forsaqn
|
here is the code. i get strange values. void myfunc() { unsigned int ix,xx, yy, y1, u1, v1, sumx, sumy,totalpix, centerx,centery; unsigned char *frame_buf, *frame_buf2; frame_buf = FRAME_BUF; frame_buf2 = FRAME_BUF2; // grab_frame() ; while(1){ grab_reference_frame() ; compute_frame_diff((unsigned char *)FRAME_BUF, (unsigned char *)FRAME_BUF2, imgWidth, imgHeight); // move_image((unsigned char *)DMA_BUF1, (unsigned char *)DMA_BUF2, (unsigned char *)FRAME_BUF, imgWidth, imgHeight); //move_image((unsigned char *)DMA_BUF1, (unsigned char *)DMA_BUF2, (unsigned char *)FRAME_BUF2, imgWidth, imgHeight); //compute_frame_diff((unsigned char *)FRAME_BUF, (unsigned char *)FRAME_BUF2, imgWidth, imgHeight); y1 = u1=v1 =xx=0; yy=0; centerx=centery=totalpix =sumx=0; sumy =0; for (xx=0; xx<imgWidth; xx+=2) { for (yy=0; yy<imgHeight; yy++) { ix = index(xx,yy); y1 = (((unsigned int)frame_buf[ix+1] + (unsigned int)frame_buf[ix+3])); u1 = ((unsigned int)frame_buf[ix]); v1 = ((unsigned int)frame_buf[ix+2]); if(y1>80 && u1> 30 && v1> 30){ sumx=sumx+xx; sumy=sumy+yy; totalpix=totalpix+1; /* printf(" %u", y1);*/ } }} centerx=sumx/totalpix; centery=sumy/totalpix; if (sumx>0 && sumy>0){printf(" &&& x:%u y:%u totalpix:%u &&&",centerx,centery,totalpix );} move_image((unsigned char *)DMA_BUF1, (unsigned char *)DMA_BUF2, (unsigned char *)FRAME_BUF, imgWidth, imgHeight) ; }return;
|