We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Mirror/flip image (Read 4748 times)
Mirror/flip image
Sep 7th, 2008, 1:50pm
 
Is there a simple way to flip video capture on the y-axis/horizontally?? I have managed to flip the video entirely, so the whole thing is upside down, but this obviously defeats the purpose. There a couple examples included which do flip the image, titled Mirror and Mirror2, but they continue on to distort the image. Ideally I would like to flip the image and then apply some sort of Brightness tracking (tracking or threshold, really would like this end to be open for me to do whatever I need to).

So, are there any examples/tutorials/etc that simply flip live video capture?
Re: Mirror/flip image
Reply #1 - Sep 9th, 2008, 10:27pm
 
something like that maybe?

Code:
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
pixels[(video.height-y-1)*video.width+x] = video[y*video.width+x];
}
}
Re: Mirror/flip image
Reply #2 - Sep 10th, 2008, 10:33pm
 
Yeah not bad but it flips the image on the x-axis, which is not what I want. I want to flip it on the y-axis - a horizontal flip. So that when a user is looking into the screen if they move right the image moves right, left if they move left, and so on.
Re: Mirror/flip image
Reply #3 - Sep 15th, 2008, 6:00pm
 
You can see example in Processing Library
http://processing.org/learning/libraries/mirror.html
Or try the code below
Enjoy!

 loadPixels();
   // Begin loop for width
   for (int i = 0; i < width; i++) {
     // Begin loop for height
     for (int j = 0; j < height; j++) {    
       pixels[j*width+i] = img[(width - i - 1) + j*width]; // Reversing x to mirror the image

     }
   }
 updatePixels();
Re: Mirror/flip image
Reply #4 - Sep 17th, 2008, 11:42am
 
Hmm, was just looking at that code. Will try that out, thanks.
Page Index Toggle Pages: 1