live video vertical flip (mirroring)

Is there a standard way of flipping live video vertically, to get “mirror” effect?

haven’t tried but something like:


should draw a 640x480 video in 20,20 vertically fliped.

thanks will try that.

That does not work folks. You can do something like this:

		//flip image (slows things down a lot!!)	  
		if(flipVideo) {  
			unsigned char * pixels = video.getPixels();  
			for (int i = 0; i < height; i++) {  
				for (int j = 0; j < width*3; j+=3) {  
					// pixel number  
					int pix1 = (i*width*3) + j;  
					int pix2 = (i*width*3) + (j+1);  
					int pix3 = (i*width*3) + (j+2);  
					// mirror pixel number  
					int mir1 = (i*width*3)+1 * (width*3 - j-3);  
					int mir2 = (i*width*3)+1 * (width*3 - j-2);  
					int mir3 = (i*width*3)+1 * (width*3 - j-1);	  
					//assign pixels  
					videoMirror[pix1] = pixels[mir1];  
					videoMirror[pix2] = pixels[mir2];  
					videoMirror[pix3] = pixels[mir3];  
			videoColorCvImage.setFromPixels(videoMirror, width, height);  
		} else {  
			videoColorCvImage.setFromPixels(video.getPixels(), width, height);  

I’ve noticed this slows things down a lot - so I’m going to try IGlasses or Adjusting this in the video settings…anyone know how to optimize this? (slows things from 80fps to 30fps)

what kind of ‘does not work’? the video isn’t drawn vertically, or you just can’t see it any more?

if you can’t see it any more, it’s simply possible that it’s just being drawn off-screen. when you flip vertically, the bottom right corner becomes the top right corner. that’s why the code is :
videoPlayer.draw( 20, 500, 640, -480 );

you can also try this:

ofSetRectMode( OF_RECTMODE_CENTER );  
ofTranslate( video_centre_x, video_centre_y, 0 );  
ofScale( 1, -1, 1 );  
videoPlayer.draw( 0, 0, 640, 480 );  
ofSetRectMode( OF_RECTMODE_CORNER );  

should also draw flipped, centred at video_centre_x, video_centre_y.