From f3117bf10c367592e30a7b5559e30d7b75b494f3 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Mon, 21 Sep 2009 07:39:56 +0000 Subject: fix global movement detection svn path=/trunk/externals/pix_opencv/; revision=12422 --- pix_opencv_motempl.cc | 99 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 27 deletions(-) diff --git a/pix_opencv_motempl.cc b/pix_opencv_motempl.cc index 120a243..545b437 100644 --- a/pix_opencv_motempl.cc +++ b/pix_opencv_motempl.cc @@ -237,15 +237,30 @@ void pix_opencv_motempl :: processRGBAImage(imageStruct &image) cvLine( motion, center, cvPoint( cvRound( center.x + magnitude*cos(angle*CV_PI/180)), cvRound( center.y - magnitude*sin(angle*CV_PI/180))), color, 3, CV_AA, 0 ); - sprintf( tindex, "%d", ++j ); - cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); - SETFLOAT(&rlist[0], j); - SETFLOAT(&rlist[1], center.x); - SETFLOAT(&rlist[2], center.y); - SETFLOAT(&rlist[3], comp_rect.width); - SETFLOAT(&rlist[4], comp_rect.height); - SETFLOAT(&rlist[5], angle); - outlet_list( m_dataout, 0, 6, rlist ); + if( i < 0 ) // case of the whole image + { + sprintf( tindex, "%d", i ); + cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); + SETFLOAT(&rlist[0], i); + SETFLOAT(&rlist[1], center.x); + SETFLOAT(&rlist[2], center.y); + SETFLOAT(&rlist[3], comp_rect.width); + SETFLOAT(&rlist[4], comp_rect.height); + SETFLOAT(&rlist[5], angle); + outlet_list( m_dataout, 0, 6, rlist ); + } + else + { + sprintf( tindex, "%d", ++j ); + cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); + SETFLOAT(&rlist[0], j); + SETFLOAT(&rlist[1], center.x); + SETFLOAT(&rlist[2], center.y); + SETFLOAT(&rlist[3], comp_rect.width); + SETFLOAT(&rlist[4], comp_rect.height); + SETFLOAT(&rlist[5], angle); + outlet_list( m_dataout, 0, 6, rlist ); + } } @@ -394,15 +409,30 @@ void pix_opencv_motempl :: processRGBImage(imageStruct &image) cvLine( motion, center, cvPoint( cvRound( center.x + magnitude*cos(angle*CV_PI/180)), cvRound( center.y - magnitude*sin(angle*CV_PI/180))), color, 3, CV_AA, 0 ); - sprintf( tindex, "%d", ++j ); - cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); - SETFLOAT(&rlist[0], j); - SETFLOAT(&rlist[1], center.x); - SETFLOAT(&rlist[2], center.y); - SETFLOAT(&rlist[3], comp_rect.width); - SETFLOAT(&rlist[4], comp_rect.height); - SETFLOAT(&rlist[5], angle); - outlet_list( m_dataout, 0, 6, rlist ); + if( i < 0 ) // case of the whole image + { + sprintf( tindex, "%d", i ); + cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); + SETFLOAT(&rlist[0], i); + SETFLOAT(&rlist[1], center.x); + SETFLOAT(&rlist[2], center.y); + SETFLOAT(&rlist[3], comp_rect.width); + SETFLOAT(&rlist[4], comp_rect.height); + SETFLOAT(&rlist[5], angle); + outlet_list( m_dataout, 0, 6, rlist ); + } + else + { + sprintf( tindex, "%d", ++j ); + cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); + SETFLOAT(&rlist[0], j); + SETFLOAT(&rlist[1], center.x); + SETFLOAT(&rlist[2], center.y); + SETFLOAT(&rlist[3], comp_rect.width); + SETFLOAT(&rlist[4], comp_rect.height); + SETFLOAT(&rlist[5], angle); + outlet_list( m_dataout, 0, 6, rlist ); + } } @@ -556,15 +586,30 @@ void pix_opencv_motempl :: processGrayImage(imageStruct &image) cvLine( motion, center, cvPoint( cvRound( center.x + magnitude*cos(angle*CV_PI/180)), cvRound( center.y - magnitude*sin(angle*CV_PI/180))), color, 3, CV_AA, 0 ); - sprintf( tindex, "%d", ++j ); - cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); - SETFLOAT(&rlist[0], j); - SETFLOAT(&rlist[1], center.x); - SETFLOAT(&rlist[2], center.y); - SETFLOAT(&rlist[3], comp_rect.width); - SETFLOAT(&rlist[4], comp_rect.height); - SETFLOAT(&rlist[5], angle); - outlet_list( m_dataout, 0, 6, rlist ); + if( i < 0 ) // case of the whole image + { + sprintf( tindex, "%d", i ); + cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); + SETFLOAT(&rlist[0], i); + SETFLOAT(&rlist[1], center.x); + SETFLOAT(&rlist[2], center.y); + SETFLOAT(&rlist[3], comp_rect.width); + SETFLOAT(&rlist[4], comp_rect.height); + SETFLOAT(&rlist[5], angle); + outlet_list( m_dataout, 0, 6, rlist ); + } + else + { + sprintf( tindex, "%d", ++j ); + cvPutText( motion, tindex, center, &font, CV_RGB(255,255,255)); + SETFLOAT(&rlist[0], j); + SETFLOAT(&rlist[1], center.x); + SETFLOAT(&rlist[2], center.y); + SETFLOAT(&rlist[3], comp_rect.width); + SETFLOAT(&rlist[4], comp_rect.height); + SETFLOAT(&rlist[5], angle); + outlet_list( m_dataout, 0, 6, rlist ); + } } -- cgit v1.2.1