From 37f4e400e4a8a855a742af5b263e61cb9254182e Mon Sep 17 00:00:00 2001 From: abidrahmank Date: Mon, 24 Jun 2013 12:13:59 +0530 Subject: [PATCH] Added cv2.boxPoints() functionality to Python bindings (Feature #2023) http://www.code.opencv.org/issues/2023 eg: In [3]: box = ((10,10),(5,5),0) In [4]: cv2.boxPoints(box) Out[4]: array([[ 7.5, 12.5], [ 7.5, 7.5], [ 12.5, 7.5], [ 12.5, 12.5]], dtype=float32) --- modules/imgproc/include/opencv2/imgproc.hpp | 3 +++ modules/imgproc/src/rotcalipers.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index fcaf6a58e..6d6108872 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -1318,6 +1318,9 @@ CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false ); //! computes the minimal rotated rectangle for a set of points CV_EXPORTS_W RotatedRect minAreaRect( InputArray points ); +//! computes boxpoints +CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points); + //! computes the minimal enclosing circle for a set of points CV_EXPORTS_W void minEnclosingCircle( InputArray points, CV_OUT Point2f& center, CV_OUT float& radius ); diff --git a/modules/imgproc/src/rotcalipers.cpp b/modules/imgproc/src/rotcalipers.cpp index cc43732c2..98ae6df03 100644 --- a/modules/imgproc/src/rotcalipers.cpp +++ b/modules/imgproc/src/rotcalipers.cpp @@ -398,3 +398,10 @@ cvMinAreaRect2( const CvArr* array, CvMemStorage* /*storage*/ ) return (CvBox2D)rr; } +void cv::boxPoints(cv::RotatedRect box, OutputArray _pts) +{ + _pts.create(4, 2, CV_32F); + Mat pts = _pts.getMat(); + box.points((Point2f*)pts.data); +} +