ofVideoGrabber flip image

hello !

i have a simple question (seem simple though) : i am using ofVideoGrabber to grab webcam image.
Grabbing is ok but of course as i am filming people in front of the camera, left and right are inverted.

How can i flip the image on Y axis ? and don’t see any methods in ofVideoGrabber.

thanks a lot

just draw it fliped by doing:

video.draw(video.getWidth(),0,-video.getWidth(),video.getHeight());
4 Likes

Hi Arturo,

Sorry i didn’t specify : i am doing some face detection on the image, so i need it to be flipped prior to processing.

Perhaps video.getPixelsRef().mirror(false, true); ?

2 Likes

that should work too but although you can mirror before processing it’s usually faster to just draw everything scaled to -1 in x instead. so after analysing the image just draw the result of the analysis also flipped in x

Thanks Amnon and Arturo for the suggestions.
I tried both, and both work fine.

By the way @arturo, just interested in understanding what would make pre-processing slower than post-processing ?

if you flip the whole image you need to copy every pixel, even for small images that’s for example: 640x480=307200

if you flip the mesh that you get from analysing the image that’s around 30 points, so around 10000 times less operations and drawing the image flipped is free since it’s done by the graphics card just by passing it the texture coordinates flipped

ok ! so you say ofVideoGrabber::draw() uses GPU so flipping the image at that time is less ressource consuming than doing it pixelRefs mirror() ?

thanks