videoGrabber x,y pixel colors issue

I’m trying to do a simple chroma key application using the iPhone 4 camera and am running into some weird issues. In trying to grab the pixel color of where you touch down, I seem to be getting sporadic color values that seem outside the realm of possible pixel color values even factoring in the noise of the camera sensor. If I set the x,y value of the pixel color to use to 0,0, I get the correct color value, but as soon as I change it to touch.x and touch.y I get incongruous values. Setting the x,y value to ofGetWidth() and ofGetHeight() also spits out garbage. Is there an issue w/ orientation? I know the videoGrabber proportions are not the same as the iPhone screen but I don’t think that is the issue…see code below. Thanks for any help on this weird issue.

  
  
#include "testApp.h"  
  
//--------------------------------------------------------------  
void testApp::setup(){	  
	ofxiPhoneSetOrientation(OFXIPHONE_ORIENTATION_PORTRAIT);  
  
	ofSetFrameRate(30);  
  
	grabber.initGrabber(360,480, OF_PIXELS_BGRA);	  
	pix = new unsigned char[ (int)( grabber.getWidth() * grabber.getHeight() * 3.0) ];  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
	ofBackground(255,255,255);	  
	  
	grabber.update();  
  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){	  
	  
	ofSetColor(255);  
	grabber.draw(0, 0);//,grabber.getWidth()/2.0,grabber.getHeight()/2.0);  
    ofSetColor(touchColor);  
    ofFill();  
    ofCircle(ofGetWidth()/2.0,ofGetHeight()/2.0,30);  
      
}  
  
//--------------------------------------------------------------  
void testApp::exit(){  
      
}  
  
//--------------------------------------------------------------  
void testApp::touchDown(ofTouchEventArgs & touch){  
  
}  
  
//--------------------------------------------------------------  
void testApp::touchMoved(ofTouchEventArgs & touch){  
  
      
    int x = touch.x;  
    int y = touch.y;  
      
    unsigned char * src = grabber.getPixels();  
      
    //y = 0;  
    //x = 0;  
      
    touchColor.r = src[y*(int)grabber.getWidth() + x];  
    touchColor.g = src[y*(int)grabber.getWidth() + x+1];  
    touchColor.b = src[y*(int)grabber.getWidth() + x+2];  
      
     
    printf("touch down at (%i,%i)\n", x,y);  
    printf("grabber w,h: (%i,%i)\n", (int)grabber.getWidth(),(int)grabber.getHeight());  
    printf("iphone w,h: (%i,%i)\n",(int)ofGetWidth(),(int)ofGetHeight());  
  
      
}  
  

i don’t know where the error is in your code.
but this gives me coherent results:

  
ofColor color = grabber.getColor(x,y);  
cout << ofToString(color) << endl;  

Thanks for the reply, I’ll try this out and get back.