Move cv::RotatedRect

This commit is contained in:
Andrey Kamaev 2013-03-26 20:59:45 +04:00
parent 62adc01980
commit 93d76ac23f
4 changed files with 39 additions and 34 deletions

View File

@ -524,33 +524,6 @@ typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> 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_ ///////////////////////////////
/*!

View File

@ -1884,13 +1884,7 @@ template<typename _Tp> 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_ ///////////////////////////////

View File

@ -331,6 +331,38 @@ public:
*/
typedef Rect_<int> 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__

View File

@ -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;