aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN.N. <sevyves@users.sourceforge.net>2009-06-01 15:35:34 +0000
committerN.N. <sevyves@users.sourceforge.net>2009-06-01 15:35:34 +0000
commit4ad8d54f22a6312e7ae3a90e9a13a9aa1bd91ed5 (patch)
treea4b654a44dac5c1db572f0ee0b7bd44f03145e59
parent5b087efb674f47c5b684977ab9661eb421e57b59 (diff)
fixed outputs in pdp_opencv_contours_boundingrect.c
svn path=/trunk/externals/pdp_opencv/; revision=11607
-rw-r--r--pdp_opencv_contours_boundingrect-help.pd36
-rw-r--r--pdp_opencv_contours_boundingrect.c48
2 files changed, 36 insertions, 48 deletions
diff --git a/pdp_opencv_contours_boundingrect-help.pd b/pdp_opencv_contours_boundingrect-help.pd
index e583f9c..86217dc 100644
--- a/pdp_opencv_contours_boundingrect-help.pd
+++ b/pdp_opencv_contours_boundingrect-help.pd
@@ -1,4 +1,4 @@
-#N canvas 363 68 1249 684 10;
+#N canvas 159 107 1249 684 10;
#X obj 41 -82 cnv 15 621 223 empty empty empty 20 12 0 14 -260097 -66577
0;
#X obj 91 75 pdp_1394L;
@@ -8,7 +8,7 @@
#X obj 73 -25 metro 40;
#X msg 191 41 norm PAL;
#X msg 161 4 close;
-#X obj 281 -44 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
+#X obj 281 -44 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 281 -17 metro 40;
#X msg 371 10 close;
@@ -34,8 +34,8 @@ only works in RGB colormodel;
#X floatatom 291 509 5 0 0 0 - - -;
#X obj 185 482 unpack 0 0 0 0 0;
#X obj 185 446 route 0 1 2 3 4;
-#X floatatom 312 345 5 0 0 0 - - -;
-#X floatatom 312 368 5 0 0 0 - - -;
+#X floatatom 244 347 5 0 0 0 - - -;
+#X floatatom 268 365 5 0 0 0 - - -;
#X obj 91 387 pdp_opencv_contours_boundingrect;
#X text 335 509 Xorigin Yorigin Width Height;
#X floatatom 205 565 5 0 0 0 - - -;
@@ -53,11 +53,6 @@ only works in RGB colormodel;
#X text 280 293 threshold (default 13) to use when comparing pixel
colors;
#X text 277 269 set the background reference;
-#X text 42 -273 It is useful as a motion tracker if you have well issolated
-silouets of the objects you want to track.;
-#X text 347 346 minimal area in pixels to be detected (default 1);
-#X text 346 370 maximal area in pixels to be detected (default 76800)
-;
#X msg 568 59 format \$1;
#X obj 569 37 hradio 15 1 0 4 empty empty empty 0 -8 0 10 -262144 -1
-1 0;
@@ -83,7 +78,12 @@ to transform the contours of the shapes to be analyzed..;
#X text 288 451 For each contour detected;
#X text 288 438 We have the contours sorted bottom to top and left
to right;
-#X obj 103 465 print;
+#X text 42 -273 It is useful as a motion tracker if you have well isolated
+silouets of the objects you want to track.;
+#X text 280 349 minimal area in pixels to be detected (default 10x10)
+;
+#X text 302 367 maximal area in pixels to be detected (default 320x240)
+;
#X connect 1 0 18 0;
#X connect 2 0 1 0;
#X connect 3 0 4 0;
@@ -107,12 +107,12 @@ to right;
#X connect 26 3 25 0;
#X connect 27 0 26 0;
#X connect 27 1 36 0;
-#X connect 27 2 59 0;
+#X connect 27 2 56 0;
#X connect 28 0 30 1;
#X connect 29 0 30 2;
#X connect 30 0 38 0;
#X connect 30 1 27 0;
-#X connect 30 1 63 0;
+#X connect 30 2 50 0;
#X connect 36 0 32 0;
#X connect 36 1 33 0;
#X connect 36 2 34 0;
@@ -120,9 +120,9 @@ to right;
#X connect 40 0 42 0;
#X connect 41 0 42 1;
#X connect 42 0 30 0;
-#X connect 48 0 16 0;
-#X connect 49 0 48 0;
-#X connect 59 0 55 0;
-#X connect 59 1 56 0;
-#X connect 59 2 57 0;
-#X connect 59 3 58 0;
+#X connect 45 0 16 0;
+#X connect 46 0 45 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;
diff --git a/pdp_opencv_contours_boundingrect.c b/pdp_opencv_contours_boundingrect.c
index 748507e..c01a82b 100644
--- a/pdp_opencv_contours_boundingrect.c
+++ b/pdp_opencv_contours_boundingrect.c
@@ -32,8 +32,6 @@
#include "cv.h"
#endif
-
-
typedef struct pdp_opencv_contours_boundingrect_struct
{
t_object x_obj;
@@ -42,6 +40,7 @@ typedef struct pdp_opencv_contours_boundingrect_struct
t_outlet *x_outlet0;
t_outlet *x_dataout;
t_outlet *x_countout;
+ t_atom rlist[5];
int x_packet0;
int x_packet1;
int x_dropped;
@@ -59,15 +58,12 @@ typedef struct pdp_opencv_contours_boundingrect_struct
} t_pdp_opencv_contours_boundingrect;
-
-
static void pdp_opencv_contours_boundingrect_process_rgb(t_pdp_opencv_contours_boundingrect *x)
{
t_pdp *header = pdp_packet_header(x->x_packet0);
short int *data = (short int *)pdp_packet_data(x->x_packet0);
t_pdp *newheader = pdp_packet_header(x->x_packet1);
short int *newdata = (short int *)pdp_packet_data(x->x_packet1);
-
if ((x->x_width != (t_int)header->info.image.width) ||
(x->x_height != (t_int)header->info.image.height))
@@ -120,7 +116,6 @@ static void pdp_opencv_contours_boundingrect_process_rgb(t_pdp_opencv_contours_b
//ContourBoundingRect
//
-
// TODO afegir parametres
// Retrieval mode.
// CV_RETR_TREE || CV_RETR_CCOMP || CV_RETR_LIST || CV_RETR_EXTERNAL
@@ -136,12 +131,11 @@ static void pdp_opencv_contours_boundingrect_process_rgb(t_pdp_opencv_contours_b
//TODO afegir parametre
//si volem veure la imatge original o un fons negre
cvCopy(x->image, x->cnt_img, NULL);
- //cvZero( x->cnt_img );
+ // cvZero( x->cnt_img );
-
- int i = 0; // Indicator of cycles.
+ int i = 0; // Indicator of cycles.
for( ; contours != 0; contours = contours->h_next )
- {
+ {
int count = contours->total; // This is number point in contour
CvRect rect;
@@ -149,23 +143,21 @@ static void pdp_opencv_contours_boundingrect_process_rgb(t_pdp_opencv_contours_b
if ( ( (rect.width*rect.height) > x->minarea ) && ( (rect.width*rect.height) < x->maxarea ) ) {
cvRectangle( x->cnt_img, cvPoint(rect.x,rect.y), cvPoint(rect.x+rect.width,rect.y+rect.height), CV_RGB(255,0,0), 2, 8 , 0 );
- t_atom rlist[4];
- SETFLOAT(&rlist[0], i);
- SETFLOAT(&rlist[1], rect.x);
- SETFLOAT(&rlist[2], rect.y);
- SETFLOAT(&rlist[3], rect.width);
- SETFLOAT(&rlist[4], rect.height);
+ SETFLOAT(&x->rlist[0], i);
+ SETFLOAT(&x->rlist[1], rect.x);
+ SETFLOAT(&x->rlist[2], rect.y);
+ SETFLOAT(&x->rlist[3], rect.width);
+ SETFLOAT(&x->rlist[4], rect.height);
- outlet_list( x->x_dataout, 0, 5, rlist );
+ outlet_list( x->x_dataout, 0, 5, x->rlist );
i++;
- }
- outlet_float( x->x_countout, i );
+ }
+ outlet_float( x->x_countout, i );
- }
+ }
cvReleaseMemStorage( &stor02 );
- //cvShowImage( "contours", x->cnt_img );
memcpy( newdata, x->cnt_img->imageData, x->x_size*3 );
@@ -250,12 +242,11 @@ static void pdp_opencv_contours_boundingrect_free(t_pdp_opencv_contours_bounding
pdp_queue_finish(x->x_queue_id);
pdp_packet_mark_unused(x->x_packet0);
- //cv_freeplugins(x);
- //Destroy cv_images
- cvReleaseImage(&x->image);
- cvReleaseImage(&x->gray);
- cvReleaseImage(&x->cnt_img);
+ //Destroy cv_images
+ cvReleaseImage(&x->image);
+ cvReleaseImage(&x->gray);
+ cvReleaseImage(&x->cnt_img);
}
t_class *pdp_opencv_contours_boundingrect_class;
@@ -283,11 +274,8 @@ void *pdp_opencv_contours_boundingrect_new(t_floatarg f)
x->x_infosok = 0;
- x->minarea = 1;
+ x->minarea = 10*10;
x->maxarea = 320*240;
-
-
-
x->image = cvCreateImage(cvSize(x->x_width,x->x_height), IPL_DEPTH_8U, 3);
x->gray = cvCreateImage(cvSize(x->image->width,x->image->height), IPL_DEPTH_8U, 1);