diff options
author | N.N. <sevyves@users.sourceforge.net> | 2009-09-11 20:40:49 +0000 |
---|---|---|
committer | N.N. <sevyves@users.sourceforge.net> | 2009-09-11 20:40:49 +0000 |
commit | c6f06840fb83c2cf43f4bb1dbe4f194d92fddbae (patch) | |
tree | 5d4d571e03fa59f001681b6b300eb7b3dbc0c003 | |
parent | 92d443d724514ce6da4a87317fa7af405131c017 (diff) |
bug fixes in motempl
svn path=/trunk/externals/pdp_opencv/; revision=12310
-rw-r--r-- | pdp_opencv_motempl-help.pd | 78 | ||||
-rw-r--r-- | pdp_opencv_motempl.c | 49 |
2 files changed, 66 insertions, 61 deletions
diff --git a/pdp_opencv_motempl-help.pd b/pdp_opencv_motempl-help.pd index 6344607..ed1f42c 100644 --- a/pdp_opencv_motempl-help.pd +++ b/pdp_opencv_motempl-help.pd @@ -11,7 +11,7 @@ movement history; #X msg 341 157 close; #X obj 271 228 pdp_v4l; #X msg 328 125 open /dev/video0; -#X obj 440 98 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 +#X obj 440 98 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X obj 440 125 metro 40; #X msg 521 144 close; @@ -28,7 +28,7 @@ movement history; #X msg 41 142 open \$1; #X msg 41 89 bang; #X msg 75 241 loop \$1; -#X obj 155 241 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X obj 155 241 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1; #X obj 155 159 loadbang; #X text 84 92 playing a video file; @@ -40,7 +40,6 @@ movement history; #X floatatom 191 500 5 0 0 0 - - -; #X floatatom 242 459 5 0 0 0 - - -; #X text 231 502 Threshold value. (default 30); -#X obj 198 587 route -1 0 1 2 3 4; #X floatatom 201 658 5 0 0 0 - - -; #X floatatom 236 658 5 0 0 0 - - -; #X floatatom 273 658 5 0 0 0 - - -; @@ -76,24 +75,26 @@ movement history; #X text 284 460 Maximal duration of motion track in seconds. (default 1.0); #X msg 115 392 aperture \$1; -#X text 291 393 aperture ( 3 \, 5 or 7 \, default 3 ); -#X msg 195 392 3; -#X msg 228 392 5; -#X msg 259 392 7; +#X msg 235 390 3; +#X msg 268 390 5; +#X msg 299 390 7; #X text 406 610 For each motion component; +#X text 327 392 aperture ( 1 \, 3 \, 5 or 7 \, default 3 ); +#X msg 202 390 1; +#X obj 198 587 route -1 1 2 3 4; #X connect 3 0 4 0; #X connect 4 0 6 0; #X connect 5 0 6 0; -#X connect 6 0 48 0; +#X connect 6 0 47 0; #X connect 7 0 6 0; #X connect 8 0 9 0; #X connect 9 0 12 0; #X connect 10 0 12 0; #X connect 11 0 12 0; -#X connect 12 0 48 0; +#X connect 12 0 47 0; #X connect 13 0 12 0; #X connect 14 0 13 0; -#X connect 15 0 48 0; +#X connect 15 0 47 0; #X connect 16 0 15 0; #X connect 17 0 16 0; #X connect 18 0 16 0; @@ -105,32 +106,33 @@ movement history; #X connect 24 0 23 0; #X connect 24 0 17 0; #X connect 27 0 15 1; -#X connect 29 0 48 1; -#X connect 30 0 50 0; -#X connect 32 0 41 0; -#X connect 32 1 42 0; -#X connect 41 0 33 0; -#X connect 41 1 34 0; -#X connect 41 2 35 0; -#X connect 41 3 36 0; +#X connect 29 0 47 1; +#X connect 30 0 49 0; +#X connect 40 0 32 0; +#X connect 40 1 33 0; +#X connect 40 2 34 0; +#X connect 40 3 35 0; +#X connect 40 4 42 0; +#X connect 41 0 36 0; +#X connect 41 1 37 0; +#X connect 41 2 38 0; +#X connect 41 3 39 0; #X connect 41 4 43 0; -#X connect 42 0 37 0; -#X connect 42 1 38 0; -#X connect 42 2 39 0; -#X connect 42 3 40 0; -#X connect 42 4 44 0; -#X connect 48 0 49 0; -#X connect 48 1 32 0; -#X connect 50 0 48 0; -#X connect 51 0 52 0; -#X connect 52 0 48 0; -#X connect 53 0 54 0; -#X connect 54 0 48 0; -#X connect 55 0 56 0; -#X connect 56 0 48 0; -#X connect 57 0 48 2; -#X connect 58 0 48 3; -#X connect 65 0 48 0; -#X connect 67 0 65 0; -#X connect 68 0 65 0; -#X connect 69 0 65 0; +#X connect 47 0 48 0; +#X connect 47 1 71 0; +#X connect 49 0 47 0; +#X connect 50 0 51 0; +#X connect 51 0 47 0; +#X connect 52 0 53 0; +#X connect 53 0 47 0; +#X connect 54 0 55 0; +#X connect 55 0 47 0; +#X connect 56 0 47 2; +#X connect 57 0 47 3; +#X connect 64 0 47 0; +#X connect 65 0 64 0; +#X connect 66 0 64 0; +#X connect 67 0 64 0; +#X connect 70 0 64 0; +#X connect 71 0 40 0; +#X connect 71 1 41 0; diff --git a/pdp_opencv_motempl.c b/pdp_opencv_motempl.c index 79fca42..76ed1ec 100644 --- a/pdp_opencv_motempl.c +++ b/pdp_opencv_motempl.c @@ -66,6 +66,7 @@ typedef struct pdp_opencv_motempl_struct IplImage *mask; // valid orientation mask IplImage *segmask; // motion segmentation map CvMemStorage* storage; // temporary storage + CvFont font; IplImage* image; IplImage* motion; @@ -87,17 +88,18 @@ typedef struct pdp_opencv_motempl_struct void pdp_opencv_motempl_update_mhi( t_pdp_opencv_motempl *x, IplImage* img, IplImage* dst, int diff_threshold ) { - double timestamp = (double)clock()/CLOCKS_PER_SEC; // get current time in seconds - CvSize size = cvSize(img->width,img->height); // get current frame size - int i, j, idx1 = x->last, idx2; - IplImage* silh; - CvSeq* seq; - CvRect comp_rect; - double count; - double angle; - CvPoint center; - double magnitude; - CvScalar color; + double timestamp = (double)clock()/CLOCKS_PER_SEC; // get current time in seconds + CvSize size = cvSize(img->width,img->height); // get current frame size + int i, j, idx1 = x->last, idx2; + IplImage* silh; + CvSeq* seq; + CvRect comp_rect; + double count; + double angle; + CvPoint center; + double magnitude; + CvScalar color; + char tindex[10]; // allocate images at the beginning or // reallocate them if the frame size is changed @@ -200,20 +202,18 @@ void pdp_opencv_motempl_update_mhi( t_pdp_opencv_motempl *x, IplImage* img, Ipl cvLine( dst, 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(&x->rlist[0], j++); - SETFLOAT(&x->rlist[1], center.x); - SETFLOAT(&x->rlist[2], center.y); - SETFLOAT(&x->rlist[3], comp_rect.width); - SETFLOAT(&x->rlist[4], comp_rect.height); - SETFLOAT(&x->rlist[5], angle); - outlet_list( x->x_dataout, 0, 6, x->rlist ); + sprintf( tindex, "%d", ++j ); + cvPutText( dst, tindex, center, &x->font, CV_RGB(255,255,255)); + SETFLOAT(&x->rlist[0], j); + SETFLOAT(&x->rlist[1], center.x); + SETFLOAT(&x->rlist[2], center.y); + SETFLOAT(&x->rlist[3], comp_rect.width); + SETFLOAT(&x->rlist[4], comp_rect.height); + SETFLOAT(&x->rlist[5], angle); + outlet_list( x->x_dataout, 0, 6, x->rlist ); } } - - - static void pdp_opencv_motempl_process_rgb(t_pdp_opencv_motempl *x) { t_pdp *header = pdp_packet_header(x->x_packet0); @@ -283,7 +283,7 @@ static void pdp_opencv_motempl_mhi_duration(t_pdp_opencv_motempl *x, t_floatarg static void pdp_opencv_motempl_aperture(t_pdp_opencv_motempl *x, t_floatarg f) { - if ( ( (int)f == 3.0 ) || ( (int)f == 5.0 ) || ( (int)f == 7.0 ) ) + if ( ( (int)f == 1.0 ) || ( (int)f == 3.0 ) || ( (int)f == 5.0 ) || ( (int)f == 7.0 ) ) { x->x_aperture = (int)f; } @@ -413,6 +413,9 @@ void *pdp_opencv_motempl_new(t_floatarg f) x->storage = NULL; + // initialize font + cvInitFont( &x->font, CV_FONT_HERSHEY_PLAIN, 1.0, 1.0, 0, 1, 8 ); + return (void *)x; } |