diff options
author | N.N. <sevyves@users.sourceforge.net> | 2009-09-11 20:40:11 +0000 |
---|---|---|
committer | N.N. <sevyves@users.sourceforge.net> | 2009-09-11 20:40:11 +0000 |
commit | 17ed7b467d52b597664834278fbbfbee8d77c3c1 (patch) | |
tree | d946cb56ded89b66ad8cec904590762d97a01bf0 /pix_opencv_motempl.cc | |
parent | bd706e8c7bb54f2cb7aaa7554363ca08bd2fa5d1 (diff) |
bug fixes in motempl
svn path=/trunk/externals/pix_opencv/; revision=12309
Diffstat (limited to 'pix_opencv_motempl.cc')
-rw-r--r-- | pix_opencv_motempl.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/pix_opencv_motempl.cc b/pix_opencv_motempl.cc index 938acce..e755bc5 100644 --- a/pix_opencv_motempl.cc +++ b/pix_opencv_motempl.cc @@ -40,8 +40,8 @@ pix_opencv_motempl :: pix_opencv_motempl() aperture = 3; diff_threshold = 30; last = 0; - comp_xsize = 0; - comp_ysize = 0; + comp_xsize = 320; + comp_ysize = 240; // various tracking parameters (in seconds) max_time_delta = 0.5; @@ -65,6 +65,15 @@ pix_opencv_motempl :: pix_opencv_motempl() mask_size = CV_DIST_MASK_PRECISE; + cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, 1.0, 1.0, 0, 1, 8 ); + + img = cvCreateImage(cvSize(comp_xsize,comp_ysize), IPL_DEPTH_8U, 3); + motion = cvCreateImage( cvSize(comp_xsize,comp_ysize), 8, 3 ); + cvZero( motion ); + motion->origin = img->origin; + rgba = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 4 ); + alpha = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 1 ); + } ///////////////////////////////////////////////////////// @@ -97,7 +106,7 @@ void pix_opencv_motempl :: processRGBAImage(imageStruct &image) CvPoint center; double magnitude; CvScalar color; - t_atom rlist[6]; + char tindex[10]; if ((this->comp_xsize!=image.xsize)&&(this->comp_ysize!=image.ysize)) { @@ -228,7 +237,9 @@ 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 ); - SETFLOAT(&rlist[0], j++); + 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); @@ -258,7 +269,7 @@ void pix_opencv_motempl :: processRGBImage(imageStruct &image) CvPoint center; double magnitude; CvScalar color; - t_atom rlist[6]; + char tindex[10]; if ((this->comp_xsize!=image.xsize)&&(this->comp_ysize!=image.ysize)) { @@ -383,7 +394,9 @@ 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 ); - SETFLOAT(&rlist[0], j++); + 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); @@ -415,7 +428,7 @@ void pix_opencv_motempl :: processGrayImage(imageStruct &image) CvPoint center; double magnitude; CvScalar color; - t_atom rlist[6]; + char tindex[10]; if ((this->comp_xsize!=image.xsize)&&(this->comp_ysize!=image.ysize)) { @@ -543,7 +556,9 @@ 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 ); - SETFLOAT(&rlist[0], j++); + 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); |