diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | pix_opencv_hu_compare-help.pd | 39 | ||||
-rw-r--r-- | pix_opencv_hu_compare.cc | 8 | ||||
-rw-r--r-- | pix_opencv_hu_compare.h | 3 | ||||
-rw-r--r-- | pix_opencv_pgh_compare-help.pd | 21 | ||||
-rw-r--r-- | pix_opencv_pgh_compare.cc | 8 | ||||
-rw-r--r-- | pix_opencv_pgh_compare.h | 3 |
7 files changed, 72 insertions, 18 deletions
@@ -1,5 +1,5 @@ -PD_DIR = /usr/src/pd-svn/trunk/pd -GEM_DIR = /usr/src/pd-svn/trunk/Gem +PD_DIR = /Software/pd-svn/trunk/pd +GEM_DIR = /usr/local/pd/gem GEM_OPENCV_VERSION = 0.2 @@ -13,12 +13,14 @@ CPPFLAGS = -fPIC -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \ UNAME := $(shell uname -s) ifeq ($(UNAME),Linux) + CPPFLAGS += -DLINUX INCLUDES += `pkg-config --cflags opencv` LDFLAGS = -export_dynamic -shared LIBS = `pkg-config --libs opencv` EXTENSION = pd_linux endif ifeq ($(UNAME),Darwin) + CPPFLAGS += -DDARWIN INCLUDES += -I/System/Library/Frameworks/OpenCV.framework/Headers/ LDFLAGS = -bundle -undefined dynamic_lookup LIBS = -lm -framework OpenCV @@ -28,7 +30,7 @@ endif .SUFFIXES = $(EXTENSION) SOURCES = pix_opencv_edge.cc pix_opencv_laplace.cc pix_opencv_morphology.cc pix_opencv_distrans.cc pix_opencv_motempl.cc pix_opencv_haarcascade.cc pix_opencv_contours_boundingrect.cc pix_opencv_bgsubstract.cc pix_opencv_contours_convexity.cc pix_opencv_dft.cc pix_opencv_lk.cc pix_opencv_hist_compare.cc pix_opencv_knear.cc pix_opencv_threshold.cc pix_opencv_floodfill.cc pix_opencv_athreshold.cc pix_opencv_bgstats.cc pix_opencv_camshift.cc pix_opencv_hu_compare.cc pix_opencv_pgh_compare.cc pix_opencv_hough_circles.cc pix_opencv_hough_lines.cc pix_opencv_hu_moments.cc pix_opencv_contours_convexhull.cc pix_opencv_colorfilt.cc -SOURCES_OPT = +SOURCES_OPT = pix_opencv_surf.cc all: $(SOURCES:.cc=.$(EXTENSION)) $(SOURCES_OPT:.cc=.$(EXTENSION)) diff --git a/pix_opencv_hu_compare-help.pd b/pix_opencv_hu_compare-help.pd index d7b1f46..4315ac4 100644 --- a/pix_opencv_hu_compare-help.pd +++ b/pix_opencv_hu_compare-help.pd @@ -1,7 +1,7 @@ -#N canvas 266 86 1154 642 10; +#N canvas 266 66 1154 759 10; #X obj 937 -7 gemhead; -#X obj 372 500 pix_texture; -#X obj 372 528 square 2; +#X obj 375 543 pix_texture; +#X obj 374 566 square 2; #X obj 9 -28 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577 0; #N canvas 0 22 454 304 gemwin 0; @@ -37,7 +37,7 @@ #X restore 14 16 pd gemwin; #X msg 14 -5 create; #X text 15 -23 Create window and render; -#X obj 363 232 cnv 15 700 250 empty empty empty 20 12 0 14 -24198 -66577 +#X obj 353 225 cnv 15 700 300 empty empty empty 20 12 0 14 -24198 -66577 0; #X obj 619 -90 bng 25 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; @@ -51,16 +51,16 @@ #X obj 625 -16 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X obj 373 395 pix_opencv_hu_compare; -#X floatatom 506 439 30 0 0 0 - - -; -#X text 511 422 distance; -#X obj 722 457 route 1; -#X obj 774 457 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +#X floatatom 491 481 30 0 0 0 - - -; +#X text 496 464 distance; +#X obj 707 499 route 1; +#X obj 759 499 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; -#X obj 683 458 < 0.1; -#X obj 783 437 hsl 128 15 0 0.2 0 0 cdist empty empty -2 -8 0 10 -262144 +#X obj 668 500 < 0.1; +#X obj 768 479 hsl 128 15 0 0.2 0 0 cdist empty empty -2 -8 0 10 -262144 -1 -1 0 1; -#X text 696 420 criteria value; -#X floatatom 701 439 10 0 0 0 - - -; +#X text 788 499 criteria value; +#X floatatom 686 481 10 0 0 0 - - -; #X text 528 376 calculating their hu moments ( CvMatchShape ); #X text 527 364 compares the contours to the pattern reference contour ; @@ -154,6 +154,16 @@ colors; #X msg 422 16 driver 1; #X msg 399 -69 dialog; #X msg 404 -39 device /dev/dv1394-0; +#X obj 547 415 unpack f f f f f; +#X text 661 415 position of detected contours; +#X floatatom 570 437 5 0 0 0 - - -; +#X floatatom 608 438 5 0 0 0 - - -; +#X floatatom 648 437 5 0 0 0 - - -; +#X floatatom 691 438 5 0 0 0 - - -; +#X text 577 450 X; +#X text 616 449 Y; +#X text 648 449 width; +#X text 689 450 height; #X connect 0 0 49 0; #X connect 1 0 2 0; #X connect 4 0 5 0; @@ -169,6 +179,7 @@ colors; #X connect 15 0 14 0; #X connect 16 0 1 0; #X connect 16 1 17 0; +#X connect 16 2 82 0; #X connect 17 0 21 0; #X connect 19 0 20 0; #X connect 21 0 19 0; @@ -219,3 +230,7 @@ colors; #X connect 79 0 76 0; #X connect 80 0 76 0; #X connect 81 0 76 0; +#X connect 82 1 84 0; +#X connect 82 2 85 0; +#X connect 82 3 86 0; +#X connect 82 4 87 0; diff --git a/pix_opencv_hu_compare.cc b/pix_opencv_hu_compare.cc index ad00fe5..101c448 100644 --- a/pix_opencv_hu_compare.cc +++ b/pix_opencv_hu_compare.cc @@ -30,6 +30,7 @@ CPPEXTERN_NEW_WITH_GIMME(pix_opencv_hu_compare) pix_opencv_hu_compare :: pix_opencv_hu_compare(int argc, t_atom*argv) { m_dataout = outlet_new(this->x_obj, &s_anything); + m_posout = outlet_new(this->x_obj, &s_anything); comp_xsize=320; comp_ysize=240; @@ -136,6 +137,7 @@ void pix_opencv_hu_compare :: processRGBA_RGBA(imageStruct &left, imageStruct &r cvFindContours( gray, mstorage, &contourl, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) ); + i=0; if ( contourl && x_bcontourr ) { contourlp=contourl; @@ -150,6 +152,12 @@ void pix_opencv_hu_compare :: processRGBA_RGBA(imageStruct &left, imageStruct &r { cvRectangle( gray, cvPoint(rect.x,rect.y), cvPoint(rect.x+rect.width,rect.y+rect.height), CV_RGB(255,255,255), 2, 8 , 0 ); cvDrawContours( gray, contourlp, CV_RGB(255,255,255), CV_RGB(255,255,255), 0, 1, 8, cvPoint(0,0) ); + SETFLOAT(&rlist[0], i++); + SETFLOAT(&rlist[1], rect.x); + SETFLOAT(&rlist[2], rect.y); + SETFLOAT(&rlist[3], rect.width); + SETFLOAT(&rlist[4], rect.height); + outlet_list( m_posout, 0, 5, rlist ); } else { diff --git a/pix_opencv_hu_compare.h b/pix_opencv_hu_compare.h index 50dd20c..f083a22 100644 --- a/pix_opencv_hu_compare.h +++ b/pix_opencv_hu_compare.h @@ -64,6 +64,7 @@ class GEM_EXTERN pix_opencv_hu_compare : public GemPixDualObj int comp_ysize; t_outlet *m_dataout; + t_outlet *m_posout; int x_method; int x_minsize; @@ -84,6 +85,8 @@ class GEM_EXTERN pix_opencv_hu_compare : public GemPixDualObj CvMemStorage *x_storage; CvSeq *x_bcontourr; + t_atom rlist[5]; + }; #endif // for header file diff --git a/pix_opencv_pgh_compare-help.pd b/pix_opencv_pgh_compare-help.pd index c5cefa4..2f3dff0 100644 --- a/pix_opencv_pgh_compare-help.pd +++ b/pix_opencv_pgh_compare-help.pd @@ -1,4 +1,4 @@ -#N canvas 266 176 1154 642 10; +#N canvas 266 183 1154 642 10; #X obj 897 4 gemhead; #X obj 372 500 pix_texture; #X obj 372 528 square 2; @@ -57,7 +57,7 @@ -1 -1; #X obj 783 437 hsl 128 15 0 0.2 0 0 cdist empty empty -2 -8 0 10 -262144 -1 -1 0 1; -#X text 696 420 criteria value; +#X text 805 455 criteria value; #X floatatom 701 439 10 0 0 0 - - -; #X msg 478 319 criteria \$1; #X obj 562 320 r cdist; @@ -96,7 +96,7 @@ #X obj 831 34 pix_resize 320 240; #X obj 831 181 translateXYZ 4 0 0; #X obj 374 177 pix_resize 320 240; -#X obj 374 395 pix_opencv_pgh_compare; +#X obj 374 356 pix_opencv_pgh_compare; #X text 17 -80 pix_opencv_pgh_compare :: compare contours calculating their PGH histograms.; #X text 17 -53 Written by Yves Degoyon ( ydegoyon@gmail.com ) using @@ -144,6 +144,16 @@ example code from OpenCV book; #X msg 420 56 driver 1; #X msg 397 -29 dialog; #X msg 402 1 device /dev/dv1394-0; +#X obj 544 379 unpack f f f f f; +#X text 658 379 position of detected contours; +#X floatatom 567 401 5 0 0 0 - - -; +#X floatatom 605 402 5 0 0 0 - - -; +#X floatatom 645 401 5 0 0 0 - - -; +#X floatatom 688 402 5 0 0 0 - - -; +#X text 574 414 X; +#X text 613 413 Y; +#X text 645 413 width; +#X text 686 414 height; #X connect 0 0 38 0; #X connect 1 0 2 0; #X connect 4 0 5 0; @@ -191,6 +201,7 @@ example code from OpenCV book; #X connect 57 0 52 0; #X connect 58 0 1 0; #X connect 58 1 16 0; +#X connect 58 2 75 0; #X connect 61 0 18 0; #X connect 63 0 64 0; #X connect 64 0 13 0; @@ -207,3 +218,7 @@ example code from OpenCV book; #X connect 72 0 69 0; #X connect 73 0 69 0; #X connect 74 0 69 0; +#X connect 75 1 77 0; +#X connect 75 2 78 0; +#X connect 75 3 79 0; +#X connect 75 4 80 0; diff --git a/pix_opencv_pgh_compare.cc b/pix_opencv_pgh_compare.cc index b4633a7..4af6d8e 100644 --- a/pix_opencv_pgh_compare.cc +++ b/pix_opencv_pgh_compare.cc @@ -30,6 +30,7 @@ CPPEXTERN_NEW_WITH_GIMME(pix_opencv_pgh_compare) pix_opencv_pgh_compare :: pix_opencv_pgh_compare(int argc, t_atom*argv) { m_dataout = outlet_new(this->x_obj, &s_anything); + m_posout = outlet_new(this->x_obj, &s_anything); comp_xsize=320; comp_ysize=240; @@ -139,6 +140,7 @@ void pix_opencv_pgh_compare :: processRGBA_RGBA(imageStruct &left, imageStruct & cvFindContours( gray, mstorage, &contourl, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) ); + i=0; if ( contourl && x_bcontourr ) { contourlp=contourl; @@ -162,6 +164,12 @@ void pix_opencv_pgh_compare :: processRGBA_RGBA(imageStruct &left, imageStruct & { cvRectangle( gray, cvPoint(rect.x,rect.y), cvPoint(rect.x+rect.width,rect.y+rect.height), CV_RGB(255,255,255), 2, 8 , 0 ); cvDrawContours( gray, contourlp, CV_RGB(255,255,255), CV_RGB(255,255,255), 0, 1, 8, cvPoint(0,0) ); + SETFLOAT(&rlist[0], i++); + SETFLOAT(&rlist[1], rect.x); + SETFLOAT(&rlist[2], rect.y); + SETFLOAT(&rlist[3], rect.width); + SETFLOAT(&rlist[4], rect.height); + outlet_list( m_posout, 0, 5, rlist ); } else { diff --git a/pix_opencv_pgh_compare.h b/pix_opencv_pgh_compare.h index f190ac3..94e9c78 100644 --- a/pix_opencv_pgh_compare.h +++ b/pix_opencv_pgh_compare.h @@ -63,6 +63,7 @@ class GEM_EXTERN pix_opencv_pgh_compare : public GemPixDualObj int comp_ysize; t_outlet *m_dataout; + t_outlet *m_posout; int x_minsize; float x_cdistance; @@ -81,6 +82,8 @@ class GEM_EXTERN pix_opencv_pgh_compare : public GemPixDualObj CvMemStorage *x_storage; CvSeq *x_bcontourr; + t_atom rlist[5]; + }; #endif // for header file |