From f8fceccb7fecde32923dbe46693e99ee09b89525 Mon Sep 17 00:00:00 2001 From: Antoine Villeret Date: Sun, 13 Jul 2014 13:58:17 +0000 Subject: fix build on MacOSX improve help patch (contours) svn path=/trunk/externals/pix_opencv/; revision=17329 --- src/pix_opencv_contours.cc | 71 ++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 46 deletions(-) (limited to 'src/pix_opencv_contours.cc') diff --git a/src/pix_opencv_contours.cc b/src/pix_opencv_contours.cc index bf4410d..23d470e 100644 --- a/src/pix_opencv_contours.cc +++ b/src/pix_opencv_contours.cc @@ -35,7 +35,6 @@ CPPEXTERN_NEW(pix_opencv_contours) // ///////////////////////////////////////////////////////// pix_opencv_contours :: pix_opencv_contours() : \ - m_repeat_point(1), \ m_epsilon(2), \ m_enable_contours(1), \ m_enable_hulls(1), \ @@ -301,7 +300,6 @@ void pix_opencv_contours :: obj_setupCallback(t_class *classPtr) CPPEXTERN_MSG1(classPtr, "hierarchy_level", hierarchyMess, double); CPPEXTERN_MSG1(classPtr, "taboutput", taboutputMess, float); CPPEXTERN_MSG3(classPtr, "settab", tableMess, t_symbol*, t_symbol*, t_symbol*); - CPPEXTERN_MSG1(classPtr, "repeat_point", repeat_pointMess, float); } void pix_opencv_contours :: outputCount(){ @@ -309,7 +307,7 @@ void pix_opencv_contours :: outputCount(){ for( size_t i = 0 ; i < m_contours.size(); i++ ){ m_totalPointsCount+=m_contours[i].size(); } - m_totalPointsCount+=m_contours.size()*m_repeat_point*2; // add 2 points for each contour (on start and end) + m_totalPointsCount+=m_contours.size()*2; // add 2 points for each contour (on start and end) t_atom count_atom[2]; SETFLOAT(count_atom, m_contours.size()); @@ -369,7 +367,7 @@ void pix_opencv_contours :: outputBlobs(imageStruct &image){ apt2+=2; } - SETFLOAT(apt+15, m_contours[i].size()+m_repeat_point*2); // number of points in segment + SETFLOAT(apt+15, m_contours[i].size()); // number of points in segment SETFLOAT(apt+16, (float) length); } } @@ -390,38 +388,25 @@ void pix_opencv_contours :: outputContours(imageStruct &image){ { if (!m_contours[i].empty() && m_contours[i].size() > 2) { - int size = 2+(m_repeat_point*2+m_contours[i].size())*2; + int size = 2+2*m_contours[i].size(); t_atom*acontours = new t_atom[size]; t_atom* apt=acontours; - SETFLOAT(apt, static_cast(m_repeat_point*2+m_contours[i].size())); + SETFLOAT(apt, static_cast(m_contours[i].size())); SETFLOAT(apt+1, 2.0); apt+=2; - - for ( size_t j = 0 ; j < m_repeat_point ; j++){ - cv::Point pt = m_contours[i][0]; - SETFLOAT(apt, (float) pt.x/image.xsize); - SETFLOAT(apt+1,(float) pt.y/image.ysize); - apt+=2; - } - - for ( size_t j = 1 ; j < m_contours[i].size() ; j++){ + + size_t j; + for ( j = 0 ; j < m_contours[i].size() ; j++){ cv::Point pt = m_contours[i][j]; SETFLOAT(apt,(float) pt.x/image.xsize); SETFLOAT(apt+1,(float) pt.y/image.ysize); apt+=2; } - - for ( size_t j = 0 ; j < m_repeat_point ; j++){ - cv::Point pt = m_contours[i][0]; // repeat the first point to close the contour - SETFLOAT(apt, (float) pt.x/image.xsize); - SETFLOAT(apt+1,(float) pt.y/image.ysize); - apt+=2; - } - + outlet_anything(m_dataout_middle, gensym("contour"), size, acontours); if(acontours) { - delete acontours; + delete[] acontours; acontours=NULL; } } @@ -436,7 +421,7 @@ void pix_opencv_contours :: outputContours(imageStruct &image){ return; } - int vecxsize(0), vecysize(0), veczsize(0); + int vecxsize(0), vecysize(0), veczsize(0), vecsize(0); t_garray *ax, *ay, *az; t_word *vecx, *vecy, *vecz; @@ -487,11 +472,13 @@ void pix_opencv_contours :: outputContours(imageStruct &image){ } } + vecsize=min(min(vecxsize,vecysize),veczsize); + int n=0; for( size_t i = 0 ; i < m_contours.size(); i++ ) { - if (n >= vecxsize || n>=vecysize || n>=veczsize) + if ( n >= vecsize ) { error("array are not wide enough"); break; @@ -501,14 +488,12 @@ void pix_opencv_contours :: outputContours(imageStruct &image){ cv::Point pt; pt = m_contours[i][0]; //~ start with blank point - for (j=0; j 0; } -void pix_opencv_contours :: repeat_pointMess(float arg) -{ - m_repeat_point = arg > 1 ? arg : 1; -} - void pix_opencv_contours :: tableMess(t_symbol*xarray, t_symbol*yarray, t_symbol*zarray) { // check if arrays exist -- cgit v1.2.1