Hi everyone!
I'm working on some blob detection using JMyron. My goal is to consistently detect blobs and then outline & fill them.
I've encountered a strange problem - some blob shapes don't seem to be closing. This results in long lines cutting across the blobs, and the fill not looking right.
Any help would be hugely appreciated. I really love processing but can't seem to get past this issue!
Here's a link to a screenshot:
benzer.la/images/storage/blob_problem.gif
Here's the code:
Code:
import JMyron.*;
PImage buffer;
float level;
JMyron m1, m2;
void setup(){
int w = 640;
int h = 480;
size(w,h);
m1 = new JMyron();
m2 = new JMyron();
m1.start(640,480);
m1.findGlobs(1);
buffer = new PImage (640, 480);
}
void draw(){
m1.trackColor(255,255,255,220);
m1.update();
m1.imageCopy(buffer.pixels);
buffer.updatePixels();
buffer.filter(THRESHOLD, 0.5);
background(100);
fill(255,255,255);
noStroke();
ellipse(250,250,150,150);
rect(250,250,150,150);
image(buffer, 0, 0);
buffer = get();
m2.findGlobs(1);
m2.hijack(640, 480, buffer.pixels);
m2.trackColor(255,255,255,5);
m2.minDensity(300);
m2.update();
int list[][][] = m2.globEdgePoints(4);
stroke(250,0,250);
for(int i=0;i<list.length;i++){
fill(250,250,0);
int[][] pixellist = list[i];
if(pixellist!=null){
beginShape();
for(int j=0;j<pixellist.length;j++){
vertex(pixellist[j][0], pixellist[j][1]);
}
endShape(CLOSE);
}
}
}
public void stop(){
m1.stop();
m2.stop();
super.stop();
}