Flopping webcam input horizontally

Using James George’s slit scan for a demo


But need flop the rendered output to give a mirror effect.

I assume I will need to flop the input video coming from the webcam.

Can anyone suggest how?

ok answering my own question
Came across this rather lengthy solution

but also arturo suggests just a single line will do the trick
video.draw(video.getWidth(),0,-video.getWidth(),video.getHeight());

In my case I simply added
grabber.getPixelsRef().mirror(false, true);
after
grabber.update();
in the ofApp update method.

or

ofPushMatrix();
ofTranslate(video.getWidth(),0);
ofScale(-1,1)
video.draw(0,0);
ofPopMatrix();

The grabber.getPixelsRef().mirror() approach will (AFAIK) be slower than the above or @arturo’s method because it actually modifies the underlying pixels vs. using the graphics card to draw it to the screen flipped.

Thanks
Also discovered this needs to go in my draw method, not update as in previous solution

  ofPushMatrix();
    ofTranslate(1920,0);
    ofScale(-1,1);
    
   // grabber.draw(0,0);
    slitScan.getOutputImage().draw(0, 0);
    ofPopMatrix();
1 Like