aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN.N. <sevyves@users.sourceforge.net>2009-08-30 19:07:04 +0000
committerN.N. <sevyves@users.sourceforge.net>2009-08-30 19:07:04 +0000
commitf29ff03b88ab33d418c575a28447d65167d054bb (patch)
tree84a652f89dc2aff9f81bf24f2533da5165bc5d12
parentda38513babcad1e84866d30cd4b2cddb27a36eff (diff)
fixed mouse pointing ( almost )
svn path=/trunk/externals/pix_opencv/; revision=12146
-rwxr-xr-xpix_opencv_floodfill-help.pd159
-rwxr-xr-xpix_opencv_floodfill.cc38
-rwxr-xr-xpix_opencv_lk-help.pd182
-rwxr-xr-xpix_opencv_lk.cc39
-rwxr-xr-xpix_opencv_lk.h2
5 files changed, 239 insertions, 181 deletions
diff --git a/pix_opencv_floodfill-help.pd b/pix_opencv_floodfill-help.pd
index 740b1b1..356ce1c 100755
--- a/pix_opencv_floodfill-help.pd
+++ b/pix_opencv_floodfill-help.pd
@@ -1,42 +1,52 @@
-#N canvas 5 105 1192 685 10;
+#N canvas 248 107 1192 685 10;
#X obj 396 -37 gemhead;
#X obj 212 501 pix_texture;
-#X obj 212 529 square 2;
#X obj 28 132 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577
0;
#N canvas 0 22 454 304 gemwin 0;
-#X obj 132 136 gemwin;
#X obj 67 89 outlet;
#X obj 67 10 inlet;
#X obj 67 41 route create;
#X msg 67 70 set destroy;
#X msg 182 68 set create;
-#X msg 132 112 create \, 1;
-#X msg 238 112 destroy;
#N canvas 87 154 247 179 Gem.init 0;
-#X obj 118 46 loadbang;
-#X msg 118 81 reset;
-#X obj 118 113 outlet;
-#X connect 0 0 1 0;
+#X obj 112 15 loadbang;
+#X msg 62 93 reset;
+#X obj 49 135 outlet;
+#X msg 107 89 dimen 320 240;
+#X msg 202 89 frame 15;
+#X obj 107 51 t b b b;
+#X connect 0 0 5 0;
+#X connect 1 0 2 0;
+#X connect 3 0 2 0;
+#X connect 4 0 2 0;
+#X connect 5 0 3 0;
+#X connect 5 1 4 0;
+#X connect 5 2 1 0;
+#X restore 268 69 pd Gem.init;
+#X obj 162 241 gemwin;
+#X msg 161 188 create \, 1;
+#X msg 237 189 destroy;
+#X msg 188 161 dimen 320 240;
+#X msg 283 161 frame 15;
+#X obj 164 126 t b b b;
#X connect 1 0 2 0;
-#X restore 289 80 pd Gem.init;
#X connect 2 0 3 0;
-#X connect 3 0 4 0;
-#X connect 3 0 6 0;
-#X connect 3 1 5 0;
-#X connect 3 1 7 0;
-#X connect 4 0 1 0;
-#X connect 5 0 1 0;
-#X connect 6 0 0 0;
-#X connect 7 0 0 0;
-#X connect 8 0 0 0;
+#X connect 2 0 11 0;
+#X connect 2 1 4 0;
+#X connect 2 1 8 0;
+#X connect 3 0 0 0;
+#X connect 4 0 0 0;
+#X connect 7 0 6 0;
+#X connect 8 0 6 0;
+#X connect 9 0 6 0;
+#X connect 10 0 6 0;
+#X connect 11 0 7 0;
+#X connect 11 1 9 0;
+#X connect 11 2 10 0;
#X restore 35 178 pd gemwin;
-#X msg 35 154 create;
+#X msg 36 156 destroy;
#X text 36 136 Create window and render;
-#X obj 213 404 pix_texture;
-#X obj 213 432 square 2;
-#X obj 325 71 translateXYZ -2 0 0;
-#X obj 326 100 separator;
#X obj 340 181 cnv 15 600 350 empty empty empty 20 12 0 14 -24198 -66577
0;
#X obj 511 -66 bng 25 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
@@ -52,9 +62,8 @@
#X msg 511 -17 open \$1;
#X obj 499 92 pix_film;
#X msg 517 26 auto \$1;
-#X obj 517 8 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+#X obj 517 8 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
;
-#X obj 326 126 translateXYZ 4 0 0;
#X obj 580 26 loadbang;
#X msg 528 50 colorspace RGBA;
#X obj 771 5 gemmouse;
@@ -103,54 +112,52 @@ specific color;
#X text 643 453 detected components;
#X msg 437 307 connectivity 4;
#X msg 439 330 connectivity 8;
-#X connect 0 0 21 0;
-#X connect 1 0 2 0;
-#X connect 4 0 5 0;
-#X connect 5 0 4 0;
-#X connect 7 0 8 0;
-#X connect 9 0 7 0;
-#X connect 9 0 10 0;
-#X connect 10 0 24 0;
-#X connect 12 0 19 0;
-#X connect 13 0 14 0;
-#X connect 13 1 15 0;
-#X connect 13 2 16 0;
-#X connect 17 0 18 0;
-#X connect 18 0 21 1;
+#X obj 211 525 pix_resize 320 240;
+#X obj 212 555 rectangle 4 3;
+#X connect 0 0 16 0;
+#X connect 1 0 64 0;
+#X connect 3 0 4 0;
+#X connect 4 0 3 0;
+#X connect 7 0 14 0;
+#X connect 8 0 9 0;
+#X connect 8 1 10 0;
+#X connect 8 2 11 0;
+#X connect 12 0 13 0;
+#X connect 13 0 16 1;
+#X connect 14 0 15 0;
+#X connect 15 0 16 0;
+#X connect 16 0 28 0;
+#X connect 16 1 8 0;
+#X connect 16 2 12 0;
+#X connect 17 0 16 0;
+#X connect 18 0 17 0;
#X connect 19 0 20 0;
-#X connect 20 0 21 0;
-#X connect 21 0 9 0;
-#X connect 21 1 13 0;
-#X connect 21 2 17 0;
-#X connect 22 0 21 0;
-#X connect 23 0 22 0;
-#X connect 24 0 34 0;
-#X connect 25 0 26 0;
-#X connect 26 0 21 0;
-#X connect 27 0 29 1;
-#X connect 27 1 28 1;
-#X connect 27 2 32 0;
-#X connect 28 0 31 1;
-#X connect 29 0 31 0;
-#X connect 30 0 29 0;
-#X connect 30 1 28 0;
-#X connect 31 0 41 0;
-#X connect 32 0 33 0;
-#X connect 33 0 30 0;
-#X connect 34 0 1 0;
-#X connect 34 1 57 0;
-#X connect 39 0 34 1;
-#X connect 40 0 34 2;
-#X connect 41 0 34 0;
-#X connect 42 0 34 0;
-#X connect 43 0 42 0;
-#X connect 45 0 34 0;
-#X connect 50 0 34 0;
-#X connect 51 0 34 0;
-#X connect 57 0 62 0;
-#X connect 62 0 58 0;
-#X connect 62 1 59 0;
-#X connect 62 2 60 0;
-#X connect 62 3 61 0;
-#X connect 68 0 34 0;
-#X connect 69 0 34 0;
+#X connect 20 0 16 0;
+#X connect 21 0 23 1;
+#X connect 21 1 22 1;
+#X connect 21 2 26 0;
+#X connect 22 0 25 1;
+#X connect 23 0 25 0;
+#X connect 24 0 23 0;
+#X connect 24 1 22 0;
+#X connect 25 0 35 0;
+#X connect 26 0 27 0;
+#X connect 27 0 24 0;
+#X connect 28 0 1 0;
+#X connect 28 1 51 0;
+#X connect 33 0 28 1;
+#X connect 34 0 28 2;
+#X connect 35 0 28 0;
+#X connect 36 0 28 0;
+#X connect 37 0 36 0;
+#X connect 39 0 28 0;
+#X connect 44 0 28 0;
+#X connect 45 0 28 0;
+#X connect 51 0 56 0;
+#X connect 56 0 52 0;
+#X connect 56 1 53 0;
+#X connect 56 2 54 0;
+#X connect 56 3 55 0;
+#X connect 62 0 28 0;
+#X connect 63 0 28 0;
+#X connect 64 0 65 0;
diff --git a/pix_opencv_floodfill.cc b/pix_opencv_floodfill.cc
index 3b492c2..1c8cdd3 100755
--- a/pix_opencv_floodfill.cc
+++ b/pix_opencv_floodfill.cc
@@ -90,17 +90,18 @@ void pix_opencv_floodfill :: processRGBAImage(imageStruct &image)
this->comp_xsize=image.xsize;
this->comp_ysize=image.ysize;
+ cvReleaseImage( &rgba );
+ cvReleaseImage( &rgb );
+ cvReleaseImage( &grey );
+
rgba = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 4 );
rgb = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 3 );
grey = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 1 );
}
memcpy( rgba->imageData, image.data, image.xsize*image.ysize*4 );
-
- if ( !x_color )
- {
- cvCvtColor(rgba, grey, CV_BGRA2GRAY);
- }
+ cvCvtColor(rgba, grey, CV_BGRA2GRAY);
+ cvCvtColor(rgba, rgb, CV_BGRA2BGR);
// mark recognized components
for ( i=0; i<MAX_COMPONENTS; i++ )
@@ -111,7 +112,7 @@ void pix_opencv_floodfill :: processRGBAImage(imageStruct &image)
{
CvPoint seed = cvPoint(x_xcomp[i],x_ycomp[i]);
CvScalar color = CV_RGB( x_r[i], x_g[i], x_b[i] );
- cvFloodFill( rgba, seed, color, CV_RGB( x_lo, x_lo, x_lo ),
+ cvFloodFill( rgb, seed, color, CV_RGB( x_lo, x_lo, x_lo ),
CV_RGB( x_up, x_up, x_up ), &comp, flags, NULL );
}
else
@@ -134,6 +135,10 @@ void pix_opencv_floodfill :: processRGBAImage(imageStruct &image)
{
cvCvtColor(grey, rgba, CV_GRAY2BGRA);
}
+ else
+ {
+ cvCvtColor(rgb, rgba, CV_BGR2BGRA);
+ }
memcpy( image.data, rgba->imageData, image.xsize*image.ysize*4 );
}
@@ -152,6 +157,10 @@ void pix_opencv_floodfill :: processRGBImage(imageStruct &image)
this->comp_xsize=image.xsize;
this->comp_ysize=image.ysize;
+ cvReleaseImage( &rgba );
+ cvReleaseImage( &rgb );
+ cvReleaseImage( &grey );
+
rgba = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 4 );
rgb = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 3 );
grey = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 1 );
@@ -219,6 +228,10 @@ void pix_opencv_floodfill :: processGrayImage(imageStruct &image)
this->comp_xsize=image.xsize;
this->comp_ysize=image.ysize;
+ cvReleaseImage( &rgba );
+ cvReleaseImage( &rgb );
+ cvReleaseImage( &grey );
+
rgba = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 4 );
rgb = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 3 );
grey = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 1 );
@@ -287,9 +300,9 @@ void pix_opencv_floodfill :: connectivityMessCallback(void *data, t_floatarg co
GetMyClass(data)->connectivityMess(connectivity);
}
-void pix_opencv_floodfill :: markMessCallback(void *data, t_floatarg perx, t_floatarg pery)
+void pix_opencv_floodfill :: markMessCallback(void *data, t_floatarg px, t_floatarg py)
{
- GetMyClass(data)->markMess(perx, pery);
+ GetMyClass(data)->markMess(px, py);
}
void pix_opencv_floodfill :: deleteMessCallback(void *data, t_floatarg index)
@@ -354,19 +367,19 @@ void pix_opencv_floodfill :: connectivityMess(float connectivity)
x_connectivity = (int)connectivity;
}
-void pix_opencv_floodfill :: markMess(float fperx, float fpery)
+void pix_opencv_floodfill :: markMess(float fpx, float fpy)
{
int i;
int inserted;
int px, py;
- if ( ( fperx < 0.0 ) || ( fperx > 1.0 ) || ( fpery < 0.0 ) || ( fpery > 1.0 ) )
+ if ( ( fpx < 0.0 ) || ( fpx > comp_xsize ) || ( fpy < 0.0 ) || ( fpy > comp_ysize ) )
{
return;
}
- px = (int)(fperx*comp_xsize);
- py = (int)(fpery*comp_ysize);
+ px = (int)fpx;
+ py = comp_ysize-(int)fpy;
inserted = 0;
for ( i=0; i<MAX_COMPONENTS; i++)
{
@@ -374,6 +387,7 @@ void pix_opencv_floodfill :: markMess(float fperx, float fpery)
{
x_xcomp[i] = px;
x_ycomp[i] = py;
+ // post( "pix_opencv_floodfill : inserted point (%d,%d)", px, py );
inserted = 1;
break;
}
diff --git a/pix_opencv_lk-help.pd b/pix_opencv_lk-help.pd
index f77ff9b..d4cb0e4 100755
--- a/pix_opencv_lk-help.pd
+++ b/pix_opencv_lk-help.pd
@@ -1,42 +1,52 @@
-#N canvas 3 105 1192 685 10;
+#N canvas 248 90 1192 685 10;
#X obj 396 -37 gemhead;
-#X obj 212 501 pix_texture;
-#X obj 212 529 square 2;
+#X obj 218 457 pix_texture;
#X obj 28 132 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577
0;
-#N canvas 0 22 454 304 gemwin 0;
-#X obj 132 136 gemwin;
+#N canvas 189 149 454 304 gemwin 0;
+#X obj 130 218 gemwin;
#X obj 67 89 outlet;
#X obj 67 10 inlet;
#X obj 67 41 route create;
#X msg 67 70 set destroy;
#X msg 182 68 set create;
-#X msg 132 112 create \, 1;
-#X msg 238 112 destroy;
-#N canvas 87 154 247 179 Gem.init 0;
-#X obj 118 46 loadbang;
-#X msg 118 81 reset;
-#X obj 118 113 outlet;
-#X connect 0 0 1 0;
+#X msg 129 165 create \, 1;
+#X msg 205 166 destroy;
+#N canvas 87 154 363 340 Gem.init 0;
+#X obj 112 15 loadbang;
+#X msg 62 93 reset;
+#X obj 49 135 outlet;
+#X msg 107 89 dimen 320 240;
+#X msg 202 89 frame 15;
+#X obj 107 51 t b b b;
+#X connect 0 0 5 0;
#X connect 1 0 2 0;
+#X connect 3 0 2 0;
+#X connect 4 0 2 0;
+#X connect 5 0 3 0;
+#X connect 5 1 4 0;
+#X connect 5 2 1 0;
#X restore 289 80 pd Gem.init;
+#X obj 128 109 t b b b;
+#X msg 156 138 dimen 320 240;
+#X msg 251 138 frame 15;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
-#X connect 3 0 6 0;
+#X connect 3 0 9 0;
#X connect 3 1 5 0;
#X connect 3 1 7 0;
#X connect 4 0 1 0;
#X connect 5 0 1 0;
#X connect 6 0 0 0;
#X connect 7 0 0 0;
-#X connect 8 0 0 0;
+#X connect 9 0 6 0;
+#X connect 9 1 10 0;
+#X connect 9 2 11 0;
+#X connect 10 0 0 0;
+#X connect 11 0 0 0;
#X restore 35 178 pd gemwin;
-#X msg 35 154 create;
+#X msg 35 157 create;
#X text 36 136 Create window and render;
-#X obj 213 404 pix_texture;
-#X obj 213 432 square 2;
-#X obj 325 71 translateXYZ -2 0 0;
-#X obj 326 100 separator;
#X obj 340 180 cnv 15 600 450 empty empty empty 20 12 0 14 -24198 -66577
0;
#X obj 511 -66 bng 25 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
@@ -54,7 +64,6 @@
#X msg 517 26 auto \$1;
#X obj 517 8 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
-#X obj 326 126 translateXYZ 4 0 0;
#X obj 580 26 loadbang;
#X msg 528 50 colorspace RGBA;
#X floatatom 488 520 5 0 0 0 - - -;
@@ -74,7 +83,7 @@
#X obj 576 233 / 1000;
#X msg 494 328 mark \$1 \$2;
#X msg 508 349 delete \$1;
-#X text 579 349 delete a marker;
+#X text 702 349 delete a marker;
#X msg 516 369 clear;
#X text 564 370 delete all markers;
#X msg 522 389 maxmove \$1;
@@ -95,7 +104,7 @@
#X obj 1008 230 f;
#X obj 978 229 f;
#X obj 1022 201 t b b;
-#X obj 978 257 pack f f;
+#X obj 975 274 pack f f;
#X text 573 329 mark x y : mark a point to track ( max points : 10
);
#X obj 998 151 route 1;
@@ -120,66 +129,71 @@
#X text 43 -1 Corner points detection based on Shi and Tomasi;
#X text 43 -13 pix_opencv_lk : Lukas-Kanade corner points tracking
;
-#X connect 0 0 21 0;
-#X connect 1 0 2 0;
-#X connect 4 0 5 0;
-#X connect 5 0 4 0;
-#X connect 7 0 8 0;
-#X connect 9 0 7 0;
-#X connect 9 0 10 0;
-#X connect 10 0 24 0;
-#X connect 12 0 19 0;
-#X connect 13 0 14 0;
-#X connect 13 1 15 0;
-#X connect 13 2 16 0;
-#X connect 17 0 18 0;
-#X connect 18 0 21 1;
+#X obj 576 350 hradio 15 1 0 8 empty empty empty 0 -8 0 10 -262144
+-1 -1 0;
+#X floatatom 969 251 5 0 0 0 - - -;
+#X floatatom 1022 254 5 0 0 0 - - -;
+#X obj 208 534 rectangle 4 3;
+#X obj 212 489 pix_resize 320 240;
+#X connect 0 0 16 0;
+#X connect 1 0 81 0;
+#X connect 3 0 4 0;
+#X connect 4 0 3 0;
+#X connect 7 0 14 0;
+#X connect 8 0 9 0;
+#X connect 8 1 10 0;
+#X connect 8 2 11 0;
+#X connect 12 0 13 0;
+#X connect 13 0 16 1;
+#X connect 14 0 15 0;
+#X connect 15 0 16 0;
+#X connect 16 0 53 0;
+#X connect 16 1 8 0;
+#X connect 16 2 12 0;
+#X connect 17 0 16 0;
+#X connect 18 0 17 0;
#X connect 19 0 20 0;
-#X connect 20 0 21 0;
-#X connect 21 0 9 0;
-#X connect 21 1 13 0;
-#X connect 21 2 17 0;
-#X connect 22 0 21 0;
-#X connect 23 0 22 0;
-#X connect 24 0 59 0;
-#X connect 25 0 26 0;
-#X connect 26 0 21 0;
-#X connect 27 0 59 1;
-#X connect 29 0 30 0;
-#X connect 30 0 59 0;
-#X connect 32 0 59 0;
-#X connect 33 0 32 0;
-#X connect 34 0 35 0;
-#X connect 35 0 59 0;
-#X connect 37 0 59 0;
-#X connect 39 0 40 0;
-#X connect 40 0 33 0;
-#X connect 41 0 59 0;
-#X connect 42 0 59 0;
-#X connect 44 0 59 0;
-#X connect 46 0 59 0;
-#X connect 48 0 46 0;
-#X connect 50 0 39 0;
-#X connect 51 0 50 0;
-#X connect 52 0 53 0;
-#X connect 52 1 54 0;
-#X connect 57 0 52 0;
-#X connect 59 0 1 0;
-#X connect 59 1 57 0;
-#X connect 60 0 62 1;
-#X connect 60 1 61 1;
-#X connect 60 2 66 0;
-#X connect 61 0 64 1;
-#X connect 62 0 64 0;
-#X connect 63 0 62 0;
-#X connect 63 1 61 0;
-#X connect 64 0 41 0;
-#X connect 66 0 67 0;
-#X connect 67 0 63 0;
-#X connect 68 0 59 0;
-#X connect 69 0 59 0;
-#X connect 73 0 59 0;
-#X connect 74 0 59 0;
-#X connect 76 0 59 0;
-#X connect 77 0 59 0;
-#X connect 78 0 77 0;
+#X connect 20 0 16 0;
+#X connect 21 0 53 1;
+#X connect 23 0 24 0;
+#X connect 24 0 53 0;
+#X connect 26 0 53 0;
+#X connect 27 0 26 0;
+#X connect 28 0 29 0;
+#X connect 29 0 53 0;
+#X connect 31 0 53 0;
+#X connect 33 0 34 0;
+#X connect 34 0 27 0;
+#X connect 35 0 53 0;
+#X connect 36 0 53 0;
+#X connect 38 0 53 0;
+#X connect 40 0 53 0;
+#X connect 42 0 40 0;
+#X connect 44 0 33 0;
+#X connect 45 0 44 0;
+#X connect 46 0 47 0;
+#X connect 46 1 48 0;
+#X connect 51 0 46 0;
+#X connect 53 0 1 0;
+#X connect 53 1 51 0;
+#X connect 54 0 56 1;
+#X connect 54 1 55 1;
+#X connect 54 2 60 0;
+#X connect 55 0 58 1;
+#X connect 55 0 79 0;
+#X connect 56 0 58 0;
+#X connect 56 0 78 0;
+#X connect 57 0 56 0;
+#X connect 57 1 55 0;
+#X connect 58 0 35 0;
+#X connect 60 0 61 0;
+#X connect 61 0 57 0;
+#X connect 62 0 53 0;
+#X connect 63 0 53 0;
+#X connect 67 0 53 0;
+#X connect 68 0 53 0;
+#X connect 70 0 53 0;
+#X connect 71 0 53 0;
+#X connect 72 0 71 0;
+#X connect 77 0 36 0;
+#X connect 81 0 80 0;
diff --git a/pix_opencv_lk.cc b/pix_opencv_lk.cc
index 65daa24..57edaf1 100755
--- a/pix_opencv_lk.cc
+++ b/pix_opencv_lk.cc
@@ -109,6 +109,13 @@ void pix_opencv_lk :: processRGBAImage(imageStruct &image)
this->comp_xsize=image.xsize;
this->comp_ysize=image.ysize;
+ cvReleaseImage( &rgba );
+ cvReleaseImage( &rgb );
+ cvReleaseImage( &grey );
+ cvReleaseImage( &prev_grey );
+ cvReleaseImage( &pyramid );
+ cvReleaseImage( &prev_pyramid );
+
rgba = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 4 );
rgb = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 3 );
grey = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 1 );
@@ -238,13 +245,14 @@ void pix_opencv_lk :: processRGBAImage(imageStruct &image)
// first marking
if ( x_xmark[im] != -1.0 )
{
- if ( ( abs( points[1][i].x - x_xmark[im] ) <= maxmove ) && ( abs( points[1][i].y - x_ymark[im] ) <= maxmove ) )
+ // post( "pix_opencv_lk : compare (%f,%f) to (%d,%d)", points[1][i].x, points[1][i].y, x_xmark[im], x_ymark[im] );
+ if ( ( abs( (int)points[1][i].x - x_xmark[im] ) <= maxmove ) && ( abs( (int)points[1][i].y - x_ymark[im] ) <= maxmove ) )
{
char tindex[4];
sprintf( tindex, "%d", im+1 );
cvPutText( rgba, tindex, cvPointFrom32f(points[1][i]), &font, CV_RGB(255,255,255));
- x_xmark[im]=points[1][i].x;
- x_ymark[im]=points[1][i].y;
+ x_xmark[im]=(int)points[1][i].x;
+ x_ymark[im]=(int)points[1][i].y;
x_found[im]=ftolerance;
marked=1;
SETFLOAT(&x_list[0], im+1);
@@ -359,6 +367,13 @@ void pix_opencv_lk :: processRGBImage(imageStruct &image)
this->comp_xsize=image.xsize;
this->comp_ysize=image.ysize;
+ cvReleaseImage( &rgba );
+ cvReleaseImage( &rgb );
+ cvReleaseImage( &grey );
+ cvReleaseImage( &prev_grey );
+ cvReleaseImage( &pyramid );
+ cvReleaseImage( &prev_pyramid );
+
rgba = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 4 );
rgb = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 3 );
grey = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 1 );
@@ -614,6 +629,13 @@ void pix_opencv_lk :: processGrayImage(imageStruct &image)
this->comp_xsize=image.xsize;
this->comp_ysize=image.ysize;
+ cvReleaseImage( &rgba );
+ cvReleaseImage( &rgb );
+ cvReleaseImage( &grey );
+ cvReleaseImage( &prev_grey );
+ cvReleaseImage( &pyramid );
+ cvReleaseImage( &prev_pyramid );
+
rgba = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 4 );
rgb = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 3 );
grey = cvCreateImage( cvSize(comp_xsize, comp_ysize), 8, 1 );
@@ -992,17 +1014,17 @@ void pix_opencv_lk :: markMess(int argc, t_atom *argv)
}
else
{
- float fperx = argv[0].a_w.w_float;
- float fpery = argv[1].a_w.w_float;
+ float fpx = argv[0].a_w.w_float;
+ float fpy = argv[1].a_w.w_float;
int px, py;
- if ( ( fperx < 0.0 ) || ( fperx > 1.0 ) || ( fpery < 0.0 ) || ( fpery > 1.0 ) )
+ if ( ( fpx < 0.0 ) || ( fpx > comp_xsize ) || ( fpy < 0.0 ) || ( fpy > comp_ysize ) )
{
return;
}
- px = (int)(fperx*comp_xsize);
- py = (int)(fpery*comp_ysize);
+ px = (int)fpx;
+ py = comp_ysize-(int)fpy;
inserted = 0;
for ( i=0; i<MAX_MARKERS; i++)
{
@@ -1012,6 +1034,7 @@ void pix_opencv_lk :: markMess(int argc, t_atom *argv)
x_ymark[i] = py;
x_found[i] = ftolerance;
inserted = 1;
+ // post( "pix_opencv_lk : inserted point (%d,%d)", px, py );
break;
}
}
diff --git a/pix_opencv_lk.h b/pix_opencv_lk.h
index c8be6a7..13b8ba3 100755
--- a/pix_opencv_lk.h
+++ b/pix_opencv_lk.h
@@ -22,7 +22,7 @@ LOG
#include "cv.h"
#endif
-#define MAX_MARKERS 10
+#define MAX_MARKERS 500
const int MAX_COUNT = 500;
/*-----------------------------------------------------------------