diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 638f97dfb..d98bd98d8 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -524,33 +524,6 @@ typedef Vec Vec4d; typedef Vec Vec6d; -/*! - The rotated 2D rectangle. - - The class represents rotated (i.e. not up-right) rectangles on a plane. - Each rectangle is described by the center point (mass center), length of each side - (represented by cv::Size2f structure) and the rotation angle in degrees. -*/ -class CV_EXPORTS RotatedRect -{ -public: - //! various constructors - RotatedRect(); - RotatedRect(const Point2f& center, const Size2f& size, float angle); - RotatedRect(const CvBox2D& box); - - //! returns 4 vertices of the rectangle - void points(Point2f pts[]) const; - //! returns the minimal up-right rectangle containing the rotated rectangle - Rect boundingRect() const; - //! conversion to the old-style CvBox2D structure - operator CvBox2D() const; - - Point2f center; //< the rectangle mass center - Size2f size; //< width and height of the rectangle - float angle; //< the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. -}; - //////////////////////////////// Scalar_ /////////////////////////////// /*! diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index ff36cc1ab..3dff3a2c6 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -1884,13 +1884,7 @@ template inline bool Point_<_Tp>::inside( const Rect_<_Tp>& r ) co inline RotatedRect::RotatedRect() { angle = 0; } inline RotatedRect::RotatedRect(const Point2f& _center, const Size2f& _size, float _angle) : center(_center), size(_size), angle(_angle) {} -inline RotatedRect::RotatedRect(const CvBox2D& box) - : center(box.center), size(box.size), angle(box.angle) {} -inline RotatedRect::operator CvBox2D() const -{ - CvBox2D box; box.center = center; box.size = size; box.angle = angle; - return box; -} + //////////////////////////////// Scalar_ /////////////////////////////// diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 4d4172bae..387ed0ce6 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -331,6 +331,38 @@ public: */ typedef Rect_ Rect; + + +///////////////////////////// RotatedRect ///////////////////////////// + +/*! + The rotated 2D rectangle. + + The class represents rotated (i.e. not up-right) rectangles on a plane. + Each rectangle is described by the center point (mass center), length of each side + (represented by cv::Size2f structure) and the rotation angle in degrees. +*/ +class CV_EXPORTS RotatedRect +{ +public: + //! various constructors + RotatedRect(); + RotatedRect(const Point2f& center, const Size2f& size, float angle); + + //! returns 4 vertices of the rectangle + void points(Point2f pts[]) const; + //! returns the minimal up-right rectangle containing the rotated rectangle + Rect boundingRect() const; + + Point2f center; //< the rectangle mass center + Size2f size; //< width and height of the rectangle + float angle; //< the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. +}; + + + + + } // cv #endif //__OPENCV_CORE_TYPES_HPP__ \ No newline at end of file diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index 4e15653ad..9c4c7e5dd 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -955,6 +955,12 @@ typedef struct CvBox2D CvSize2D32f size; /* Box width and length. */ float angle; /* Angle between the horizontal axis */ /* and the first side (i.e. length) in degrees */ + +#ifdef __cplusplus + CvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) : center(c), size(s), angle(a) {} + CvBox2D(const cv::RotatedRect& rr) : center(rr.center), size(rr.size), angle(rr.angle) {} + operator cv::RotatedRect() const { return cv::RotatedRect(center, size, angle); } +#endif } CvBox2D;