aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Villeret <avilleret@users.sourceforge.net>2012-12-19 08:35:19 +0000
committerAntoine Villeret <avilleret@users.sourceforge.net>2012-12-19 08:35:19 +0000
commitddae61c7ff97bd07967c257ef3e482465c2465ed (patch)
treed0ffdea0adccb1cb574be5696015374700e55d51
parentd8a6537813878b9f6d74b4c1ebfaaa219291fc3c (diff)
add zero padding to info outlet and number of segment for each contour
WARNING ! this breaks compatibility with previous versions !! svn path=/trunk/externals/pix_opencv/; revision=16703
-rw-r--r--pix_opencv_contours.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/pix_opencv_contours.cc b/pix_opencv_contours.cc
index 7c0bdc0..438d947 100644
--- a/pix_opencv_contours.cc
+++ b/pix_opencv_contours.cc
@@ -92,11 +92,11 @@ void pix_opencv_contours :: processGrayImage(imageStruct &image)
//~ cv::drawContours(imgMat2, m_contours, -1, cv::Scalar(128,255,255), 3);
t_atom*info;
- info = new t_atom[(int) m_contours.size()*14+2];
- // info : 14x(contour_nb) matrix
- // info for each contour : area, rotrect corner (8 float), rotrect center, rotrect size, rotation angle
+ info = new t_atom[(int) m_contours.size()*20+2];
+ // info : 20x(contour_nb) matrix
+ // info for each contour : area, rotrect corner (8 float), rotrect center, rotrect size, rotation angle, segments number, other are reserved for future use
int count(0);
- SETFLOAT(info+1, 14.);
+ SETFLOAT(info+1, 20.);
int info_offset(2);
for( std::vector<std::vector<cv::Point> >::iterator it = m_contours.begin(); it != m_contours.end(); ++it ) {
@@ -116,13 +116,19 @@ void pix_opencv_contours :: processGrayImage(imageStruct &image)
SETFLOAT(info+info_offset+11, rot_rect.size.width/image.xsize);
SETFLOAT(info+info_offset+12, rot_rect.size.height/image.xsize);
SETFLOAT(info+info_offset+13, rot_rect.angle);
+ SETFLOAT(info+info_offset+14, it->size()/2); // number of points in segment
+ SETFLOAT(info+info_offset+15, 0);
+ SETFLOAT(info+info_offset+16, 0);
+ SETFLOAT(info+info_offset+17, 0);
+ SETFLOAT(info+info_offset+18, 0);
+ SETFLOAT(info+info_offset+19, 0);
- info_offset+=14;
+ info_offset+=20;
count++;
}
}
SETFLOAT(info, (float) count);
- if (count) outlet_anything(m_dataout_right, gensym("info"), count*14+2, info);
+ if (count) outlet_anything(m_dataout_right, gensym("info"), count*20+2, info);
else outlet_float(m_dataout_right, 0);
for( std::vector<std::vector<cv::Point> >::iterator it = m_contours.begin(); it != m_contours.end(); ++it ) {