aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN.N. <sevyves@users.sourceforge.net>2009-08-24 17:30:12 +0000
committerN.N. <sevyves@users.sourceforge.net>2009-08-24 17:30:12 +0000
commit5f69e22234261b49bbf29a379db2da9d3322f067 (patch)
tree70710e1c2bfe92f8f4b2c4d9a231c88f447167f5
parentcf9dc8196ff70332e7c1c5a7524cd14ade133eeb (diff)
output coordinates, no marking yet
svn path=/trunk/externals/pdp_opencv/; revision=12056
-rw-r--r--pdp_opencv_hough_lines-help.pd77
-rw-r--r--pdp_opencv_hough_lines.cc30
2 files changed, 63 insertions, 44 deletions
diff --git a/pdp_opencv_hough_lines-help.pd b/pdp_opencv_hough_lines-help.pd
index 40ba799..2519207 100644
--- a/pdp_opencv_hough_lines-help.pd
+++ b/pdp_opencv_hough_lines-help.pd
@@ -1,4 +1,4 @@
-#N canvas 588 49 833 785 10;
+#N canvas 587 49 833 785 10;
#X text -13 -95 written by Lluis Gomez i Bigorda ( lluisgomez@hangar.org
) and Yves Degoyon ( ydegoyon@gmail.com );
#X obj -17 -55 cnv 15 621 250 empty empty empty 20 12 0 14 -260097
@@ -9,7 +9,7 @@
#X msg 313 39 close;
#X obj 243 110 pdp_v4l;
#X msg 300 7 open /dev/video0;
-#X obj 412 -20 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+#X obj 412 -20 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X obj 412 7 metro 40;
#X msg 493 26 close;
@@ -35,11 +35,11 @@
-1 -1 0 1;
#X obj -17 198 cnv 15 621 400 empty empty empty 20 12 0 14 -258113
-66577 0;
-#X obj 201 440 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+#X obj 214 470 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
-#X msg 116 438 nightmode \$1;
-#X text 220 441 set nightmode;
-#X floatatom 147 288 5 0 0 0 - - -;
+#X msg 129 468 nightmode \$1;
+#X text 233 471 set nightmode;
+#X floatatom 160 318 5 0 0 0 - - -;
#X floatatom 153 564 5 0 0 0 - - -;
#X floatatom 189 565 5 0 0 0 - - -;
#X obj 153 524 route 1 2 3 4 5 6 7 8 9 10;
@@ -52,36 +52,37 @@
#X floatatom 262 566 5 0 0 0 - - -;
#X text 229 579 X2;
#X text 265 579 Y2;
-#X msg 43 260 mode \$1;
-#X text 42 240 Detection mode;
-#X obj 139 231 vradio 15 1 0 3 empty empty empty 0 -8 0 10 -262144
--1 -1 0;
-#X text 160 231 CV_HOUGH_STANDARD;
-#X text 160 245 CV_HOUGH_PROBABILISTIC;
-#X text 161 261 CV_HOUGN_MULTI_SCALE;
-#X msg 58 285 threshold \$1;
-#X msg 72 315 minlength \$1;
-#X floatatom 158 316 5 0 0 0 - - -;
-#X floatatom 138 342 5 0 0 0 - - -;
-#X msg 87 341 gap \$1;
-#X text 181 342 gap betwwen lines ( default 10 \, for mode CV_HOUGH_PROBABILISTIC
+#X msg 59 282 mode \$1;
+#X obj 155 253 vradio 15 1 0 3 empty empty empty 0 -8 0 10 -262144
+-1 -1 1;
+#X text 176 253 CV_HOUGH_STANDARD;
+#X text 176 267 CV_HOUGH_PROBABILISTIC;
+#X text 177 283 CV_HOUGN_MULTI_SCALE;
+#X msg 71 315 threshold \$1;
+#X msg 85 345 minlength \$1;
+#X floatatom 171 346 5 0 0 0 - - -;
+#X floatatom 151 372 5 0 0 0 - - -;
+#X msg 100 371 gap \$1;
+#X text 194 372 gap betwwen lines ( default 10 \, for mode CV_HOUGH_PROBABILISTIC
);
-#X text 195 313 minimum length ( default 30 \, for mode CV_HOUGH_PROBABILISTIC
+#X text 208 343 minimum length ( default 30 \, for mode CV_HOUGH_PROBABILISTIC
);
-#X floatatom 192 380 5 0 0 0 - - -;
-#X floatatom 214 412 5 0 0 0 - - -;
-#X msg 91 378 aresolution \$1;
-#X msg 109 410 dresolutyion \$1;
-#X text 258 408 distance resolution ( default 1 \, for mode CV_HOUGH_MULTI_SCALE
+#X floatatom 205 410 5 0 0 0 - - -;
+#X floatatom 227 442 5 0 0 0 - - -;
+#X msg 104 408 aresolution \$1;
+#X msg 122 440 dresolutyion \$1;
+#X text 271 438 distance resolution ( default 1 \, for mode CV_HOUGH_MULTI_SCALE
);
-#X text 230 377 angle resolution ( default 1 \, for mode CV_HOUGH_MULTI_SCALE
+#X text 243 407 angle resolution ( default 1 \, for mode CV_HOUGH_MULTI_SCALE
);
#X obj 13 621 pdp_xv;
#X msg 34 213 maxlines \$1;
#X floatatom 113 214 5 0 0 0 - - -;
#X text 154 210 maximum nuber of lines detected ( default : 10 );
#X text -14 -110 pdp_opencv_hough_lines : Hough lines algorithm;
-#X text 186 284 threshold ( default 200 );
+#X text 199 314 threshold ( default 50 );
+#X text 64 235 Detection mode ( default : CV_HOUGH_PROBABILISTIC )
+;
#X connect 2 0 3 0;
#X connect 3 0 5 0;
#X connect 4 0 5 0;
@@ -108,24 +109,24 @@
#X connect 26 0 14 1;
#X connect 28 0 29 0;
#X connect 29 0 35 0;
-#X connect 31 0 50 0;
+#X connect 31 0 49 0;
#X connect 34 0 37 0;
-#X connect 35 0 63 0;
+#X connect 35 0 62 0;
#X connect 35 1 34 0;
#X connect 37 0 32 0;
#X connect 37 1 33 0;
#X connect 37 2 40 0;
#X connect 37 3 41 0;
#X connect 44 0 35 0;
-#X connect 46 0 44 0;
+#X connect 45 0 44 0;
+#X connect 49 0 35 0;
#X connect 50 0 35 0;
-#X connect 51 0 35 0;
-#X connect 52 0 51 0;
-#X connect 53 0 54 0;
-#X connect 54 0 35 0;
+#X connect 51 0 50 0;
+#X connect 52 0 53 0;
+#X connect 53 0 35 0;
+#X connect 56 0 58 0;
#X connect 57 0 59 0;
-#X connect 58 0 60 0;
+#X connect 58 0 35 0;
#X connect 59 0 35 0;
-#X connect 60 0 35 0;
-#X connect 64 0 35 0;
-#X connect 65 0 64 0;
+#X connect 63 0 35 0;
+#X connect 64 0 63 0;
diff --git a/pdp_opencv_hough_lines.cc b/pdp_opencv_hough_lines.cc
index 535e1ca..224531e 100644
--- a/pdp_opencv_hough_lines.cc
+++ b/pdp_opencv_hough_lines.cc
@@ -42,7 +42,7 @@ typedef struct pdp_opencv_hough_lines_struct
t_outlet *x_outlet0;
t_outlet *x_outlet1;
- t_atom x_list[3];
+ t_atom x_list[5];
int x_packet0;
int x_packet1;
@@ -139,9 +139,15 @@ static void pdp_opencv_hough_lines_process_rgb(t_pdp_opencv_hough_lines *x)
pt2.x = cvRound(x0 - 1000*(-b));
pt2.y = cvRound(y0 - 1000*(a));
cvLine( x->image, pt1, pt2, CV_RGB(255,0,0), 3, 8 );
- sprintf( tindex, "%d", i );
+ SETFLOAT(&x->x_list[0], i);
+ SETFLOAT(&x->x_list[1], pt1.x);
+ SETFLOAT(&x->x_list[2], pt1.y);
+ SETFLOAT(&x->x_list[3], pt2.x);
+ SETFLOAT(&x->x_list[4], pt2.y);
+ outlet_list( x->x_outlet1, 0, 5, x->x_list );
pt1.x = (pt1.x+pt2.x)/2;
pt1.y = (pt1.y+pt2.y)/2;
+ sprintf( tindex, "%d", i );
cvPutText( x->image, tindex, pt1, &x->font, CV_RGB(255,255,255));
}
}
@@ -160,9 +166,15 @@ static void pdp_opencv_hough_lines_process_rgb(t_pdp_opencv_hough_lines *x)
CvPoint* line = (CvPoint*)cvGetSeqElem(x->x_lines,i);
char tindex[10];
cvLine( x->image, line[0], line[1], CV_RGB(255,0,0), 3, 8 );
- sprintf( tindex, "%d", i );
+ SETFLOAT(&x->x_list[0], i);
+ SETFLOAT(&x->x_list[1], line[0].x);
+ SETFLOAT(&x->x_list[2], line[0].y);
+ SETFLOAT(&x->x_list[3], line[1].x);
+ SETFLOAT(&x->x_list[4], line[1].y);
+ outlet_list( x->x_outlet1, 0, 5, x->x_list );
line[0].x = (line[0].x+line[1].x)/2;
line[0].y = (line[0].y+line[1].y)/2;
+ sprintf( tindex, "%d", i );
cvPutText( x->image, tindex, line[0], &x->font, CV_RGB(255,255,255));
}
}
@@ -190,9 +202,15 @@ static void pdp_opencv_hough_lines_process_rgb(t_pdp_opencv_hough_lines *x)
pt2.x = cvRound(x0 - 1000*(-b));
pt2.y = cvRound(y0 - 1000*(a));
cvLine( x->image, pt1, pt2, CV_RGB(255,0,0), 3, 8 );
- sprintf( tindex, "%d", i );
+ SETFLOAT(&x->x_list[0], i);
+ SETFLOAT(&x->x_list[1], pt1.x);
+ SETFLOAT(&x->x_list[2], pt1.y);
+ SETFLOAT(&x->x_list[3], pt2.x);
+ SETFLOAT(&x->x_list[4], pt2.y);
+ outlet_list( x->x_outlet1, 0, 5, x->x_list );
pt1.x = (pt1.x+pt2.x)/2;
pt1.y = (pt1.y+pt2.y)/2;
+ sprintf( tindex, "%d", i );
cvPutText( x->image, tindex, pt1, &x->font, CV_RGB(255,255,255));
}
}
@@ -345,8 +363,8 @@ void *pdp_opencv_hough_lines_new(t_floatarg f)
x->x_height = 240;
x->x_size = x->x_width * x->x_height;
- x->x_mode = CV_HOUGH_STANDARD;
- x->x_threshold = 200;
+ x->x_mode = CV_HOUGH_PROBABILISTIC;
+ x->x_threshold = 50;
x->x_maxlines = 10;
x->x_minlength = 30.0;
x->x_gap = 10.0;