Resize a Video Crap

(sry for my english)

Hey, i have a problem and need your help. All i want is to grab images (sequences) from my camera and display them on screen with a size of 640/240. In addition i want to “save” and display a copy in half the size. (320/240) I just tried to copy the Grab by using

colorImg2 = colorImg; and resize it with
colorImg2.resize(320/240);

but this doesnt work… it displays only a quarter (the top-left corner) of the original Grab.

Here’s the code…

  
void testApp::setup(){	   
	vidGrabber.setVerbose(true);  
	vidGrabber.initGrabber(640,480);  
	  
	grabW = vidGrabber.width;  
	grabH = vidGrabber.height;  
	  
    colorImg.allocate(grabW,grabH);  
	colorImg2.allocate(grabW/2,grabH/2);  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
	ofBackground(100,100,100);  
    bool bNewFrame = false;  
	  
	vidGrabber.grabFrame();  
	bNewFrame = vidGrabber.isFrameNew();  
	  
	if (bNewFrame){  
		colorImg.setFromPixels(vidGrabber.getPixels(), grabW, grabH);  
		colorImg2 = colorImg;  
		colorImg2.resize(grabW/2, grabH/2);  
	}  
}  
//--------------------------------------------------------------  
void testApp::draw(){  
	ofSetColor(0xffffff);  
    colorImg.draw(20,20);	  
	colorImg2.draw(700,20);  
}  

this is what i got:

http://helpmode.de/trash/face1.jpg

Where is the Mistake?

I think what’s happening is this: you’re allocating the image with 320x240, then copying the 640x480 in, then “resizing” the 320x240 image to 320x240. So, during the copy you just get the corner – then during the resize nothing happens.

Try changing this line:

  
  
colorImg2.allocate(grabW/2,grabH/2);  
  

To this:

  
  
colorImg2.allocate(grabW,grabH);  
  

I changed the line, but nothing different happend. I get the same result.

I dont understand why this does not work. When i resize an static image (jpg for example) it works. And here i am just saving an sequence from my cam to an image, why i can resize it normally? :frowning:

Another ideas?

Looking at the source for ofImage, it looks like what Kyle says should work.

After the resize, colorImg2 should only be 320x240 in size.

hi kamil,

i came across the same problem,
resize() doesn’t do what you’d expect it to.
so try using,

resizeImg.allocate( 320, 240 );
resizeImg.scaleIntoMe( sourceImg );

L.

Thanks! That’s it!

:stuck_out_tongue: