mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 13:13:26 +08:00
Added some assert statements to constrain the type of the input and output parameters. Convert the input set of points to vector<Point2f> before passing it to the findMinimumAreaEnclosingTriangle function.
This commit is contained in:
parent
4fce8e6b0e
commit
9902affae6
@ -273,6 +273,8 @@ void cv::minEnclosingTriangle(cv::InputArray points,
|
|||||||
CV_OUT cv::OutputArray triangle, CV_OUT double& area) {
|
CV_OUT cv::OutputArray triangle, CV_OUT double& area) {
|
||||||
std::vector<cv::Point2f> resultingTriangle;
|
std::vector<cv::Point2f> resultingTriangle;
|
||||||
|
|
||||||
|
CV_Assert(triangle.getMat().depth() == CV_32F);
|
||||||
|
|
||||||
createConvexHull(points);
|
createConvexHull(points);
|
||||||
findMinEnclosingTriangle(resultingTriangle, area);
|
findMinEnclosingTriangle(resultingTriangle, area);
|
||||||
copyResultingTriangle(resultingTriangle, triangle);
|
copyResultingTriangle(resultingTriangle, triangle);
|
||||||
@ -288,11 +290,14 @@ void cv::minEnclosingTriangle(cv::InputArray points,
|
|||||||
*/
|
*/
|
||||||
static void createConvexHull(cv::InputArray points) {
|
static void createConvexHull(cv::InputArray points) {
|
||||||
cv::Mat pointsMat = points.getMat();
|
cv::Mat pointsMat = points.getMat();
|
||||||
|
std::vector<cv::Point2f> pointsVector;
|
||||||
|
|
||||||
CV_Assert((pointsMat.checkVector(2) > 0) &&
|
CV_Assert((pointsMat.checkVector(2) > 0) &&
|
||||||
((pointsMat.depth() == CV_32F) || (pointsMat.depth() == CV_32S)));
|
((pointsMat.depth() == CV_32F) || (pointsMat.depth() == CV_32S)));
|
||||||
|
|
||||||
convexHull(points, polygon, true, true);
|
pointsMat.convertTo(pointsVector, CV_32F);
|
||||||
|
|
||||||
|
convexHull(pointsVector, polygon, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Find the minimum enclosing triangle and its area
|
//! Find the minimum enclosing triangle and its area
|
||||||
|
Loading…
Reference in New Issue
Block a user