From 37f4e400e4a8a855a742af5b263e61cb9254182e Mon Sep 17 00:00:00 2001 From: abidrahmank Date: Mon, 24 Jun 2013 12:13:59 +0530 Subject: [PATCH 1/3] 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 fcaf6a58ee..6d61088724 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 cc43732c26..98ae6df034 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); +} + From bcf9117957a6c8e79e37761aa4734533db1e18fb Mon Sep 17 00:00:00 2001 From: abidrahmank Date: Mon, 24 Jun 2013 15:53:45 +0530 Subject: [PATCH 2/3] Added missing python functions in highgui documentation setMouseCallback createTrackbar --- modules/highgui/doc/user_interface.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/highgui/doc/user_interface.rst b/modules/highgui/doc/user_interface.rst index f84a04c21e..e4276718b1 100644 --- a/modules/highgui/doc/user_interface.rst +++ b/modules/highgui/doc/user_interface.rst @@ -9,6 +9,8 @@ Creates a trackbar and attaches it to the specified window. .. ocv:function:: int createTrackbar( const String& trackbarname, const String& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0) +.. ocv:pyfunction:: cv2.createTrackbar(trackbarName, windowName, value, count, onChange) -> None + .. ocv:cfunction:: int cvCreateTrackbar( const char* trackbar_name, const char* window_name, int* value, int count, CvTrackbarCallback on_change=NULL ) :param trackbarname: Name of the created trackbar. @@ -181,6 +183,8 @@ Sets mouse handler for the specified window .. ocv:function:: void setMouseCallback( const String& winname, MouseCallback onMouse, void* userdata=0 ) +.. ocv:pyfunction:: cv2.setMouseCallback(windowName, onMouse [, param]) -> None + .. ocv:cfunction:: void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* param=NULL ) :param winname: Window name From a1ea1a7ec5b013c3730400d80b609453065c9191 Mon Sep 17 00:00:00 2001 From: abidrahmank Date: Mon, 24 Jun 2013 16:17:23 +0530 Subject: [PATCH 3/3] boxpoints documentation --- ...ructural_analysis_and_shape_descriptors.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst index 6f7cba3a9a..136d3e3df4 100644 --- a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst +++ b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst @@ -522,6 +522,24 @@ The function calculates and returns the minimum-area bounding rectangle (possibl +boxPoints +----------- +Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle. + +.. ocv:function:: void boxPoints(RotatedRect box, OutputArray points) + +.. ocv:pyfunction:: cv2.boxPoints(box[, points]) -> points + +.. ocv:cfunction:: void cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] ) + + :param box: The input rotated rectangle. It may be the output of .. ocv:function:: minAreaRect. + + :param points: The output array of four vertices of rectangles. + +The function finds the four vertices of a rotated rectangle. This function is useful to draw the rectangle. In C++, instead of using this function, you can directly use box.points() method. Please visit the `tutorial on bounding rectangle `_ for more information. + + + minEnclosingCircle ---------------------- Finds a circle of the minimum area enclosing a 2D point set.