]> rtime.felk.cvut.cz Git - opencv.git/commitdiff
return absolute value of the contour area by default
authorvp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 26 Mar 2010 17:14:41 +0000 (17:14 +0000)
committervp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 26 Mar 2010 17:14:41 +0000 (17:14 +0000)
git-svn-id: https://code.ros.org/svn/opencv/trunk@2927 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08

opencv/include/opencv/cv.h
opencv/include/opencv/cv.hpp
opencv/samples/c/squares.c
opencv/src/cv/cvcontours.cpp
opencv/src/cv/cvshapedescr.cpp

index 8baf9f672a2bb3814419ee9fa3bd3aa40f49acb1..d7f6434992f9831c94d4acf7bdea107eb093a0f5 100644 (file)
@@ -729,7 +729,8 @@ CVAPI(CvRect)  cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
 
 /* Calculates area of a contour or contour segment */
 CVAPI(double)  cvContourArea( const CvArr* contour,
-                              CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ));
+                              CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
+                              int oriented CV_DEFAULT(0));
 
 /* Finds minimum area rotated rectangle bounding a set of points */
 CVAPI(CvBox2D)  cvMinAreaRect2( const CvArr* points,
index 6aaba501bb456b3d5221fbad888d43c65dc00a45..69699a201f25091dd1067f224e4e5ba7ffdb80a4 100644 (file)
@@ -534,7 +534,7 @@ CV_EXPORTS void approxPolyDP( const Mat& curve,
     
 CV_EXPORTS double arcLength( const Mat& curve, bool closed );
 CV_EXPORTS Rect boundingRect( const Mat& points );
-CV_EXPORTS double contourArea( const Mat& contour );    
+CV_EXPORTS double contourArea( const Mat& contour, bool oriented=false );    
 CV_EXPORTS RotatedRect minAreaRect( const Mat& points );
 CV_EXPORTS void minEnclosingCircle( const Mat& points,
                                     Point2f& center, float& radius );    
index 79f2b7b4412f3d22ea26055ad766f993c157c06d..9a5e7cef732f879a6c43409973e4752fc07ed5d4 100644 (file)
@@ -105,7 +105,7 @@ CvSeq* findSquares4( IplImage* img, CvMemStorage* storage )
                 // area may be positive or negative - in accordance with the
                 // contour orientation
                 if( result->total == 4 &&
-                    fabs(cvContourArea(result,CV_WHOLE_SEQ)) > 1000 &&
+                    cvContourArea(result,CV_WHOLE_SEQ,0) > 1000 &&
                     cvCheckContourConvexity(result) )
                 {
                     s = 0;
index c76d0c288bf6a76283c2fa88be71be765598a49e..55cf261c7a34f1264fddb4cb5495da853991ef82 100644 (file)
@@ -1670,14 +1670,14 @@ cv::Rect cv::boundingRect( const Mat& points )
 }
 
 
-double cv::contourArea( const Mat& contour )
+double cv::contourArea( const Mat& contour, bool oriented )
 {
     CV_Assert(contour.isContinuous() &&
               (contour.depth() == CV_32S || contour.depth() == CV_32F) &&
               ((contour.rows == 1 && contour.channels() == 2) ||
                contour.cols*contour.channels() == 2));
     CvMat _contour = contour;
-    return cvContourArea(&_contour);
+    return cvContourArea(&_contour, CV_WHOLE_SEQ, oriented);
 }
 
 
index fffa73320c836faafb1c0341b1a27fd8a8ffca51..02ee27271d716ab77deb9fa16fdf5ae146dc7533 100644 (file)
@@ -713,7 +713,7 @@ static CvStatus icvContourSecArea( CvSeq * contour, CvSlice slice, double *area
 
 /* external contour area function */
 CV_IMPL double
-cvContourArea( const void *array, CvSlice slice )
+cvContourArea( const void *array, CvSlice slice, int oriented )
 {
     double area = 0;
 
@@ -744,7 +744,7 @@ cvContourArea( const void *array, CvSlice slice )
         IPPI_CALL( icvContourSecArea( contour, slice, &area ));
     }
 
-    return area;
+    return oriented ? area : fabs(area);
 }