static void sib_cleanup(struct blob_list* blist, struct blob* b) // seems to do too much { struct blob* s1; struct blob* s3; if (b->sib_p == NULL && b->sib_n == NULL) {return;} // paranoid... //if (b->sib_p != NULL && b->y > b->sib_p->y) // {return;} // should raise an error //if (b->sib_n != NULL && b->y > b->sib_n->y) // {return;} // should raise an error s1 = b->sib_p; s3 = b->sib_n; if (s1 != NULL && range_overlap(b->x1, b->x2, s1->x1, s1->x2)) {blob_merge(s1, b); blob_reap(blist, b); return;} if (s3 != NULL && range_overlap(b->x1, b->x2, s3->x1, s3->x2)) {blob_merge(s3, b); blob_reap(blist, b); return;} if (s1 != NULL) {blob_merge(s1, b); blob_reap(blist, b); return;} if (s3 != NULL) {blob_merge(s3, b); blob_reap(blist, b); return;} }
static void flush_incremental(void* user_struct, struct blob_list* blist, struct blob* blob_now) // merges/prints/reaps everything before blob_now { struct blob* b; struct blob* b2; // pass 1, merge old sibs b = blob_now; while (b->sib_p) { b = b->sib_p; if (b->y != blob_now->y-1) {continue;} if (b->x1 == -1) {break;} if (b->x2 > blob_now->x2) {continue;} // merge b into b2 b2 = b->sib_n; blob_merge(b2, b); blob_reap(blist, b); b = b2; } // pass 2, log isolated blobs b = blob_now; while (b->prev) { b = b->prev; if (b->y != blob_now->y-1) {continue;} if (b->x1 == -1) {break;} if (b->sib_n || b->sib_p) {continue;} b2 = b->next; log_blob_hook(user_struct, b); blob_reap(blist, b); b = b2; } }
int main() { /* Variable Definition */ int coreid; int i,j; int start_frame; int index; int time; coreid = get_core_id(); if (coreid == 0) { // initialization NB_BLOB = 0 ; start_frame = 0; for(i=0;i<NFRAME;i++){ // for each frame //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// //%%%%%%%%%%%%%%% * DATA TRANSFER FROM L2 TO L1 * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%// index = 0; N_pixel = N_pixelL2[i]; reset_timer(); start_timer(); for(j=start_frame; j<start_frame + N_pixel*2; j++){ pixel[index++]=pixelL2[j]; } stop_timer(); printf("FRAME: %d (%d-%d) Transfer Time: %d\n",i,start_frame,j,get_time()); start_frame = j; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// //%%%%%%%%%%%%%%% * PROCESSING * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// init_data(); reset_timer(); start_timer(); blob_formation(); stop_timer(); printf("Blob Formation Time: %d\n",get_time(),0,0,0); reset_timer(); start_timer(); prevBlob_filter(); stop_timer(); printf("Filtering prev Blob List Time: %d\n",get_time(),0,0,0); reset_timer(); start_timer(); newBlob_filter(); stop_timer(); printf("Filtering new Blob List Time: %d\n",get_time(),0,0,0); reset_timer(); start_timer(); blob_merge(); stop_timer(); printf("Blob Merging Time: %d\n",get_time(),0,0,0); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// //%%%%%%%%%%%%%%% * CHECKSUM * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%// printf("FRAME = %d\n",i,0,0,0); printf("NB_BLOB = %d\n",NB_BLOB,0,0,0); for(j=0;j<NB_BLOB;j++){ printf("Blob %d: centroid = (%d,%d), weight = %d, ",j,BLOB_LIST[j].xc,BLOB_LIST[j].yc,BLOB_LIST[j].W); printf("xmax = %d, xmin = %d, ymax = %d, ymin = %d\n",BLOB_LIST[j].xmax, BLOB_LIST[j].xmin, BLOB_LIST[j].ymax, BLOB_LIST[j].ymin); if(BLOB_LIST[j].xc == results[(i*B_MAX+j)*6 ]) printf("OK xc!\t",0,0,0,0); else printf("FAIL xc!\t",0,0,0,0); if(BLOB_LIST[j].yc == results[(i*B_MAX+j)*6+1 ]) printf("OK yc!\t",0,0,0,0); else printf("FAIL yc!\t",0,0,0,0); if(BLOB_LIST[j].xmax == results[(i*B_MAX+j)*6+2 ]) printf("OK xmax!\t",0,0,0,0); else printf("FAIL xmax!\t",0,0,0,0); if(BLOB_LIST[j].xmin == results[(i*B_MAX+j)*6+3 ]) printf("OK xmin!\t",0,0,0,0); else printf("FAIL xmin!\t",0,0,0,0); if(BLOB_LIST[j].ymax == results[(i*B_MAX+j)*6+4 ]) printf("OK ymax!\t",0,0,0,0); else printf("FAIL ymax!\t",0,0,0,0); if(BLOB_LIST[j].ymin == results[(i*B_MAX+j)*6+5 ]) printf("OK ymin!\n",0,0,0,0); else printf("FAIL ymin!\n",0,0,0,0); } printf("\n\n",0,0,0,0); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// } eoc(0); } }