From 9902affae6ee3f16be1958653684edb49cc2add4 Mon Sep 17 00:00:00 2001 From: Ovidiu Parvu Date: Thu, 12 Sep 2013 14:34:08 +0100 Subject: [PATCH] Added some assert statements to constrain the type of the input and output parameters. Convert the input set of points to vector before passing it to the findMinimumAreaEnclosingTriangle function. --- modules/imgproc/src/min_enclosing_triangle.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/min_enclosing_triangle.cpp b/modules/imgproc/src/min_enclosing_triangle.cpp index ccbbf973b2..640308515b 100644 --- a/modules/imgproc/src/min_enclosing_triangle.cpp +++ b/modules/imgproc/src/min_enclosing_triangle.cpp @@ -273,6 +273,8 @@ void cv::minEnclosingTriangle(cv::InputArray points, CV_OUT cv::OutputArray triangle, CV_OUT double& area) { std::vector resultingTriangle; + CV_Assert(triangle.getMat().depth() == CV_32F); + createConvexHull(points); findMinEnclosingTriangle(resultingTriangle, area); copyResultingTriangle(resultingTriangle, triangle); @@ -288,11 +290,14 @@ void cv::minEnclosingTriangle(cv::InputArray points, */ static void createConvexHull(cv::InputArray points) { cv::Mat pointsMat = points.getMat(); + std::vector pointsVector; CV_Assert((pointsMat.checkVector(2) > 0) && ((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