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
making JMyron mirror imaged (Read 1249 times)
making JMyron mirror imaged
Jan 2nd, 2009, 10:12pm
 
How do you make Jmyron output a mirror image?
Re: making JMyron mirror imaged
Reply #1 - Jan 3rd, 2009, 12:54pm
 
Hello!

Something like this should do what you want...

m.update();
 int[] imgNormal = m.cameraImage();
 
 this.loadPixels();
 for(int i=1; i<width;i++){
   for(int j=1;j<height;j++){
     this.pixels[(m.width() - i - 1) + j * m.width()] = imgNormal[(i) + j * m.width()];
   }
 }
 this.updatePixels();
 
 
 arraycopy(m.cameraImage(),img.pixels);
 img.updatePixels();
 
 image(img,0,0);
Re: making JMyron mirror imaged
Reply #2 - Jan 3rd, 2009, 8:36pm
 
Thanks Goju-Ryu, but I can't plug it in without getting a "double image." Below is the project I am working on based on the myron "pixelfun." Any suggestions will be appreciated.


import JMyron.*;

JMyron m;

void setup(){
 size(1024,640);
 
 
 m = new JMyron();
 m.start(width,height);
 m.findGlobs(0);
 
 rectMode(CENTER);
 
}

void draw(){
 background(255);
 m.update();
 int[] img = m.image();
 
 for(int y=0;y<height;y+=6){
   for(int x=0;x<width;x+=9){
     float av = (red(img[y*width+x]))/2.0;

     fill(red(img[y*width+x]));
     
     pushMatrix();
     rotate(av/6000.0);
     translate(x,y);
     rect(0,0,(25-av)/5.0,(25-av)/5.0);
     popMatrix();
   }
 }
}
Re: making JMyron mirror imaged
Reply #3 - Apr 5th, 2010, 10:47am
 
I've been trying to achieve the same - create mirror output - while using Myron & the differencing eg... to no avail. Am also somewhat new to processing. Have you found a solution to this? Anyone else?
Re: making JMyron mirror imaged
Reply #4 - Apr 7th, 2010, 8:45am
 
figured something out m'self ; here is the solution that is working for me:

Code:

//init array for recording difference image (btwn prior & current frames)
//ext lib function : returns the difference image
//get the normal image of the camera

int[] img = m.differenceImage();
loadPixels();

//cycle through all the pixels and add the frame's pixels to screen
//to take a 1d array that is counting in rows/width and find the 2d x,y coord's
//creating mirror reflection : turn all pixels on x axis backward
//draw all differencing pixels to screen on both the x, y axis'


for(int i = 0; i < width*height; i++){
int y=i/width;
int x=i%width;
x=width-x-1;
pixels[i] = img[y*width+x];
}
println("x=" + x);

//processing command that updates the display window with the data in the pixels[] array).

updatePixels();

Page Index Toggle Pages: 1