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.
IndexProgramming Questions & HelpSyntax Questions › Event from Jmyron Glob Detection and time delay
Page Index Toggle Pages: 1
Event from Jmyron Glob Detection and time delay (Read 529 times)
Event from Jmyron Glob Detection and time delay
Nov 30th, 2009, 1:35pm
 
My question comes in 2 parts but first I will describe my sketch's purpose.

The goal of this sketch is that while capture device is running (Im using JMyron library) I will hold up a red(or other brightly colored) object and upon detecting the red object a 3 second timer will begin and at the end of 3 seconds it will saveFrame().

as it sits now I have it set to saveFrame() based upon the predetermined position of the red object which is not what I want as I stated in the description. So I need help understanding how to set a historical variable from which I can check and compare the position of the red object. Also the "timer" syntax i have set up does not work. It reads it from the start of the program and not based on the if() event.

Question #1  How do set up a historical variable that I can use to compare the current position of the red object to the old position? (when no red object is on screen the draw() repeats the last known position of the red object)  That way I can then then set a Boolean variable of true false to activate saveFrame().

Question #2 How can I get my timer to work like I want it to?  is there a library I can download to get the results I want?

THank you for your help

import JMyron.*;

JMyron m;
boolean foundIt = false;
int xPoint;

void setup(){  
 size(640,480);
 m = new JMyron();
 m.start(640,480);  //sets video window
 m.findGlobs(1); //find Globs ON
 frameRate(60);
}

void draw(){
 //code to generate image START
 m.trackColor(255,55,0,150);  //set trackColor to RED
 m.update();
 int[] img = m.image();  
 loadPixels();
 for(int i=0;i<width*height;i++){
     pixels[i] = img[i];
 }
 updatePixels();
 //code to generate image END
 
 noFill();
 int[][] a;  //set array A
 
 //draw bounding box around RED  object
 a = m.globBoxes();
 stroke(255,0,0);
 for(int i=0;i<a.length;i++){
   int[] b = a[i];
   rect(b[0], b[1], b[2], b[3]);
   xPoint = b[1]; //set variable to be used as a global value
   //for the position of bounding box of red object
 }
 println(xPoint);
 
 if(xPoint == 250){    
    picture();
    println(foundIt);
    println("Saved Image");  
}
}
public void stop(){
 m.stop();
 super.stop();
}

void picture(){
 int s = millis();
 if (s >= 4000) {
   saveFrame("IMadeAPose-####.png");
 }
}
Re: Event from Jmyron Glob Detection and time delay
Reply #1 - Nov 30th, 2009, 9:19pm
 
Hi,
I suggest you ask this question in the video capture board. There's a number of people experienced with JMyron. I don't use JMyron for tracking but I do track colors with my own code. I simply find all red points and average their x positions to get the center of red points (center of mass if you're familiar with college physics). This process is fairly quick and simple.
Page Index Toggle Pages: 1