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
Question about JMyron (Read 737 times)
Question about JMyron
Jun 30th, 2009, 5:14am
 
Hi,

I'm a newbie at Processing and got some questions when I use JMyron. At first I want to combine the brightness tracking function with using webcam as mouse function. It works well when it has only one brightest glob in the screen. However, if there are multi brightest globs, the camera just get to confuse Embarrassed  I guess maybe I need multi-mouses function, but still have no idea how to do that. Anybody can give me some help about it please? Cry Thanks very very much!

This is my code:

import JMyron.*;
JMyron m;

float objx = 320;
float objy = 240;
float objdestx = 320;
float objdesty = 240;

void setup(){
 size(320,240);
 m = new JMyron();//make a new instance of the object
 m.start(width,height);//start a capture
 m.trackColor(255,255,255,2);//R, G, B, and range of similarity
 m.minDensity(100); //minimum pixels in the glob required to result in a box
 println("Myron " + m.version());
 noFill();
}

void draw(){
 m.update();//update the camera view
 drawCamera();//draw the camera to the screen
 int[][] b = m.globBoxes();//get the center points

 float avX=0;
 float avY=0;
   
 //draw the boxes
 stroke(255,0,0);
 for(int i=0;i<b.length;i++){
   rect( b[i][0] , b[i][1] , b[i][2] , b[i][3] );
   
   avX += b[i][0];
   avY += b[i][1];
 }

  if(b.length-1>0){
   avX/=b.length-1;
   avY/=b.length-1;
 }

//mouse follow
  if(!(avX==0&&avY==0)&&b.length>0){
   objdestx = avX;
   objdesty = avY;
 }
 objx += (objdestx-objx)/10.0f;
 objy += (objdesty-objy)/10.0f;
 noFill();
 
 ellipse(objx,objy,30,30);

}


void drawCamera(){
 int[] img = m.image(); //get the normal image of the camera
 loadPixels();
 for(int i=0;i<width*height;i++){ //loop through all the pixels
   pixels[i] = img[i]; //draw each pixel to the screen
 }
 updatePixels();

}

public void stop(){
 m.stop();//stop the object
 super.stop();
}
Re: Question about JMyron
Reply #1 - Jul 6th, 2009, 9:29pm
 
Hi,
actually ussing a camara as a mouse requires a controlled environment, it is really hard to get acurate information from the camera if you have it installed in a "noisy" environment. You could close the cameras exposure or reduce contrast to get more accurate bright spots, try ussing lights (little lintenr bulbs or leds) and never point the camera to a window or any other source of light that way you can get a real bright point the camera con track and not multiple ones. Iv tried ussing leds in normal ambient light situations reducing the cameras exposure and it worked fine.
Be sure to understan how does jmyron works so you can control it well for me, this is the best video library due to the posibilities it gives in terms of traking.
Ill be here for all that you need
Page Index Toggle Pages: 1