diff options
-rwxr-xr-x | Makefile.in | 2 | ||||
-rw-r--r-- | pix_opencv_contours_convexity-help.pd | 164 | ||||
-rw-r--r-- | pix_opencv_distrans-help.pd | 91 | ||||
-rw-r--r-- | pix_opencv_edge-help.pd | 21 | ||||
-rw-r--r-- | pix_opencv_haarcascade-help.pd | 16 | ||||
-rw-r--r-- | pix_opencv_laplace-help.pd | 63 | ||||
-rw-r--r-- | pix_opencv_morphology-help.pd | 103 | ||||
-rw-r--r-- | pix_opencv_motempl-help.pd | 187 | ||||
-rw-r--r-- | pix_opencv_motempl.cc | 38 | ||||
-rw-r--r-- | pix_opencv_motempl.h | 137 |
10 files changed, 436 insertions, 386 deletions
diff --git a/Makefile.in b/Makefile.in index 50b6bc3..c85b59e 100755 --- a/Makefile.in +++ b/Makefile.in @@ -16,7 +16,7 @@ all: pix_preview.pd_linux pix_preview.pd_linux: pix_preview.o rm -f pix_preview.pd_linux - gcc -Wl,--export-dynamic -shared -o pix_preview.pd_linux pix_preview.o $(LIBS) + gcc -export_dynamic -shared -o pix_preview.pd_linux pix_preview.o $(LIBS) clean: rm -f *.o diff --git a/pix_opencv_contours_convexity-help.pd b/pix_opencv_contours_convexity-help.pd index 52cc7cc..5552b48 100644 --- a/pix_opencv_contours_convexity-help.pd +++ b/pix_opencv_contours_convexity-help.pd @@ -1,8 +1,8 @@ -#N canvas 0 25 1257 669 10; -#X obj 286 -33 gemhead; -#X obj 364 374 pix_texture; -#X obj 364 402 square 2; -#X obj 20 159 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577 +#N canvas 1 49 1424 780 10; +#X obj 264 18 gemhead; +#X obj 195 378 pix_texture; +#X obj 195 406 square 2; +#X obj 558 -22 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; @@ -30,82 +30,92 @@ #X connect 6 0 0 0; #X connect 7 0 0 0; #X connect 8 0 0 0; -#X restore 25 203 pd gemwin; -#X msg 25 179 destroy; -#X text 21 159 Create window and render; -#X obj 200 368 pix_texture; -#X obj 200 396 square 2; -#X obj 266 167 translateXYZ -2 0 0; -#X obj 367 224 separator; -#X obj 346 281 cnv 15 255 67 empty empty empty 20 12 0 14 -24198 -66577 +#X restore 563 22 pd gemwin; +#X msg 563 -2 destroy; +#X text 559 -22 Create window and render; +#X obj 31 372 pix_texture; +#X obj 31 400 square 2; +#X obj 97 171 translateXYZ -2 0 0; +#X obj 198 228 separator; +#X obj 177 285 cnv 15 255 67 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 +#X obj 342 -62 bng 25 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; -#X obj 524 128 unpack 0 0 0; -#X floatatom 514 151 5 0 0 3 length - -; -#X floatatom 563 151 5 0 0 3 width - -; -#X floatatom 613 151 5 0 0 3 height - -; -#X obj 568 109 bng 15 250 50 0 empty empty end_reached 20 7 0 10 -262144 +#X obj 355 132 unpack 0 0 0; +#X floatatom 345 155 5 0 0 3 length - -; +#X floatatom 394 155 5 0 0 3 width - -; +#X floatatom 444 155 5 0 0 3 height - -; +#X obj 399 113 bng 15 250 50 0 empty empty end_reached 20 7 0 10 -262144 -1 -1; -#X floatatom 550 74 5 0 10000 1 frame# - -; -#X obj 511 -37 openpanel; -#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 floatatom 381 78 5 0 10000 1 frame# - -; +#X obj 342 -33 openpanel; +#X msg 342 -13 open \$1; +#X obj 330 96 pix_film; +#X msg 348 30 auto \$1; +#X obj 348 12 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; -#X obj 364 259 translateXYZ 4 0 0; -#X obj 378 110 pix_invert; -#X obj 319 135 pix_threshold; -#X floatatom 425 142 5 0 0 0 - - -; -#X msg 441 191 0.33; -#X obj 479 192 loadbang; -#X msg 528 50 colorspace RGBA; -#X obj 364 324 pix_opencv_contours_convexity; -#X floatatom 100 631 5 0 0 0 - - -; -#X floatatom 135 631 5 0 0 0 - - -; -#X floatatom 165 612 5 0 0 0 - - -; -#X floatatom 199 612 5 0 0 0 - - -; -#X obj 569 449 route 0 1 2 3 4; -#X obj 134 567 unpack 0 0 0 0 0 0; -#X floatatom 229 593 5 0 0 0 - - -; -#X floatatom 263 593 5 0 0 0 - - -; -#X text 679 450 For each convexity defect in our contour; -#X text 173 632 Start point (X -Y); -#X text 237 612 Depth point (X -Y); -#X text 302 594 End point (X -Y); -#X floatatom 408 631 5 0 0 0 - - -; -#X floatatom 443 631 5 0 0 0 - - -; -#X floatatom 473 612 5 0 0 0 - - -; -#X floatatom 507 612 5 0 0 0 - - -; -#X obj 442 567 unpack 0 0 0 0 0 0; -#X floatatom 537 593 5 0 0 0 - - -; -#X floatatom 571 593 5 0 0 0 - - -; -#X text 481 632 Start point (X -Y); -#X text 545 612 Depth point (X -Y); -#X text 610 594 End point (X -Y); -#X floatatom 726 638 5 0 0 0 - - -; -#X floatatom 761 638 5 0 0 0 - - -; -#X floatatom 791 619 5 0 0 0 - - -; -#X floatatom 825 619 5 0 0 0 - - -; -#X obj 760 574 unpack 0 0 0 0 0 0; -#X floatatom 855 600 5 0 0 0 - - -; -#X floatatom 889 600 5 0 0 0 - - -; -#X text 799 639 Start point (X -Y); -#X text 863 619 Depth point (X -Y); -#X text 928 601 End point (X -Y); -#X floatatom 1034 638 5 0 0 0 - - -; -#X floatatom 1069 638 5 0 0 0 - - -; -#X floatatom 1099 619 5 0 0 0 - - -; -#X floatatom 1133 619 5 0 0 0 - - -; -#X obj 1068 574 unpack 0 0 0 0 0 0; -#X floatatom 1163 600 5 0 0 0 - - -; -#X floatatom 1197 600 5 0 0 0 - - -; -#X text 1107 639 Start point (X -Y); -#X text 1171 619 Depth point (X -Y); -#X text 1236 601 End point (X -Y); -#X floatatom 470 385 5 0 0 0 - - -; -#X text 466 400 number convexity defects; +#X obj 195 263 translateXYZ 4 0 0; +#X obj 209 114 pix_invert; +#X obj 150 139 pix_threshold; +#X floatatom 256 146 5 0 0 0 - - -; +#X msg 272 195 0.33; +#X obj 310 196 loadbang; +#X msg 359 54 colorspace RGBA; +#X obj 195 328 pix_opencv_contours_convexity; +#X floatatom 286 614 5 0 0 0 - - -; +#X floatatom 321 614 5 0 0 0 - - -; +#X floatatom 351 595 5 0 0 0 - - -; +#X floatatom 385 595 5 0 0 0 - - -; +#X obj 393 375 route 0 1 2 3 4; +#X obj 320 550 unpack 0 0 0 0 0 0; +#X floatatom 415 576 5 0 0 0 - - -; +#X floatatom 449 576 5 0 0 0 - - -; +#X text 495 378 For each convexity defect in our contour; +#X text 359 615 Start point (X -Y); +#X text 423 595 Depth point (X -Y); +#X text 488 577 End point (X -Y); +#X floatatom 298 517 5 0 0 0 - - -; +#X floatatom 333 517 5 0 0 0 - - -; +#X floatatom 363 498 5 0 0 0 - - -; +#X floatatom 397 498 5 0 0 0 - - -; +#X obj 332 453 unpack 0 0 0 0 0 0; +#X floatatom 427 479 5 0 0 0 - - -; +#X floatatom 461 479 5 0 0 0 - - -; +#X text 371 518 Start point (X -Y); +#X text 435 498 Depth point (X -Y); +#X text 500 480 End point (X -Y); +#X floatatom 616 524 5 0 0 0 - - -; +#X floatatom 651 524 5 0 0 0 - - -; +#X floatatom 681 505 5 0 0 0 - - -; +#X floatatom 715 505 5 0 0 0 - - -; +#X obj 650 460 unpack 0 0 0 0 0 0; +#X floatatom 745 486 5 0 0 0 - - -; +#X floatatom 779 486 5 0 0 0 - - -; +#X text 689 525 Start point (X -Y); +#X text 753 505 Depth point (X -Y); +#X text 818 487 End point (X -Y); +#X floatatom 601 621 5 0 0 0 - - -; +#X floatatom 636 621 5 0 0 0 - - -; +#X floatatom 666 602 5 0 0 0 - - -; +#X floatatom 700 602 5 0 0 0 - - -; +#X obj 635 557 unpack 0 0 0 0 0 0; +#X floatatom 730 583 5 0 0 0 - - -; +#X floatatom 764 583 5 0 0 0 - - -; +#X text 674 622 Start point (X -Y); +#X text 738 602 Depth point (X -Y); +#X text 803 584 End point (X -Y); +#X floatatom 301 389 5 0 0 0 - - -; +#X text 297 404 number convexity defects; +#X text 505 194 pix_opencv_contours_convexity :: Finds convexity defects +of the bigest contour of a binary image.; +#X text 504 230 This object considers a contour to be analyzed any +group of white pixels in a black background \, for this reason you +will find useful to use pix_threshold to obtain a correct input for +pix_opencv_contours_boundingrect.; +#X text 505 283 pix_opencv_contours_boundingrect works detecting the +bigest white area in the input image \, sometimes you will need to +use pix_opencv_morphology to transform the contours of the shape to +be analyzed..; #X connect 0 0 21 0; #X connect 1 0 2 0; #X connect 4 0 5 0; diff --git a/pix_opencv_distrans-help.pd b/pix_opencv_distrans-help.pd index b8b7b6f..a8e8dd7 100644 --- a/pix_opencv_distrans-help.pd +++ b/pix_opencv_distrans-help.pd @@ -1,7 +1,7 @@ -#N canvas 545 127 691 547 10; +#N canvas 1 49 1424 780 10; #X obj 286 -33 gemhead; -#X obj 364 374 pix_texture; -#X obj 364 402 square 2; +#X obj 363 431 pix_texture; +#X obj 363 459 square 2; #X obj 20 159 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577 0; #N canvas 0 22 454 304 gemwin 0; @@ -33,14 +33,12 @@ #X restore 25 203 pd gemwin; #X msg 25 179 destroy; #X text 21 159 Create window and render; -#X text 64 81 greys out all pixels (but pixel-values are still in RGBA) -; #X obj 200 368 pix_texture; #X obj 200 396 square 2; #X obj 266 167 translateXYZ -2 0 0; #X obj 367 224 separator; -#X floatatom 519 329 5 0 0 0 - - -; -#X obj 499 -71 cnv 15 155 250 empty empty empty 20 12 0 14 -24198 -66577 +#X floatatom 518 386 5 0 0 0 - - -; +#X obj 335 278 cnv 15 400 150 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 -1; @@ -55,49 +53,54 @@ #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 1 1 +#X obj 517 8 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X msg 528 50 colorspace Grey; -#X obj 364 259 translateXYZ 4 0 0; -#X obj 360 329 pix_opencv_distrans; -#X msg 569 217 voronoi \$1; -#X obj 660 217 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X obj 367 253 translateXYZ 4 0 0; +#X obj 359 386 pix_opencv_distrans; +#X msg 429 293 voronoi \$1; +#X obj 520 293 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; -#X text 679 217 switch Voronoi diagram mode on/off; -#X text 628 243 use 3x3 mask; -#X text 638 262 use 5x5 mask; -#X text 644 281 use precise distance transform; -#X text 560 327 edge threshold; -#X msg 591 281 mask 0; -#X msg 581 262 mask 5; -#X msg 571 242 mask 3; -#X connect 0 0 23 0; +#X text 539 293 switch Voronoi diagram mode on/off; +#X text 488 319 use 3x3 mask; +#X text 498 338 use 5x5 mask; +#X text 504 357 use precise distance transform; +#X text 559 384 edge threshold; +#X msg 451 357 mask 0; +#X msg 441 338 mask 5; +#X msg 431 318 mask 3; +#X text 22 55 it's a morphology filter that can be used to preprocess +video frames; +#X text 23 80 written by lluis gomez i bigorda ( lluisgomez@hangar.org +); +#X text 22 41 pix_opencv_distrans : distance processing; +#X connect 0 0 22 0; #X connect 1 0 2 0; #X connect 4 0 5 0; #X connect 5 0 4 0; -#X connect 8 0 9 0; -#X connect 10 0 8 0; -#X connect 10 0 11 0; -#X connect 11 0 27 0; -#X connect 12 0 28 1; -#X connect 14 0 21 0; -#X connect 15 0 16 0; -#X connect 15 1 17 0; -#X connect 15 2 18 0; -#X connect 19 0 20 0; -#X connect 20 0 23 1; +#X connect 7 0 8 0; +#X connect 9 0 7 0; +#X connect 9 0 10 0; +#X connect 10 0 26 0; +#X connect 11 0 27 1; +#X connect 13 0 20 0; +#X connect 14 0 15 0; +#X connect 14 1 16 0; +#X connect 14 2 17 0; +#X connect 18 0 19 0; +#X connect 19 0 22 1; +#X connect 20 0 21 0; #X connect 21 0 22 0; -#X connect 22 0 23 0; -#X connect 23 0 10 0; -#X connect 23 1 15 0; -#X connect 23 2 19 0; +#X connect 22 0 9 0; +#X connect 22 1 14 0; +#X connect 22 2 18 0; +#X connect 23 0 22 0; #X connect 24 0 23 0; -#X connect 25 0 24 0; -#X connect 26 0 23 0; -#X connect 27 0 28 0; -#X connect 28 0 1 0; +#X connect 25 0 22 0; +#X connect 26 0 27 0; +#X connect 27 0 1 0; +#X connect 28 0 27 0; #X connect 29 0 28 0; -#X connect 30 0 29 0; -#X connect 36 0 28 0; -#X connect 37 0 28 0; -#X connect 38 0 28 0; +#X connect 35 0 27 0; +#X connect 36 0 27 0; +#X connect 37 0 27 0; diff --git a/pix_opencv_edge-help.pd b/pix_opencv_edge-help.pd index ce9f355..dfbca66 100644 --- a/pix_opencv_edge-help.pd +++ b/pix_opencv_edge-help.pd @@ -1,8 +1,8 @@ -#N canvas 510 70 691 547 10; +#N canvas 139 94 805 652 10; #X obj 286 -33 gemhead; #X obj 364 374 pix_texture; #X obj 364 402 square 2; -#X obj 20 159 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577 +#X obj 23 230 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; @@ -30,14 +30,14 @@ #X connect 6 0 0 0; #X connect 7 0 0 0; #X connect 8 0 0 0; -#X restore 25 203 pd gemwin; -#X msg 25 179 destroy; -#X text 21 159 Create window and render; -#X obj 200 368 pix_texture; -#X obj 200 396 square 2; +#X restore 28 274 pd gemwin; +#X msg 28 250 destroy; +#X text 24 230 Create window and render; +#X obj 266 365 pix_texture; +#X obj 266 393 square 2; #X obj 266 167 translateXYZ -2 0 0; #X obj 367 224 separator; -#X obj 346 281 cnv 15 255 67 empty empty empty 20 12 0 14 -24198 -66577 +#X obj 347 281 cnv 15 300 67 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 -1; @@ -52,13 +52,16 @@ #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 1 1 +#X obj 517 8 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X msg 528 50 colorspace Grey; #X obj 364 259 translateXYZ 4 0 0; #X obj 364 297 pix_opencv_edge; #X floatatom 493 296 5 0 0 0 - - -; #X text 536 295 edge threshold; +#X text 18 86 written by lluis gomez i bigorda ( lluisgomez@hangar.org +); +#X text 19 70 pix_opencv_edge : edge detection filter; #X connect 0 0 21 0; #X connect 1 0 2 0; #X connect 4 0 5 0; diff --git a/pix_opencv_haarcascade-help.pd b/pix_opencv_haarcascade-help.pd index 1c46f66..3aa9b81 100644 --- a/pix_opencv_haarcascade-help.pd +++ b/pix_opencv_haarcascade-help.pd @@ -1,4 +1,4 @@ -#N canvas 197 73 1091 744 10; +#N canvas 386 81 1091 744 10; #X obj 266 -83 gemhead; #X obj 87 544 pix_texture; #X obj 87 577 square 2; @@ -33,8 +33,8 @@ #X restore 14 -30 pd gemwin; #X msg 14 -54 destroy; #X text 10 -74 Create window and render; -#X obj -86 241 pix_texture; -#X obj -86 269 square 2; +#X obj 5 544 pix_texture; +#X obj 5 572 square 2; #X obj 37 160 translateXYZ -2 0 0; #X obj 85 247 cnv 15 650 250 empty empty empty 20 12 0 14 -24198 -66577 0; @@ -92,8 +92,6 @@ the subsequent scans (default 1.1); #X text 197 503 number of objects detected; #X text 399 -22 used for face detection by default; #X text 396 -10 ( load haarscascase_frontalface_alt.xml ); -#X text 401 -47 pix_opencv_haarscasccade : object recognition based -on Haar's algorithm ( decision tree algorithm ); #X text 400 6 Written by Lluis Gomez i Bigorda ( lluisgomez@hangar.org ); #X text 399 18 and Yves Degoyon ( ydegoyon@gmail.com ); @@ -106,6 +104,8 @@ on Haar's algorithm ( decision tree algorithm ); #X text 265 432 clear markers history; #X text 217 282 Mode of operation. Currently the only flag that may be specified is CV_HAAR_DO_CANNY_PRUNING ( 0 ); +#X text 401 -47 pix_opencv_haarscasccade : object recognition based +on Haar's cascade algorithm; #X connect 0 0 16 0; #X connect 1 0 2 0; #X connect 4 0 5 0; @@ -151,6 +151,6 @@ be specified is CV_HAAR_DO_CANNY_PRUNING ( 0 ); #X connect 48 0 29 0; #X connect 50 0 29 0; #X connect 51 0 50 0; -#X connect 62 0 29 0; -#X connect 63 0 62 0; -#X connect 64 0 29 0; +#X connect 61 0 29 0; +#X connect 62 0 61 0; +#X connect 63 0 29 0; diff --git a/pix_opencv_laplace-help.pd b/pix_opencv_laplace-help.pd index 4d2a88a..ce65535 100644 --- a/pix_opencv_laplace-help.pd +++ b/pix_opencv_laplace-help.pd @@ -1,4 +1,4 @@ -#N canvas 456 80 691 547 10; +#N canvas 338 215 691 547 10; #X obj 286 -33 gemhead; #X obj 364 374 pix_texture; #X obj 364 402 square 2; @@ -33,14 +33,11 @@ #X restore 25 203 pd gemwin; #X msg 25 179 destroy; #X text 21 159 Create window and render; -#X text 64 81 greys out all pixels (but pixel-values are still in RGBA) -; #X obj 200 368 pix_texture; #X obj 200 396 square 2; #X obj 266 167 translateXYZ -2 0 0; #X obj 367 224 separator; -#X floatatom 493 296 5 0 0 0 - - -; -#X obj 499 -71 cnv 15 155 250 empty empty empty 20 12 0 14 -24198 -66577 +#X obj 337 281 cnv 15 200 70 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 -1; @@ -59,29 +56,41 @@ ; #X msg 528 50 colorspace Grey; #X obj 364 259 translateXYZ 4 0 0; -#X obj 364 297 pix_opencv_laplace; -#X connect 0 0 23 0; +#X obj 364 323 pix_opencv_laplace; +#X msg 409 298 1; +#X msg 443 298 3; +#X msg 476 298 5; +#X msg 508 298 7; +#X text 371 280 aperture size ( default 3 ); +#X text 26 56 Written by Lluis Gomez i Bigorda ( lluisgomez@hangar.org +); +#X text 26 45 used as an edge detector; +#X text 25 32 pix_opencv_laplace : laplace filter; +#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 8 0 9 0; -#X connect 10 0 8 0; -#X connect 10 0 11 0; -#X connect 11 0 27 0; -#X connect 12 0 28 1; -#X connect 14 0 21 0; -#X connect 15 0 16 0; -#X connect 15 1 17 0; -#X connect 15 2 18 0; +#X connect 7 0 8 0; +#X connect 9 0 7 0; +#X connect 9 0 10 0; +#X connect 10 0 25 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 connect 19 0 20 0; -#X connect 20 0 23 1; -#X connect 21 0 22 0; -#X connect 22 0 23 0; -#X connect 23 0 10 0; -#X connect 23 1 15 0; -#X connect 23 2 19 0; -#X connect 24 0 23 0; -#X connect 25 0 24 0; -#X connect 26 0 23 0; -#X connect 27 0 28 0; -#X connect 28 0 1 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 21 0; +#X connect 25 0 26 0; +#X connect 26 0 1 0; +#X connect 27 0 26 1; +#X connect 28 0 26 1; +#X connect 29 0 26 1; +#X connect 30 0 26 1; diff --git a/pix_opencv_morphology-help.pd b/pix_opencv_morphology-help.pd index dab346c..d2532e4 100644 --- a/pix_opencv_morphology-help.pd +++ b/pix_opencv_morphology-help.pd @@ -1,8 +1,8 @@ -#N canvas 512 117 691 547 10; +#N canvas 56 110 846 641 10; #X obj 286 -33 gemhead; -#X obj 364 374 pix_texture; -#X obj 364 402 square 2; -#X obj 20 159 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577 +#X obj 359 468 pix_texture; +#X obj 359 496 square 2; +#X obj 36 256 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; @@ -30,16 +30,14 @@ #X connect 6 0 0 0; #X connect 7 0 0 0; #X connect 8 0 0 0; -#X restore 25 203 pd gemwin; -#X msg 25 179 destroy; -#X text 21 159 Create window and render; -#X text 64 81 greys out all pixels (but pixel-values are still in RGBA) -; -#X obj 200 368 pix_texture; -#X obj 200 396 square 2; +#X restore 43 300 pd gemwin; +#X msg 43 276 destroy; +#X text 39 256 Create window and render; +#X obj 263 468 pix_texture; +#X obj 263 496 square 2; #X obj 266 167 translateXYZ -2 0 0; #X obj 367 224 separator; -#X obj 499 -71 cnv 15 155 250 empty empty empty 20 12 0 14 -24198 -66577 +#X obj 356 285 cnv 15 450 150 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 -1; @@ -54,50 +52,55 @@ #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 1 1 +#X obj 517 8 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X msg 528 50 colorspace Grey; #X obj 364 259 translateXYZ 4 0 0; -#X floatatom 584 336 5 0 0 0 - - -; -#X obj 650 228 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X floatatom 475 377 5 0 0 0 - - -; +#X obj 501 291 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; -#X msg 571 273 shape 2; -#X msg 561 253 shape 1; -#X msg 581 292 shape 3; -#X msg 559 228 mode \$1; -#X text 618 254 use rectangle structuring element; -#X text 636 289 use cross-shaped structuring element; -#X text 630 271 use elliptic structuring element; -#X text 669 228 switch open/close and erode/dilate modes; -#X text 623 337 number of iterations -10/+10 (be carefull); -#X obj 360 329 pix_opencv_morphology; -#X connect 0 0 22 0; +#X msg 459 335 shape 2; +#X msg 449 315 shape 1; +#X msg 469 354 shape 3; +#X msg 443 291 mode \$1; +#X text 506 316 use rectangle structuring element; +#X text 524 351 use cross-shaped structuring element; +#X text 518 333 use elliptic structuring element; +#X text 524 291 switch open/close and erode/dilate modes; +#X text 528 375 number of iterations -10/+10 (be carefull); +#X obj 361 405 pix_opencv_morphology; +#X text 467 493 written by Lluis Gomez i Bigorda ( lluisgomez@hangar.org +); +#X text 468 455 pdp_opencv_morphology : morphology filter ( erosion +/ dilatation ); +#X text 468 480 used as a filter to focus on bright or dark zones; +#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 8 0 9 0; -#X connect 10 0 8 0; -#X connect 10 0 11 0; -#X connect 11 0 26 0; -#X connect 13 0 20 0; -#X connect 14 0 15 0; -#X connect 14 1 16 0; -#X connect 14 2 17 0; -#X connect 18 0 19 0; -#X connect 19 0 22 1; +#X connect 7 0 8 0; +#X connect 9 0 7 0; +#X connect 9 0 10 0; +#X connect 10 0 25 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 connect 19 0 20 0; #X connect 20 0 21 0; -#X connect 21 0 22 0; -#X connect 22 0 10 0; -#X connect 22 1 14 0; -#X connect 22 2 18 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 23 0; -#X connect 25 0 22 0; -#X connect 26 0 38 0; -#X connect 27 0 38 1; -#X connect 28 0 32 0; -#X connect 29 0 38 0; -#X connect 30 0 38 0; -#X connect 31 0 38 0; -#X connect 32 0 38 0; -#X connect 38 0 1 0; +#X connect 24 0 21 0; +#X connect 25 0 37 0; +#X connect 26 0 37 1; +#X connect 27 0 31 0; +#X connect 28 0 37 0; +#X connect 29 0 37 0; +#X connect 30 0 37 0; +#X connect 31 0 37 0; +#X connect 37 0 1 0; diff --git a/pix_opencv_motempl-help.pd b/pix_opencv_motempl-help.pd index 9652bb5..cfd1bbf 100644 --- a/pix_opencv_motempl-help.pd +++ b/pix_opencv_motempl-help.pd @@ -1,8 +1,8 @@ -#N canvas 512 26 691 638 10; -#X obj 286 -33 gemhead; +#N canvas 1 49 1424 780 10; +#X obj 398 31 gemhead; #X obj 373 555 pix_texture; #X obj 373 583 square 2; -#X obj 20 159 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577 +#X obj 37 457 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; @@ -30,33 +30,31 @@ #X connect 6 0 0 0; #X connect 7 0 0 0; #X connect 8 0 0 0; -#X restore 25 203 pd gemwin; -#X msg 25 179 destroy; -#X text 21 159 Create window and render; -#X text 64 81 greys out all pixels (but pixel-values are still in RGBA) -; +#X restore 42 501 pd gemwin; +#X msg 42 477 destroy; +#X text 38 457 Create window and render; #X obj 200 368 pix_texture; #X obj 200 396 square 2; #X obj 266 167 translateXYZ -2 0 0; #X obj 364 205 separator; -#X obj 342 269 cnv 15 357 251 empty empty empty 20 12 0 14 -24198 -66577 +#X obj 342 269 cnv 15 550 251 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 +#X obj 474 -37 bng 25 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; -#X obj 524 128 unpack 0 0 0; -#X floatatom 514 151 5 0 0 3 length - -; -#X floatatom 563 151 5 0 0 3 width - -; -#X floatatom 613 151 5 0 0 3 height - -; -#X obj 568 109 bng 15 250 50 0 empty empty end_reached 20 7 0 10 -262144 +#X obj 487 157 unpack 0 0 0; +#X floatatom 477 180 5 0 0 3 length - -; +#X floatatom 526 180 5 0 0 3 width - -; +#X floatatom 576 180 5 0 0 3 height - -; +#X obj 531 138 bng 15 250 50 0 empty empty end_reached 20 7 0 10 -262144 -1 -1; -#X floatatom 550 74 5 0 10000 1 frame# - -; -#X obj 511 -37 openpanel; -#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 1 1 +#X floatatom 513 103 5 0 10000 1 frame# - -; +#X obj 474 -8 openpanel; +#X msg 474 12 open \$1; +#X obj 462 121 pix_film; +#X msg 480 55 auto \$1; +#X obj 480 37 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; -#X msg 528 50 colorspace Grey; +#X msg 491 79 colorspace Grey; #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 - - -; @@ -82,78 +80,89 @@ #X text 701 610 Xcenter Ycenter Width Height Angle; #X text 722 661 Xcenter Ycenter Width Height Angle; #X text 769 717 Xcenter Ycenter Width Height Angle; -#X floatatom 496 423 5 0 0 0 - - -; -#X floatatom 557 385 5 0 0 0 - - -; -#X text 536 425 Threshold value. (default 30); -#X text 599 384 Maximal duration of motion track in seconds. (default -1); -#X text 561 403 xxx; -#X msg 441 383 mhi_duration \$1; -#X floatatom 597 297 5 0 0 0 - - -; -#X msg 442 295 max_time_delta \$1; -#X floatatom 597 320 5 0 0 0 - - -; -#X msg 442 318 min_time_delta \$1; -#X floatatom 596 349 5 0 0 0 - - -; -#X msg 441 347 frame_buffer_num \$1; -#X floatatom 523 441 5 0 0 0 - - -; -#X floatatom 534 460 5 0 0 0 - - -; -#X text 574 462 Max size of the motion component (default 500); -#X text 564 441 Min size of the motion component (default 50); -#X text 638 348 Number of frames in the buffer. (default 4); -#X text 639 296 Max time delta in seconds. (default 0.5); -#X text 639 319 Min time delta in seconds. (default 0.05); +#X floatatom 487 393 5 0 0 0 - - -; +#X floatatom 520 367 5 0 0 0 - - -; +#X text 527 395 Threshold value. (default 30); +#X msg 415 366 mhi_duration \$1; +#X floatatom 508 296 5 0 0 0 - - -; +#X msg 393 295 max_time_delta \$1; +#X floatatom 517 320 5 0 0 0 - - -; +#X msg 400 317 min_time_delta \$1; +#X floatatom 541 344 5 0 0 0 - - -; +#X msg 410 341 frame_buffer_num \$1; +#X floatatom 514 411 5 0 0 0 - - -; +#X floatatom 525 430 5 0 0 0 - - -; +#X text 565 432 Max size of the motion component (default 500); +#X text 555 411 Min size of the motion component (default 50); +#X text 578 342 Number of frames in the buffer. (default 4); +#X text 547 294 Max time delta in seconds. (default 0.5); +#X text 558 319 Min time delta in seconds. (default 0.05); #X obj 371 466 pix_opencv_motempl; -#X connect 0 0 22 0; +#X msg 374 274 aperture \$1; +#X text 550 275 aperture ( 3 \, 5 or 7 \, default 3 ); +#X msg 454 274 3; +#X msg 487 274 5; +#X msg 518 274 7; +#X text 557 368 Maximal duration of motion track in seconds; +#X text 24 88 written by Lluis Gomez i Bigorda ( lluisgomez@hangar.org +); +#X text 26 64 pix_opencv_motempl : opencv motion detection based on +movement history; +#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 8 0 9 0; -#X connect 10 0 8 0; -#X connect 10 0 11 0; -#X connect 11 0 26 0; -#X connect 13 0 20 0; -#X connect 14 0 15 0; -#X connect 14 1 16 0; -#X connect 14 2 17 0; -#X connect 18 0 19 0; -#X connect 19 0 22 1; +#X connect 7 0 8 0; +#X connect 9 0 7 0; +#X connect 9 0 10 0; +#X connect 10 0 25 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 connect 19 0 20 0; #X connect 20 0 21 0; -#X connect 21 0 22 0; -#X connect 22 0 10 0; -#X connect 22 1 14 0; -#X connect 22 2 18 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 23 0; -#X connect 25 0 22 0; -#X connect 26 0 70 0; -#X connect 27 0 40 0; -#X connect 27 1 41 0; -#X connect 27 2 42 0; -#X connect 40 0 28 0; -#X connect 40 1 29 0; -#X connect 40 2 30 0; -#X connect 40 3 31 0; +#X connect 24 0 21 0; +#X connect 25 0 67 0; +#X connect 26 0 39 0; +#X connect 26 1 40 0; +#X connect 26 2 41 0; +#X connect 39 0 27 0; +#X connect 39 1 28 0; +#X connect 39 2 29 0; +#X connect 39 3 30 0; +#X connect 39 4 42 0; +#X connect 40 0 31 0; +#X connect 40 1 32 0; +#X connect 40 2 33 0; +#X connect 40 3 34 0; #X connect 40 4 43 0; -#X connect 41 0 32 0; -#X connect 41 1 33 0; -#X connect 41 2 34 0; -#X connect 41 3 35 0; +#X connect 41 0 35 0; +#X connect 41 1 36 0; +#X connect 41 2 37 0; +#X connect 41 3 38 0; #X connect 41 4 44 0; -#X connect 42 0 36 0; -#X connect 42 1 37 0; -#X connect 42 2 38 0; -#X connect 42 3 39 0; -#X connect 42 4 45 0; -#X connect 51 0 70 1; -#X connect 52 0 56 0; -#X connect 56 0 70 0; -#X connect 57 0 58 0; -#X connect 58 0 70 0; -#X connect 59 0 60 0; -#X connect 60 0 70 0; -#X connect 61 0 62 0; -#X connect 62 0 70 0; -#X connect 63 0 70 2; -#X connect 64 0 70 3; -#X connect 70 0 1 0; -#X connect 70 1 27 0; +#X connect 50 0 67 1; +#X connect 51 0 53 0; +#X connect 53 0 67 0; +#X connect 54 0 55 0; +#X connect 55 0 67 0; +#X connect 56 0 57 0; +#X connect 57 0 67 0; +#X connect 58 0 59 0; +#X connect 59 0 67 0; +#X connect 60 0 67 2; +#X connect 61 0 67 3; +#X connect 67 0 1 0; +#X connect 67 1 26 0; +#X connect 68 0 67 0; +#X connect 70 0 68 0; +#X connect 71 0 68 0; +#X connect 72 0 68 0; diff --git a/pix_opencv_motempl.cc b/pix_opencv_motempl.cc index 48f6be6..6e309a8 100644 --- a/pix_opencv_motempl.cc +++ b/pix_opencv_motempl.cc @@ -36,21 +36,21 @@ pix_opencv_motempl :: pix_opencv_motempl() inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"), gensym("max_size")); m_dataout = outlet_new(this->x_obj, 0); - mhi_duration = 1; + mhi_duration = 1.0; diff_threshold = 30; last = 0; comp_xsize = 0; comp_ysize = 0; - // various tracking parameters (in seconds) - max_time_delta = 0.5; - min_time_delta = 0.05; - // number of cyclic frame buffer used for motion detection - // (should, probably, depend on FPS) - frame_buffer_num = 4; + // various tracking parameters (in seconds) + max_time_delta = 0.5; + min_time_delta = 0.05; + // number of cyclic frame buffer used for motion detection + // (should, probably, depend on FPS) + frame_buffer_num = 4; - min_size=50; - max_size=500; + min_size=50; + max_size=500; img = NULL; motion = NULL; @@ -169,7 +169,7 @@ void pix_opencv_motempl :: processRGBAImage(imageStruct &image) cvCvtPlaneToPix( mask, 0, 0, 0, motion ); // calculate motion gradient orientation and valid orientation mask - cvCalcMotionGradient( mhi, mask, orient, max_time_delta, min_time_delta, 3 ); + cvCalcMotionGradient( mhi, mask, orient, max_time_delta, min_time_delta, aperture ); if( !storage ) storage = cvCreateMemStorage(0); @@ -324,7 +324,7 @@ void pix_opencv_motempl :: processRGBImage(imageStruct &image) cvCvtPlaneToPix( mask, 0, 0, 0, motion ); // calculate motion gradient orientation and valid orientation mask - cvCalcMotionGradient( mhi, mask, orient, max_time_delta, min_time_delta, 3 ); + cvCalcMotionGradient( mhi, mask, orient, max_time_delta, min_time_delta, aperture ); if( !storage ) storage = cvCreateMemStorage(0); @@ -482,7 +482,7 @@ void pix_opencv_motempl :: processGrayImage(imageStruct &image) cvCvtPlaneToPix( mask, 0, 0, 0, motion ); // calculate motion gradient orientation and valid orientation mask - cvCalcMotionGradient( mhi, mask, orient, max_time_delta, min_time_delta, 3 ); + cvCalcMotionGradient( mhi, mask, orient, max_time_delta, min_time_delta, aperture ); if( !storage ) storage = cvCreateMemStorage(0); @@ -571,6 +571,7 @@ void pix_opencv_motempl :: obj_setupCallback(t_class *classPtr) class_addmethod(classPtr, (t_method)&pix_opencv_motempl::frame_buffer_numMessCallback, gensym("frame_buffer_num"), A_FLOAT, A_NULL); class_addmethod(classPtr, (t_method)&pix_opencv_motempl::min_sizeMessCallback, gensym("min_size"), A_FLOAT, A_NULL); class_addmethod(classPtr, (t_method)&pix_opencv_motempl::max_sizeMessCallback, gensym("max_size"), A_FLOAT, A_NULL); + class_addmethod(classPtr, (t_method)&pix_opencv_motempl::apertureMessCallback, gensym("aperture"), A_FLOAT, A_NULL); } void pix_opencv_motempl :: thresholdMessCallback(void *data, t_floatarg pos) { @@ -600,13 +601,24 @@ void pix_opencv_motempl :: frame_buffer_numMessCallback(void *data, t_floatarg f { GetMyClass(data)->floatframe_buffer_num((float)frame_buffer_num); } +void pix_opencv_motempl :: apertureMessCallback(void *data, t_floatarg aperture) +{ + GetMyClass(data)->apertureMess((float)aperture); +} void pix_opencv_motempl :: floatThreshMess(float thresh) { if (thresh>=0) diff_threshold = (int)thresh; } void pix_opencv_motempl :: floatMhiDuration(float duration) { - if (duration>=1) mhi_duration = (int)duration; + if ( duration < 1.0 ) mhi_duration = duration; +} +void pix_opencv_motempl :: apertureMess(float aperture) +{ + if ( ( aperture == 3.0 ) || ( aperture == 5.0 ) || ( aperture == 7.0 ) ) + { + aperture = (int)aperture; + } } void pix_opencv_motempl :: floatmax_size(float max_size) { diff --git a/pix_opencv_motempl.h b/pix_opencv_motempl.h index c4783d8..e50d635 100644 --- a/pix_opencv_motempl.h +++ b/pix_opencv_motempl.h @@ -46,80 +46,81 @@ class GEM_EXTERN pix_opencv_motempl : public GemPixObj public: - ////////// - // Constructor - pix_opencv_motempl(); + ////////// + // Constructor + pix_opencv_motempl(); protected: - ////////// - // Destructor - virtual ~pix_opencv_motempl(); - - ////////// - // Do the processing - virtual void processRGBAImage(imageStruct &image); - virtual void processRGBImage(imageStruct &image); - virtual void processYUVImage(imageStruct &image); - virtual void processGrayImage(imageStruct &image); + ////////// + // Destructor + virtual ~pix_opencv_motempl(); + + ////////// + // Do the processing + virtual void processRGBAImage(imageStruct &image); + virtual void processRGBImage(imageStruct &image); + virtual void processYUVImage(imageStruct &image); + virtual void processGrayImage(imageStruct &image); - ////////// - // Set the new edge threshold - void floatThreshMess(float thresh); - void floatMhiDuration(float duration); - void floatmin_time_delta(float min_time_delta); - void floatmax_time_delta(float max_time_delta); - void floatframe_buffer_num(float frame_buffer_num); - void floatmax_size(float max_size); - void floatmin_size(float min_size); - - // to detect changes in the image size - int comp_xsize; - int comp_ysize; + ////////// + // Set the new edge threshold + void floatThreshMess(float thresh); + void floatMhiDuration(float duration); + void floatmin_time_delta(float min_time_delta); + void floatmax_time_delta(float max_time_delta); + void floatframe_buffer_num(float frame_buffer_num); + void floatmax_size(float max_size); + void floatmin_size(float min_size); + void apertureMess(float aperture); + + // to detect changes in the image size + int comp_xsize; + int comp_ysize; - // Some varibales to control mophology mhi_duration - int mhi_duration; - int diff_threshold; - int mask_size; - int last; + // Some varibales to control mophology mhi_duration + double mhi_duration; + int diff_threshold; + int mask_size; + int last; + int aperture; + + // various tracking parameters (in seconds) + double max_time_delta; + double min_time_delta; + // number of cyclic frame buffer used for motion detection + // (should, probably, depend on FPS) + int frame_buffer_num; + + int max_size; + int min_size; + + private: + + ////////// + // Static member functions + static void thresholdMessCallback(void *data, t_floatarg pos); + static void mhi_durationMessCallback(void *data, t_floatarg mhi_duration); + static void max_time_deltaMessCallback(void *data, t_floatarg max_time_delta); + static void min_time_deltaMessCallback(void *data, t_floatarg min_time_delta); + static void frame_buffer_numMessCallback(void *data, t_floatarg frame_buffer_num); + static void min_sizeMessCallback(void *data, t_floatarg min_size); + static void max_sizeMessCallback(void *data, t_floatarg max_size); + static void apertureMessCallback(void *data, t_floatarg aperture); + + // The output and temporary images + IplImage *img, *motion, *rgba, *alpha; - - // various tracking parameters (in seconds) - double max_time_delta; - double min_time_delta; - // number of cyclic frame buffer used for motion detection - // (should, probably, depend on FPS) - int frame_buffer_num; - - int max_size; - int min_size; - - - private: - - ////////// - // Static member functions - static void thresholdMessCallback(void *data, t_floatarg pos); - static void mhi_durationMessCallback(void *data, t_floatarg mhi_duration); - static void max_time_deltaMessCallback(void *data, t_floatarg max_time_delta); - static void min_time_deltaMessCallback(void *data, t_floatarg min_time_delta); - static void frame_buffer_numMessCallback(void *data, t_floatarg frame_buffer_num); - static void min_sizeMessCallback(void *data, t_floatarg min_size); - static void max_sizeMessCallback(void *data, t_floatarg max_size); - - // The output and temporary images - IplImage *img, *motion, *rgba, *alpha; - - // ring image buffer - IplImage **buf; - - // temporary images - IplImage *mhi; // MHI - IplImage *orient; // orientation - IplImage *mask; // valid orientation mask - IplImage *segmask; // motion segmentation map - CvMemStorage* storage; // temporary storage - t_outlet *m_dataout; + // ring image buffer + IplImage **buf; + + // temporary images + IplImage *mhi; // MHI + IplImage *orient; // orientation + IplImage *mask; // valid orientation mask + IplImage *segmask; // motion segmentation map + CvMemStorage* storage; // temporary storage + t_outlet *m_dataout; }; #endif // for header file |