Cropping and tracking part of the image

Hi all,
I need to track a half of a 320 x 240 image from my camera, just looking the first 160x240 pixels, I don’t need the rest of the camera information there will be the audience; but then I need to use this 160x240 matrix stretched in a 320x240 again, like stretching only the vertical image.
What is the best way to do that?
David

Perhaps you could read the full 320x240 image from the ofVideoGrabber then manually copy the 160x240 to a new image that you could do your stretch on…

something like this…

  
  
	ofCvColorImage* imageSlice = new ofCvColorImage();  
  
	this->irVidGrabber->grabFrame();  
  
	if(this->irVidGrabber->isFrameNew()){  
		// grab the full 320x240 image from the camera  
		this->tmpColor->setFromPixels(this->irVidGrabber->getPixels(), this->cameraWidth, this->cameraHeight);  
		this->tmpColor->mirror(false, true);  
  
		unsigned char* slicePixels = new unsigned char[160*240*3];  
		unsigned char* fullPixels = this->tmpColor->getPixels();  
  
		imageSlice->allocate(160, 240);  
		for(int i=0; i < 240; i++){  
			for(int j=0; j < 160; j++){  
				for(int b=0; b < 3; b++){  
					slicePixels[(i*160+j)*3+b] = colourPixels[(i*320+j)*3+b];  
				}  
			}  
		}  
	}  
	imageSlice->setFromPixels(slicePixels, 160, 240);  
  

That code would be done in your update() method… you’d probably want to make imageSlice an object-scope (member) variable instead of a local function-scope variable so you can access it from your draw() and do something like imageSlice->draw(0, 0, 320, 240);

Hope that helps a little bit to get you in the right direction…