aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN.N. <sevyves@users.sourceforge.net>2009-09-11 20:40:11 +0000
committerN.N. <sevyves@users.sourceforge.net>2009-09-11 20:40:11 +0000
commit17ed7b467d52b597664834278fbbfbee8d77c3c1 (patch)
treed946cb56ded89b66ad8cec904590762d97a01bf0
parentbd706e8c7bb54f2cb7aaa7554363ca08bd2fa5d1 (diff)
bug fixes in motempl
svn path=/trunk/externals/pix_opencv/; revision=12309
-rw-r--r--pix_opencv_motempl-help.pd76
-rw-r--r--pix_opencv_motempl.cc31
-rw-r--r--pix_opencv_motempl.h3
3 files changed, 64 insertions, 46 deletions
diff --git a/pix_opencv_motempl-help.pd b/pix_opencv_motempl-help.pd
index e30eea2..4e27a3c 100644
--- a/pix_opencv_motempl-help.pd
+++ b/pix_opencv_motempl-help.pd
@@ -1,4 +1,4 @@
-#N canvas 1 49 1025 780 10;
+#N canvas 5 49 1025 780 10;
#X obj 398 31 gemhead;
#X obj 373 555 pix_texture;
#X obj 373 583 square 2;
@@ -59,7 +59,6 @@
#X obj 480 37 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 361 240 translateXYZ 4 0 0;
-#X obj 504 533 route -1 0 1 2 3 4;
#X floatatom 507 613 5 0 0 0 - - -;
#X floatatom 542 613 5 0 0 0 - - -;
#X floatatom 579 613 5 0 0 0 - - -;
@@ -115,6 +114,7 @@ movement history;
#X msg 537 70 colorspace RGBA;
#X msg 641 70 colorspace RGB;
#X msg 600 44 colorspace Grey;
+#X obj 504 533 route -1 1 2 3 4;
#X connect 0 0 21 0;
#X connect 1 0 2 0;
#X connect 4 0 5 0;
@@ -136,43 +136,43 @@ movement history;
#X connect 21 2 17 0;
#X connect 22 0 21 0;
#X connect 23 0 22 0;
-#X connect 24 0 66 0;
-#X connect 25 0 38 0;
-#X connect 25 1 39 0;
-#X connect 25 2 40 0;
-#X connect 38 0 26 0;
-#X connect 38 1 27 0;
-#X connect 38 2 28 0;
-#X connect 38 3 29 0;
+#X connect 24 0 65 0;
+#X connect 37 0 25 0;
+#X connect 37 1 26 0;
+#X connect 37 2 27 0;
+#X connect 37 3 28 0;
+#X connect 37 4 40 0;
+#X connect 38 0 29 0;
+#X connect 38 1 30 0;
+#X connect 38 2 31 0;
+#X connect 38 3 32 0;
#X connect 38 4 41 0;
-#X connect 39 0 30 0;
-#X connect 39 1 31 0;
-#X connect 39 2 32 0;
-#X connect 39 3 33 0;
+#X connect 39 0 33 0;
+#X connect 39 1 34 0;
+#X connect 39 2 35 0;
+#X connect 39 3 36 0;
#X connect 39 4 42 0;
-#X connect 40 0 34 0;
-#X connect 40 1 35 0;
-#X connect 40 2 36 0;
-#X connect 40 3 37 0;
-#X connect 40 4 43 0;
-#X connect 49 0 66 1;
-#X connect 50 0 52 0;
-#X connect 52 0 66 0;
-#X connect 53 0 54 0;
-#X connect 54 0 66 0;
-#X connect 55 0 56 0;
-#X connect 56 0 66 0;
-#X connect 57 0 58 0;
-#X connect 58 0 66 0;
-#X connect 59 0 66 2;
-#X connect 60 0 66 3;
-#X connect 66 0 1 0;
-#X connect 66 1 25 0;
-#X connect 67 0 66 0;
-#X connect 69 0 67 0;
-#X connect 70 0 67 0;
-#X connect 71 0 67 0;
-#X connect 75 0 76 0;
+#X connect 48 0 65 1;
+#X connect 49 0 51 0;
+#X connect 51 0 65 0;
+#X connect 52 0 53 0;
+#X connect 53 0 65 0;
+#X connect 54 0 55 0;
+#X connect 55 0 65 0;
+#X connect 56 0 57 0;
+#X connect 57 0 65 0;
+#X connect 58 0 65 2;
+#X connect 59 0 65 3;
+#X connect 65 0 1 0;
+#X connect 65 1 78 0;
+#X connect 66 0 65 0;
+#X connect 68 0 66 0;
+#X connect 69 0 66 0;
+#X connect 70 0 66 0;
+#X connect 74 0 75 0;
+#X connect 75 0 21 0;
#X connect 76 0 21 0;
#X connect 77 0 21 0;
-#X connect 78 0 21 0;
+#X connect 78 0 37 0;
+#X connect 78 1 38 0;
+#X connect 78 2 39 0;
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);
diff --git a/pix_opencv_motempl.h b/pix_opencv_motempl.h
index f8bf1cb..8a8e0b5 100644
--- a/pix_opencv_motempl.h
+++ b/pix_opencv_motempl.h
@@ -121,6 +121,9 @@ class GEM_EXTERN pix_opencv_motempl : public GemPixObj
IplImage *segmask; // motion segmentation map
CvMemStorage* storage; // temporary storage
t_outlet *m_dataout;
+ CvFont font;
+ t_atom rlist[6];
+
};
#endif // for header file