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
JMyron globCenters() problem (Read 790 times)
JMyron globCenters() problem
Dec 23rd, 2007, 9:12pm
 
my problem is tracking motions. Actually it is working well but there is rectanle shape at x=0,y=0. it always there Sad... do u know how to fix this problem...

code is here:
//---------------------------------------------

import JMyron.*;

JMyron m;

void setup() {
    size(320,240);
    m = new JMyron();
    m.start(width,height);
    println(m.getForcedWidth());
    println(m.getForcedHeight());
    m.findGlobs(1);
    m.adaptivity(50.0);
    m.minDensity(100);
    m.maxDensity(10000);
    loadPixels();
    frameRate(15);
    noFill();
    stroke(255,0,0);
    rectMode(CORNERS);
}

void draw() {
    background(0);
    m.update();
    m.imageCopy(pixels);
    updatePixels();
    display(m.globCenters());
}

void display(int [][] lst) {
    for (int i=0;i<lst.length;i++) {
         int x = lst[i][0];
         int y = lst[i][1];
         rect(x-2,y-2,x+2,y+2);
    }
}
Re: JMyron globCenters() problem
Reply #1 - Dec 24th, 2007, 1:26pm
 
Yes, I came across that problem (bug?), too.

My solution was to just filter it out... I just scanned all the centers and discarded the (0, 0) one.

jc
Re: JMyron globCenters() problem
Reply #2 - Dec 24th, 2007, 3:52pm
 
how? can u be more clear plz? Smiley
Re: JMyron globCenters() problem
Reply #3 - Dec 24th, 2007, 8:22pm
 
In your example, you could just do:

void display(int [][] lst) {
    for (int i=0;i<lst.length;i++) {
       
        int x = lst[i][0];
        int y = lst[i][1];
        if (x > 0.001 || y > 0.001) {
             rect(x-2,y-2,x+2,y+2);
        }
    }
}
Re: JMyron globCenters() problem
Reply #4 - Dec 24th, 2007, 9:05pm
 
thank u very much jorge.
Page Index Toggle Pages: 1