diff --git a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst index 7dc3ef0b2..094424178 100644 --- a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst +++ b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst @@ -562,15 +562,11 @@ The function finds the four vertices of a rotated rectangle. This function is us minEnclosingTriangle ---------------------- -Finds a triangle of minimum area enclosing a 2D point set. +Finds a triangle of minimum area enclosing a 2D point set and returns its area. -.. ocv:function:: void minEnclosingTriangle( InputArray points, OutputArray triangle ) +.. ocv:function:: double minEnclosingTriangle( InputArray points, OutputArray triangle ) -.. ocv:function:: void minEnclosingTriangle( InputArray points, OutputArray triangle, double &area ) - -.. ocv:pyfunction:: cv2.minEnclosingTriangle(points[, triangle]) -> triangle - -.. ocv:pyfunction:: cv2.minEnclosingTriangle(points[, triangle]) -> triangle, area +.. ocv:pyfunction:: cv2.minEnclosingTriangle(points[, triangle]) -> retval, triangle :param points: Input vector of 2D points with depth ``CV_32S`` or ``CV_32F``, stored in: @@ -580,9 +576,7 @@ Finds a triangle of minimum area enclosing a 2D point set. :param triangle: Output vector of three 2D points defining the vertices of the triangle. The depth of the OutputArray must be ``CV_32F``. - :param area: The area of the minimum enclosing triangle. - -The output for a given 2D point set is shown in the image below. The 2D points are depicted in *red* and the enclosing triangle in *yellow*. +The function finds a triangle of minimum area enclosing the given set of 2D points and returns its area. The output for a given 2D point set is shown in the image below. 2D points are depicted in *red* and the enclosing triangle in *yellow*. .. image:: pics/minenclosingtriangle.png :height: 250px diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index cb3713af8..cc64174cf 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -1451,13 +1451,8 @@ CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points); CV_EXPORTS_W void minEnclosingCircle( InputArray points, CV_OUT Point2f& center, CV_OUT float& radius ); -//! computes the minimal enclosing triangle for a set of points -CV_EXPORTS_W void minEnclosingTriangle( InputArray points, - CV_OUT OutputArray triangle ); - -//! computes the minimal enclosing triangle for a set of points -CV_EXPORTS_W void minEnclosingTriangle( InputArray points, - CV_OUT OutputArray triangle, CV_OUT double& area ); +//! computes the minimal enclosing triangle for a set of points and returns its area +CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray triangle ); //! matches two contours using one of the available algorithms CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2, diff --git a/modules/imgproc/src/min_enclosing_triangle.cpp b/modules/imgproc/src/min_enclosing_triangle.cpp index a952fe46e..df2d75490 100644 --- a/modules/imgproc/src/min_enclosing_triangle.cpp +++ b/modules/imgproc/src/min_enclosing_triangle.cpp @@ -269,27 +269,17 @@ static void updateSidesCA(); ///////////////////////////////////// Main functions ///////////////////////////////////// -//! Find the minimum enclosing triangle and its area for the given set of points -/*! -* @param points Set of points -* @param triangle Minimum area triangle enclosing the given set of points -* @param area Area of the minimum area enclosing triangle -*/ -void cv::minEnclosingTriangle(cv::InputArray points, - CV_OUT cv::OutputArray triangle, CV_OUT double &area) { - minEnclosingTriangle::findMinEnclosingTriangle(points, triangle, area); -} - -//! Find the minimum enclosing triangle and its area for the given set of points +//! Find the minimum enclosing triangle for the given set of points and return its area /*! * @param points Set of points * @param triangle Minimum area triangle enclosing the given set of points */ -void cv::minEnclosingTriangle(cv::InputArray points, - CV_OUT cv::OutputArray triangle) { +double cv::minEnclosingTriangle(cv::InputArray points, CV_OUT cv::OutputArray triangle) { double area; minEnclosingTriangle::findMinEnclosingTriangle(points, triangle, area); + + return area; } diff --git a/modules/imgproc/test/test_convhull.cpp b/modules/imgproc/test/test_convhull.cpp index 7e1f02bb1..9e4cd07c4 100644 --- a/modules/imgproc/test/test_convhull.cpp +++ b/modules/imgproc/test/test_convhull.cpp @@ -801,7 +801,6 @@ protected: std::vector convexPolygon; std::vector triangle; - double area; }; @@ -827,7 +826,7 @@ void CV_MinTriangleTest::run_func() cv::cvarrToMat(points).convertTo(pointsAsVector, CV_32F); - cv::minEnclosingTriangle(pointsAsVector, triangle, area); + cv::minEnclosingTriangle(pointsAsVector, triangle); cv::convexHull(pointsAsVector, convexPolygon, true, true); }