Looking for help to get the average of the detected blobs/rect
as an x,y variable ???
Thanks
import codeanticode.gsvideo.*;
//*** And this was the Motion tracking source I was planning to base it on. I also have a version using JMyron and another that takes one reference capture and compares all future frames to that capture.
float sensitivity; // sensitivity is a percentage of pixels changed boolean newFrame; // switch var for determining when a new frame is received color[] prevFrame; // vars for holding the current and previous frames GSCapture video;
void setup(){ size(320,240);
sensitivity=0.24; newFrame=false; stroke(240); noFill();; prevFrame=new color[320*240]; video = new GSCapture(this, width, height, 30); //frameRate(30); }
public void videoEvent(){ newFrame=true; }
void draw(){
if(video.available()){ video.read(); newFrame=false; image(video, 0, 0, width, height); // update display with current frame for(int y=0; y<30-1; y++){ // loop through video in 40x30 grid for(int x=0; x<40-1; x++){ // println(mtc++); int cxLoc=x*(320/40); // x position on grid int cyLoc=y*(240/30); // y position on grid
boolean motionTest(int srcX,int srcY,int tw, int th){ int dc=0; // counter to track number of differences color newPixel; for(int y=0;y<th;y++){ for(int x=0;x<tw;x++){ int srcPos=((srcY+y)*width)+(srcX+x); newPixel = video.pixels[srcPos]; if(abs(red(newPixel)-red(prevFrame[srcPos]))>25) dc++; prevFrame[srcPos]=newPixel; // update prevFrame w/ current pixel clr } } // test to see if number of difference is 'significant' if(dc>(sensitivity*(tw*th))){ return true; }else{ return false; } }