aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlluís gómez i bigordà <lluisbigorda@users.sourceforge.net>2009-09-18 16:57:14 +0000
committerlluís gómez i bigordà <lluisbigorda@users.sourceforge.net>2009-09-18 16:57:14 +0000
commit28833a23cfbd1ffbb45076acf110447444c6a849 (patch)
tree0a9f6954a471fef908011a7f3a92af41c9da352f
parentb7b82f9bd8cf4abe4eefd02e692aa68f10a192c9 (diff)
added pix_opencv_colorfilt
svn path=/trunk/externals/pix_opencv/; revision=12396
-rw-r--r--Makefile2
-rw-r--r--Makefile.in2
-rw-r--r--pix_opencv_colorfilt-help.pd128
-rw-r--r--pix_opencv_colorfilt.cc285
-rw-r--r--pix_opencv_colorfilt.h103
5 files changed, 518 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index ca52e25..d97d8a8 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,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
+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 =
all: $(SOURCES:.cc=.$(EXTENSION)) $(SOURCES_OPT:.cc=.$(EXTENSION))
diff --git a/Makefile.in b/Makefile.in
index fb941ec..ec751f9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -27,7 +27,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
+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@
all: $(SOURCES:.cc=.$(EXTENSION)) $(SOURCES_OPT:.cc=.$(EXTENSION))
diff --git a/pix_opencv_colorfilt-help.pd b/pix_opencv_colorfilt-help.pd
new file mode 100644
index 0000000..1163a7b
--- /dev/null
+++ b/pix_opencv_colorfilt-help.pd
@@ -0,0 +1,128 @@
+#N canvas 27 6 925 684 10;
+#X obj 277 -24 gemhead;
+#X obj 183 555 pix_texture;
+#X obj 659 -55 cnv 15 220 70 empty empty empty 20 12 0 14 -195568 -66577
+0;
+#N canvas 0 22 454 304 gemwin 0;
+#X obj 67 89 outlet;
+#X obj 67 10 inlet;
+#X obj 65 41 route create;
+#X msg 67 70 set destroy;
+#X msg 182 68 set create;
+#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 connect 1 0 2 0;
+#X restore 289 80 pd Gem.init;
+#X obj 162 241 gemwin;
+#X msg 161 188 create \, 1;
+#X msg 237 189 destroy;
+#X msg 283 161 frame 5;
+#X obj 164 126 t b b b;
+#X connect 1 0 2 0;
+#X connect 2 0 3 0;
+#X connect 2 0 10 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 7 0;
+#X connect 10 2 9 0;
+#X restore 669 -11 pd gemwin;
+#X msg 669 -29 destroy;
+#X obj 170 -57 bng 25 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 337 144 unpack 0 0 0;
+#X floatatom 327 167 5 0 0 3 length - -;
+#X floatatom 376 167 5 0 0 3 width - -;
+#X floatatom 426 167 5 0 0 3 height - -;
+#X obj 227 118 bng 15 250 50 0 empty empty end_reached 20 7 0 10 -262144
+-1 -1;
+#X floatatom 209 83 5 0 10000 1 frame# - -;
+#X obj 170 -28 openpanel;
+#X msg 170 -8 open \$1;
+#X obj 158 101 pix_film;
+#X msg 176 35 auto \$1;
+#X obj 176 17 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+;
+#X obj 178 299 cnv 15 600 250 empty empty empty 20 12 0 14 -4034 -66577
+0;
+#X text 667 -49 Create window and render;
+#X text 373 101 written by Yves Degoyon ( ydegoyon@gmail.com );
+#X msg 271 18 colorspace RGBA;
+#X msg 376 18 colorspace RGB;
+#X msg 480 18 colorspace Grey;
+#X obj 277 -2 loadbang;
+#X obj 183 474 pix_opencv_colorfilt;
+#X obj 183 574 rectangle 5.3 4;
+#X floatatom 215 505 5 0 0 0 - - -;
+#X floatatom 260 504 5 0 0 0 - - -;
+#X floatatom 305 503 5 0 0 0 - - -;
+#X text 349 503 RGB selected components;
+#X obj 250 401 pdp_colorgrid pdp_colorgrid1 256 0 256 50 0 50 0 1 1
+10 10 275 446;
+#X msg 256 363 tolerance \$1;
+#X floatatom 342 365 5 0 0 0 - - -;
+#X text 383 364 tolerance applied for the selection of colors;
+#X obj 740 114 gemmouse;
+#X obj 796 221 f;
+#X obj 766 220 f;
+#X obj 810 192 t b b;
+#X obj 763 265 pack f f;
+#X obj 786 142 route 1;
+#X msg 807 167 bang;
+#X floatatom 757 242 5 0 0 0 - - -;
+#X floatatom 810 245 5 0 0 0 - - -;
+#X text 374 66 pix_opencv_colorfilt : color filter;
+#X text 373 77 you can set the selected color with its RGB components
+or by selecting a piksel in the video window;
+#X msg 239 317 pick \$1 \$2;
+#X text 315 316 pick a color from the video;
+#X connect 0 0 14 0;
+#X connect 1 0 25 0;
+#X connect 3 0 4 0;
+#X connect 4 0 3 0;
+#X connect 5 0 12 0;
+#X connect 6 0 7 0;
+#X connect 6 1 8 0;
+#X connect 6 2 9 0;
+#X connect 10 0 11 0;
+#X connect 11 0 14 1;
+#X connect 12 0 13 0;
+#X connect 13 0 14 0;
+#X connect 14 0 24 0;
+#X connect 14 1 6 0;
+#X connect 14 2 10 0;
+#X connect 15 0 14 0;
+#X connect 16 0 15 0;
+#X connect 20 0 14 0;
+#X connect 21 0 14 0;
+#X connect 22 0 14 0;
+#X connect 23 0 20 0;
+#X connect 24 0 1 0;
+#X connect 24 1 26 0;
+#X connect 24 2 27 0;
+#X connect 24 3 28 0;
+#X connect 30 0 24 1;
+#X connect 30 1 24 2;
+#X connect 30 2 24 3;
+#X connect 31 0 24 0;
+#X connect 32 0 31 0;
+#X connect 34 0 36 1;
+#X connect 34 1 35 1;
+#X connect 34 2 39 0;
+#X connect 35 0 38 1;
+#X connect 35 0 42 0;
+#X connect 36 0 38 0;
+#X connect 36 0 41 0;
+#X connect 37 0 36 0;
+#X connect 37 1 35 0;
+#X connect 38 0 45 0;
+#X connect 39 0 40 0;
+#X connect 40 0 37 0;
+#X connect 45 0 24 0;
diff --git a/pix_opencv_colorfilt.cc b/pix_opencv_colorfilt.cc
new file mode 100644
index 0000000..483f0b1
--- /dev/null
+++ b/pix_opencv_colorfilt.cc
@@ -0,0 +1,285 @@
+////////////////////////////////////////////////////////
+//
+// GEM - Graphics Environment for Multimedia
+//
+// zmoelnig@iem.kug.ac.at
+//
+// Implementation file
+//
+// Copyright (c) 1997-2000 Mark Danks.
+// Copyright (c) Günther Geiger.
+// Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM
+// Copyright (c) 2002 James Tittle & Chris Clepper
+// For information on usage and redistribution, and for a DISCLAIMER OF ALL
+// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+//
+/////////////////////////////////////////////////////////
+
+#include "pix_opencv_colorfilt.h"
+#include "g_canvas.h"
+
+CPPEXTERN_NEW(pix_opencv_colorfilt)
+
+/////////////////////////////////////////////////////////
+//
+// pix_opencv_colorfilt
+//
+/////////////////////////////////////////////////////////
+// Constructor
+//
+/////////////////////////////////////////////////////////
+pix_opencv_colorfilt :: pix_opencv_colorfilt()
+{
+ inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("R"));
+ inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("G"));
+ inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("B"));
+
+ x_R = outlet_new(this->x_obj, &s_float);
+ x_G = outlet_new(this->x_obj, &s_float);
+ x_B = outlet_new(this->x_obj, &s_float);
+
+ x_colorR = 128;
+ x_colorG = 128;
+ x_colorB = 128;
+
+ outlet_float( x_R, x_colorR );
+ outlet_float( x_G, x_colorG );
+ outlet_float( x_B, x_colorB );
+
+ comp_xsize=320;
+ comp_ysize=240;
+
+ x_tolerance = 50;
+
+ x_canvas = canvas_getcurrent();
+
+ rgba = cvCreateImage(cvSize(comp_xsize,comp_ysize), IPL_DEPTH_8U, 4);
+ rgb = cvCreateImage(cvSize(comp_xsize,comp_ysize), IPL_DEPTH_8U, 3);
+ brgb = cvCreateImage(cvSize(comp_xsize,comp_ysize), IPL_DEPTH_8U, 3);
+}
+
+/////////////////////////////////////////////////////////
+// Destructor
+//
+/////////////////////////////////////////////////////////
+pix_opencv_colorfilt :: ~pix_opencv_colorfilt()
+{
+ //Destroy cv_images to clean memory
+ cvReleaseImage(&rgba);
+ cvReleaseImage(&rgb);
+ cvReleaseImage(&brgb);
+}
+
+void pix_opencv_colorfilt :: drawColor()
+{
+ int width, height;
+ char color[32];
+
+ sprintf( color, "#%.2X%.2X%.2X", x_colorR, x_colorG, x_colorB );
+ width = rtext_width( glist_findrtext( (t_glist*)x_canvas, (t_text *)this->x_obj ) );
+ height = rtext_height( glist_findrtext( (t_glist*)x_canvas, (t_text *)this->x_obj ) );
+ sys_vgui((char*)".x%x.c delete rectangle %xCOLOR\n", x_canvas, this->x_obj );
+ sys_vgui((char*)".x%x.c create rectangle %d %d %d %d -fill %s -tags %xCOLOR\n",
+ x_canvas, this->x_obj->te_xpix+width+5, this->x_obj->te_ypix,
+ this->x_obj->te_xpix+width+height+5,
+ this->x_obj->te_ypix+height, color, this->x_obj );
+}
+
+/////////////////////////////////////////////////////////
+// processImage
+//
+/////////////////////////////////////////////////////////
+void pix_opencv_colorfilt :: processRGBAImage(imageStruct &image)
+{
+ int px,py;
+ unsigned char r,g,b;
+ int diff;
+
+ if ((this->comp_xsize!=image.xsize)||(this->comp_ysize!=image.ysize)||(!rgba)) {
+
+ comp_xsize = image.xsize;
+ comp_ysize = image.ysize;
+
+ //Destroy cv_images to clean memory
+ if ( rgba )
+ {
+ cvReleaseImage(&rgba);
+ cvReleaseImage(&rgb);
+ cvReleaseImage(&brgb);
+ }
+
+ //create the orig image with new size
+ rgba = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 4);
+ rgb = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 3);
+ brgb = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 3);
+ }
+ memcpy( rgba->imageData, image.data, image.xsize*image.ysize*4 );
+ cvCvtColor(rgba, brgb, CV_BGRA2BGR);
+
+ for( py=0; py<rgba->height; py++ ) {
+ for( px=0; px<rgba->width; px++ ) {
+ b = ((uchar*)(rgba->imageData + rgba->widthStep*(int)py))[(int)px*4];
+ g = ((uchar*)(rgba->imageData + rgba->widthStep*(int)py))[(int)px*4+1];
+ r = ((uchar*)(rgba->imageData + rgba->widthStep*(int)py))[(int)px*4+2];
+
+ diff = 0;
+ diff = abs(r-x_colorR );
+ diff += abs(g-x_colorG );
+ diff += abs(b-x_colorB );
+
+ if ( diff > x_tolerance )
+ {
+ (rgba->imageData + rgba->widthStep*(int)py)[(int)px*4] = 0x0;
+ (rgba->imageData + rgba->widthStep*(int)py)[(int)px*4+1] = 0x0;
+ (rgba->imageData + rgba->widthStep*(int)py)[(int)px*4+2] = 0x0;
+ }
+ }
+ }
+
+ //copy back the processed frame to image
+ memcpy( image.data, rgba->imageData, image.xsize*image.ysize*4 );
+}
+
+void pix_opencv_colorfilt :: processRGBImage(imageStruct &image)
+{
+ unsigned char r,g,b;
+ int diff;
+ int px, py;
+
+ if ((this->comp_xsize!=image.xsize)||(this->comp_ysize!=image.ysize)||(!rgb)) {
+
+ this->comp_xsize = image.xsize;
+ this->comp_ysize = image.ysize;
+
+ //Destroy cv_images to clean memory
+ if ( rgb )
+ {
+ cvReleaseImage(&rgba);
+ cvReleaseImage(&rgb);
+ cvReleaseImage(&brgb);
+ }
+
+ //create the orig image with new size
+ rgba = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 4);
+ rgb = cvCreateImage(cvSize(image.xsize,image.ysize), IPL_DEPTH_8U, 3);
+ brgb = cvCreateImage(cvSize(rgb->width,rgb->height), IPL_DEPTH_8U, 3);
+
+ }
+ memcpy( rgb->imageData, image.data, image.xsize*image.ysize*3 );
+ cvCopy(rgb, brgb);
+
+ for( py=0; py<rgb->height; py++ ) {
+ for( px=0; px<rgb->width; px++ ) {
+ b = ((uchar*)(rgb->imageData + rgb->widthStep*(int)py))[(int)px*3];
+ g = ((uchar*)(rgb->imageData + rgb->widthStep*(int)py))[(int)px*3+1];
+ r = ((uchar*)(rgb->imageData + rgb->widthStep*(int)py))[(int)px*3+2];
+
+ diff = 0;
+ diff = abs(r-x_colorR );
+ diff += abs(g-x_colorG );
+ diff += abs(b-x_colorB );
+
+ if ( diff > x_tolerance )
+ {
+ (rgb->imageData + rgb->widthStep*(int)py)[(int)px*3] = 0x0;
+ (rgb->imageData + rgb->widthStep*(int)py)[(int)px*3+1] = 0x0;
+ (rgb->imageData + rgb->widthStep*(int)py)[(int)px*3+2] = 0x0;
+ }
+ }
+ }
+
+ memcpy( image.data, rgb->imageData, image.xsize*image.ysize*3 );
+}
+
+void pix_opencv_colorfilt :: processYUVImage(imageStruct &image)
+{
+ post( "pix_opencv_colorfilt : yuv format not supported" );
+}
+
+void pix_opencv_colorfilt :: processGrayImage(imageStruct &image)
+{
+ post( "pix_opencv_colorfilt : gray format not supported" );
+}
+
+void pix_opencv_colorfilt :: floatToleranceMess (float tolerance)
+{
+ if ( (int)tolerance>0 ) x_tolerance = (int)tolerance;
+}
+
+void pix_opencv_colorfilt :: floatRMess (float r)
+{
+ if ( ( (int)r>=0 ) && ( (int)r<=255 ) ) x_colorR = (int)r;
+ if (glist_isvisible(x_canvas)) drawColor();
+}
+
+void pix_opencv_colorfilt :: floatGMess (float g)
+{
+ if ( ( (int)g>=0 ) && ( (int)g<=255 ) ) x_colorG = (int)g;
+ if (glist_isvisible(x_canvas)) drawColor();
+}
+
+void pix_opencv_colorfilt :: floatBMess (float b)
+{
+ if ( ( (int)b>=0 ) && ( (int)b<=255 ) ) x_colorB = (int)b;
+ if (glist_isvisible(x_canvas)) drawColor();
+}
+
+void pix_opencv_colorfilt :: pickMess (float xcur, float ycur)
+{
+ if ( ( xcur >= 0. ) && ( xcur <= comp_xsize )
+ && ( ycur > 0. ) && ( ycur < comp_ysize ) )
+ {
+ x_colorB = ((uchar*)(brgb->imageData + brgb->widthStep*(int)ycur))[(int)xcur*3];
+ x_colorG = ((uchar*)(brgb->imageData + brgb->widthStep*(int)ycur))[(int)xcur*3+1];
+ x_colorR = ((uchar*)(brgb->imageData + brgb->widthStep*(int)ycur))[(int)xcur*3+2];
+
+ outlet_float( x_R, x_colorR );
+ outlet_float( x_G, x_colorG );
+ outlet_float( x_B, x_colorB );
+
+ if (glist_isvisible(x_canvas)) drawColor();
+ }
+}
+
+/////////////////////////////////////////////////////////
+// static member function
+//
+/////////////////////////////////////////////////////////
+void pix_opencv_colorfilt :: obj_setupCallback(t_class *classPtr)
+{
+ class_addmethod(classPtr, (t_method)&pix_opencv_colorfilt::floatToleranceMessCallback,
+ gensym("tolerance"), A_FLOAT, A_NULL);
+ class_addmethod(classPtr, (t_method)&pix_opencv_colorfilt::floatRMessCallback,
+ gensym("R"), A_FLOAT, A_NULL);
+ class_addmethod(classPtr, (t_method)&pix_opencv_colorfilt::floatGMessCallback,
+ gensym("G"), A_FLOAT, A_NULL);
+ class_addmethod(classPtr, (t_method)&pix_opencv_colorfilt::floatBMessCallback,
+ gensym("B"), A_FLOAT, A_NULL);
+ class_addmethod(classPtr, (t_method)&pix_opencv_colorfilt::pickMessCallback,
+ gensym("pick"), A_FLOAT, A_FLOAT, A_NULL);
+}
+
+void pix_opencv_colorfilt :: floatToleranceMessCallback(void *data, t_floatarg tolerance)
+{
+ GetMyClass(data)->floatToleranceMess((float)tolerance);
+}
+
+void pix_opencv_colorfilt :: floatRMessCallback(void *data, t_floatarg r)
+{
+ GetMyClass(data)->floatRMess((float)r);
+}
+
+void pix_opencv_colorfilt :: floatGMessCallback(void *data, t_floatarg g)
+{
+ GetMyClass(data)->floatGMess((float)g);
+}
+
+void pix_opencv_colorfilt :: floatBMessCallback(void *data, t_floatarg b)
+{
+ GetMyClass(data)->floatBMess((float)b);
+}
+
+void pix_opencv_colorfilt :: pickMessCallback(void *data, t_floatarg xcur, t_floatarg ycur)
+{
+ GetMyClass(data)->pickMess((float)xcur,(float)ycur);
+}
diff --git a/pix_opencv_colorfilt.h b/pix_opencv_colorfilt.h
new file mode 100644
index 0000000..b3a3949
--- /dev/null
+++ b/pix_opencv_colorfilt.h
@@ -0,0 +1,103 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Color filter
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ Copyright (c) 2002 James Tittle & Chris Clepper
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_PIX_OPENCV_COLORFILT_H_
+#define INCLUDE_PIX_OPENCV_COLORFILT_H_
+
+#include "Base/GemPixObj.h"
+
+#include <stdio.h>
+
+#ifndef _EiC
+#include "cv.h"
+#endif
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ pix_opencv_colorfilt
+
+ Color filter object
+
+KEYWORDS
+ pix
+
+DESCRIPTION
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN pix_opencv_colorfilt : public GemPixObj
+{
+ CPPEXTERN_HEADER(pix_opencv_colorfilt, GemPixObj)
+
+ public:
+
+ //////////
+ // Constructor
+ pix_opencv_colorfilt();
+
+ protected:
+
+ //////////
+ // Destructor
+ virtual ~pix_opencv_colorfilt();
+
+ //////////
+ // 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 floatToleranceMess(float tolerance);
+ void floatRMess(float r);
+ void floatGMess(float g);
+ void floatBMess(float b);
+ void pickMess(float xcur, float ycur);
+ void drawColor(void);
+
+ // The color tolerance
+ int x_tolerance;
+ unsigned char x_colorR; // RGB components of binary mask
+ unsigned char x_colorG;
+ unsigned char x_colorB;
+
+ t_outlet *x_R; // output R component of selected color
+ t_outlet *x_G; // output G component of selected color
+ t_outlet *x_B; // output B component of selected color
+
+ t_canvas *x_canvas;
+
+ // to detect changes in the image size
+ int comp_xsize;
+ int comp_ysize;
+
+ private:
+
+ //////////
+ // Static member functions
+ static void floatToleranceMessCallback(void *data, float tolerance);
+ static void floatRMessCallback(void *data, float r);
+ static void floatGMessCallback(void *data, float g);
+ static void floatBMessCallback(void *data, float b);
+ static void pickMessCallback(void *data, float xcur, float ycur);
+
+ /////////
+ // IplImage needed
+ IplImage *rgba, *rgb, *brgb;
+};
+
+#endif // for header file