// group.cc // // process disparity information into groups of similar velocity #include "image.h" #include #include #include #include #include #include "lib.h" #define MAXGROUP 16 #define MINGROUPSIZE (50) // width/height ratio (discard if less than) #define MINGROUPRATIO (1.5) // main, duh int main(int argc, char *argv[]) { float *image[argc-1]; int *maxx, *maxy; if (argc<3) { cerr << "usage: group file1.pgm file2.pgm [file3.pgm ...]" << endl; exit(-1); } // allocate space maxx=new int[argc-1]; maxy=new int[argc-1]; for (int i=1;imax) { whichx=j%17-8; whichy=j/17-8; max=c[j]; } if ((whichx==0) && (whichy==0)) break; // all out of motion // cout << "prominent velocity: ("<MAXGROUP) break; for (int x=0;xMAXGROUP) break; // recursively group pixels around (x,y) radius 1 int gsize=build_group(txmap,tymap,mask,xsize,ysize,x,y,1,col+1); if (gsize>0) { // clear out the old mask and generate working mask bcopy(mask,wmask,sizeof(int)*xsize*ysize); bzero(mask,sizeof(int)*xsize*ysize); // build x,y pixel histograms so we can define boundaries int xhist[xsize]; bzero(xhist,sizeof(int)*xsize); int yhist[ysize]; bzero(yhist,sizeof(int)*ysize); compute_xy_histogram(wmask,xhist,yhist,xsize,ysize); int x1,y1,x2,y2,cx,cy; find_bounding_rect(xhist,yhist,xsize,ysize,0.8,x1,x2,y1,y2,cx,cy); // is the target an acceptable shape? if ((y2-y1+1)