aboutsummaryrefslogtreecommitdiff
path: root/pix_opencv_contours.cc
diff options
context:
space:
mode:
authorAntoine Villeret <avilleret@users.sourceforge.net>2013-01-10 12:16:41 +0000
committerAntoine Villeret <avilleret@users.sourceforge.net>2013-01-10 12:16:41 +0000
commit997720d18c09050619b00b652e18075a6f065f51 (patch)
tree2ae24c2dbda9fdb32849e20982246b4c9bf1b3a7 /pix_opencv_contours.cc
parent59eabc4c7f04473efcfd305b213d78c57a2de26b (diff)
- update build instructions
- add contour length to infos output of pix_opencv_contours svn path=/trunk/externals/pix_opencv/; revision=16850
Diffstat (limited to 'pix_opencv_contours.cc')
-rw-r--r--pix_opencv_contours.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/pix_opencv_contours.cc b/pix_opencv_contours.cc
index 6032d1b..d8f162d 100644
--- a/pix_opencv_contours.cc
+++ b/pix_opencv_contours.cc
@@ -149,7 +149,7 @@ void pix_opencv_contours :: processGrayImage(imageStruct &image)
t_atom*info;
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
+ // info for each contour : area, rotrect corner (8 float), rotrect center, rotrect size, rotation angle, number of segments, length of contour, other are reserved for future use
int count(0);
SETFLOAT(info+1, 20.);
int info_offset(2);
@@ -162,6 +162,7 @@ void pix_opencv_contours :: processGrayImage(imageStruct &image)
cv::RotatedRect rot_rect = cv::minAreaRect(m_contours[i]);
cv::Point2f corners[4];
rot_rect.points(corners);
+ double length = cv::arcLength(m_contours[i],true);
for (int j=0;j<4;j++) {
SETFLOAT(info+info_offset+j*2+1, corners[j].x/image.xsize);
SETFLOAT(info+info_offset+j*2+2, corners[j].y/image.ysize);
@@ -173,7 +174,7 @@ void pix_opencv_contours :: processGrayImage(imageStruct &image)
SETFLOAT(info+info_offset+12, rot_rect.size.height/image.xsize);
SETFLOAT(info+info_offset+13, rot_rect.angle);
SETFLOAT(info+info_offset+14, m_contours[i].size()); // number of points in segment
- SETFLOAT(info+info_offset+15, 0);
+ SETFLOAT(info+info_offset+15, (float) length);
SETFLOAT(info+info_offset+16, 0);
SETFLOAT(info+info_offset+17, 0);
SETFLOAT(info+info_offset+18, 0);