Commit 8bada4c7 authored by Ovidiu Parvu's avatar Ovidiu Parvu

Overloaded the minEnclosingTriangle function such that there is an alternative…

Overloaded the minEnclosingTriangle function such that there is an alternative function with the same name which does not require the output parameter ``area''.
Changed the sample source file minarea.cpp to use the overloaded version of the function.
Updated some comments in the min_enclosing_triangle.cpp source file.
parent 0ed2f620
......@@ -1451,6 +1451,10 @@ 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 );
......
......@@ -170,6 +170,9 @@ static bool findGammaIntersectionPoints(unsigned int polygonPointIndex, const cv
const cv::Point2f &side2EndVertex, cv::Point2f &intersectionPoint1,
cv::Point2f &intersectionPoint2);
static void findMinEnclosingTriangle(cv::InputArray points,
CV_OUT cv::OutputArray triangle, CV_OUT double& area);
static void findMinEnclosingTriangle(std::vector<cv::Point2f> &triangle, double& area);
static void findMinimumAreaEnclosingTriangle(std::vector<cv::Point2f> &triangle, double &area);
......@@ -262,15 +265,39 @@ static void updateSidesCA();
//! Find the minimum enclosing triangle and its area for the given set of points
/*!
* The overall complexity of the algorithm is theta(n) where "n" represents the number
* of vertices in the convex hull of the points
*
* @param points Set of points
* @param triangle Minimum area triangle enclosing the given polygon
* @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) {
findMinEnclosingTriangle(points, triangle, area);
}
//! 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
*/
void cv::minEnclosingTriangle(cv::InputArray points,
CV_OUT cv::OutputArray triangle) {
double area;
findMinEnclosingTriangle(points, triangle, area);
}
/////////////////////////////// Helper functions definition //////////////////////////////
//! Find the minimum enclosing triangle and its area
/*!
* @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
*/
static void findMinEnclosingTriangle(cv::InputArray points,
CV_OUT cv::OutputArray triangle, CV_OUT double& area) {
std::vector<cv::Point2f> resultingTriangle;
CV_Assert(triangle.depth() == CV_32F);
......@@ -280,10 +307,6 @@ void cv::minEnclosingTriangle(cv::InputArray points,
copyResultingTriangle(resultingTriangle, triangle);
}
/////////////////////////////// Helper functions definition //////////////////////////////
//! Create the convex hull of the given set of points
/*!
* @param points The provided set of points
......@@ -319,12 +342,20 @@ static void findMinEnclosingTriangle( std::vector<cv::Point2f> &triangle, double
}
//! Copy resultingTriangle to the OutputArray triangle
/*!
* @param resultingTriangle Minimum area triangle enclosing the given polygon found by the algorithm
* @param triangle Minimum area triangle enclosing the given polygon return to the user
*/
static void copyResultingTriangle(const std::vector<cv::Point2f> &resultingTriangle,
cv::OutputArray triangle) {
cv::Mat(resultingTriangle).convertTo(triangle, triangle.fixedType() ? triangle.type() : CV_32F);
}
//! Initialisation function
/*!
* @param triangle Minimum area triangle enclosing the given polygon
* @param area Area of the minimum area enclosing triangle
*/
static void initialise(std::vector<cv::Point2f> &triangle, double &area) {
nrOfPoints = static_cast<unsigned int>(polygon.size());
area = std::numeric_limits<double>::max();
......
......@@ -44,9 +44,8 @@ int main( int /*argc*/, char** /*argv*/ )
// Find the minimum area enclosing triangle
vector<Point2f> triangle;
double area;
minEnclosingTriangle(points, triangle, area);
minEnclosingTriangle(points, triangle);
// Find the minimum area enclosing circle
Point2f center, vtx[4];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment