diff options
author | Antoine Villeret <avilleret@users.sourceforge.net> | 2013-10-08 08:16:17 +0000 |
---|---|---|
committer | Antoine Villeret <avilleret@users.sourceforge.net> | 2013-10-08 08:16:17 +0000 |
commit | e99cbc19d6fcf61e4b3a056eafa35b88852aea53 (patch) | |
tree | 9f2c082dd4bad7bedce3be28029308671dc8aa35 | |
parent | f79e9cb01a0d7f7c7774d496dcd1c11804c7d509 (diff) |
add areaThreshold message and filter
svn path=/trunk/externals/pix_opencv/; revision=17208
-rw-r--r-- | pix_opencv_blobtrack.cc | 41 | ||||
-rw-r--r-- | pix_opencv_blobtrack.h | 8 |
2 files changed, 27 insertions, 22 deletions
diff --git a/pix_opencv_blobtrack.cc b/pix_opencv_blobtrack.cc index ed84d20..4eaa56f 100644 --- a/pix_opencv_blobtrack.cc +++ b/pix_opencv_blobtrack.cc @@ -41,7 +41,8 @@ pix_opencv_blobtrack :: pix_opencv_blobtrack() : m_fg_name(FGDetector_Modules[0 m_bt_corr("none"), \ m_FGTrainFrames(6), \ m_monitoring_stage(0), \ - m_tracker(NULL) + m_areaThreshold(0.), \ + m_tracker(NULL) { m_param.pBT=NULL; m_param.pBD=NULL; @@ -114,35 +115,30 @@ void pix_opencv_blobtrack :: RunBlobTrackingAuto( IplImage* img ) break; } - /* Process: */ - m_tracker->Process(imgRGB, pMask); + /* Process: */ + m_tracker->Process(imgRGB, pMask); //~ t_atom blob_num; //~ SETFLOAT(&blob_num, m_tracker->GetBlobNum()); //~ outlet_anything(m_dataout, gensym("blobnum"), 1, &blob_num); - int blob_num=m_tracker->GetBlobNum(); + int blob_num=m_tracker->GetBlobNum(); int blob_atom_size = 2+blob_num*6; t_atom* blob_atom = new t_atom[blob_atom_size]; SETFLOAT(&blob_atom[0], blob_num); SETFLOAT(&blob_atom[1], 6); - for(int i=0; i<blob_num; i++){ + for(int i=0; i<blob_num; i++){ CvBlob* blob = m_tracker->GetBlob(i); - SETFLOAT(&blob_atom[2+i*6], blob->ID); - SETFLOAT(&blob_atom[3+i*6], blob->x/img->width); - SETFLOAT(&blob_atom[4+i*6], blob->y/img->height); - SETFLOAT(&blob_atom[5+i*6], blob->w/img->width); - SETFLOAT(&blob_atom[6+i*6], blob->h/img->height); - SETFLOAT(&blob_atom[7+i*6], m_tracker->GetState(blob->ID)); - //~ t_atom *ap=blob_atom+2+6*i; - //~ SETFLOAT(ap++, blob->ID); - //~ SETFLOAT(ap++, blob->x/img->width); - //~ SETFLOAT(ap++, blob->y/img->height); - //~ SETFLOAT(ap++, blob->w/img->width); - //~ SETFLOAT(ap++, blob->h/img->height); - //~ SETFLOAT(ap++, m_tracker->GetState(blob->ID)); + if ( blob->w*blob->h/(img->width*img->height) > m_areaThreshold ){ + SETFLOAT(&blob_atom[2+i*6], blob->ID); + SETFLOAT(&blob_atom[3+i*6], blob->x/img->width); + SETFLOAT(&blob_atom[4+i*6], blob->y/img->height); + SETFLOAT(&blob_atom[5+i*6], blob->w/img->width); + SETFLOAT(&blob_atom[6+i*6], blob->h/img->height); + SETFLOAT(&blob_atom[7+i*6], m_tracker->GetState(blob->ID)); + } } outlet_anything(m_dataout, gensym("cvblob"), blob_atom_size, blob_atom); @@ -247,6 +243,7 @@ void pix_opencv_blobtrack :: obj_setupCallback(t_class *classPtr) CPPEXTERN_MSG (classPtr, "setParam", setParamMess); CPPEXTERN_MSG (classPtr, "getModule", getModuleMess); CPPEXTERN_MSG (classPtr, "setModule", setModuleMess); + CPPEXTERN_MSG1 (classPtr, "areaThreshold", areaThresholdMess, t_float); } ///////////////////////////////////////////////////////// @@ -422,6 +419,14 @@ void pix_opencv_blobtrack :: monitorStageMess(int arg) outlet_anything( m_dataout, gensym("monitorStage"), 1, &data_out); } +void pix_opencv_blobtrack :: areaThresholdMess(t_float arg) +{ + m_areaThreshold = arg; + t_atom data_out; + SETFLOAT(&data_out, m_areaThreshold); + outlet_anything( m_dataout, gensym("areaThreshold"), 1, &data_out); +} + void pix_opencv_blobtrack :: fgTrainFramesMess(int arg) { //~ m_FGTrainFrames = int(arg); diff --git a/pix_opencv_blobtrack.h b/pix_opencv_blobtrack.h index d1041be..d6b2ba4 100644 --- a/pix_opencv_blobtrack.h +++ b/pix_opencv_blobtrack.h @@ -2,8 +2,6 @@ LOG GEM - Graphics Environment for Multimedia - Threshold 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 @@ -31,9 +29,9 @@ LOG /*----------------------------------------------------------------- ------------------------------------------------------------------- CLASS - pix_opencv_blobtrack + pix_opencv_blobtrack - square pattern detector + advanced blob tracker KEYWORDS pix @@ -68,6 +66,7 @@ class GEM_EXTERN pix_opencv_blobtrack : public GemPixObj ////////// // Messages handling void monitorStageMess(int arg); + void areaThresholdMess(t_float arg); void fgTrainFramesMess(int arg); void printParamsMess(void); void getParamMess(t_symbol*s, int argc, t_atom*argv); // get available params or param value @@ -79,6 +78,7 @@ class GEM_EXTERN pix_opencv_blobtrack : public GemPixObj std::string m_fg_name, m_bd_name, m_bt_name, m_btgen_name, m_btpp_name, m_bta_name, m_bt_corr; int m_FGTrainFrames; int m_monitoring_stage; // 0 : input image, 1 : FG 3 : input with trackng info + t_float m_areaThreshold; int x_size, y_size; |