Changed the signature of the minEnclosingTriangle function such that it returns the area automatically. Moreover, the overloaded function was no longer required so it was removed. Sample code, documentation and unit tests were updated correspondingly.

pull/1470/head
Ovidiu Parvu 11 years ago
parent 52cdae6e2b
commit e324446c70
  1. 14
      modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst
  2. 9
      modules/imgproc/include/opencv2/imgproc.hpp
  3. 18
      modules/imgproc/src/min_enclosing_triangle.cpp
  4. 3
      modules/imgproc/test/test_convhull.cpp

@ -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

@ -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,

@ -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;
}

@ -801,7 +801,6 @@ protected:
std::vector<cv::Point2f> convexPolygon;
std::vector<cv::Point2f> 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);
}

Loading…
Cancel
Save