The class represents rotated (i.e. not up-right) rectangles on a plane.
More...
#include <opencv2/core/types.hpp>
|
float | angle |
| returns the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle.
|
|
Point2f | center |
| returns the rectangle mass center
|
|
Size2f | size |
| returns width and height of the rectangle
|
|
The class represents rotated (i.e. not up-right) rectangles on a plane.
Each rectangle is specified by the center point (mass center), length of each side (represented by Size2f structure) and the rotation angle in degrees.
The sample below demonstrates how to use RotatedRect:
for (int i = 0; i < 4; i++)
{
line(test_image, vertices[i], vertices[(i+1)%4],
Scalar(0,255,0), 2);
}
imshow(
"rectangles", test_image);
n-dimensional dense array class
Definition mat.hpp:812
Template class for 2D rectangles.
Definition types.hpp:444
The class represents rotated (i.e. not up-right) rectangles on a plane.
Definition types.hpp:531
Rect boundingRect() const
returns the minimal up-right integer rectangle containing the rotated rectangle
void points(Point2f pts[]) const
RotatedRect()
default constructor
Scalar_< double > Scalar
Definition types.hpp:702
Point_< float > Point2f
Definition types.hpp:207
Size_< float > Size2f
Definition types.hpp:368
#define CV_8UC3
Definition interface.h:90
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
void rectangle(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a simple, thick, or filled up-right rectangle.
void putText(InputOutputArray img, const String &text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=LINE_8, bool bottomLeftOrigin=false)
Draws a text string.
void line(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a line segment connecting two points.
@ FONT_HERSHEY_SIMPLEX
normal size sans-serif font
Definition imgproc.hpp:901
- See also
- CamShift, fitEllipse, minAreaRect, CvBox2D
- Examples
- samples/cpp/camshiftdemo.cpp, samples/cpp/fitellipse.cpp, and samples/cpp/minarea.cpp.
◆ RotatedRect() [1/3]
cv::RotatedRect::RotatedRect |
( |
| ) |
|
Python: |
---|
| cv.RotatedRect( | | ) -> | <RotatedRect object> |
| cv.RotatedRect( | center, size, angle | ) -> | <RotatedRect object> |
| cv.RotatedRect( | point1, point2, point3 | ) -> | <RotatedRect object> |
◆ RotatedRect() [2/3]
cv::RotatedRect::RotatedRect |
( |
const Point2f & |
center, |
|
|
const Size2f & |
size, |
|
|
float |
angle |
|
) |
| |
Python: |
---|
| cv.RotatedRect( | | ) -> | <RotatedRect object> |
| cv.RotatedRect( | center, size, angle | ) -> | <RotatedRect object> |
| cv.RotatedRect( | point1, point2, point3 | ) -> | <RotatedRect object> |
full constructor
- Parameters
-
center | The rectangle mass center. |
size | Width and height of the rectangle. |
angle | The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. |
◆ RotatedRect() [3/3]
Python: |
---|
| cv.RotatedRect( | | ) -> | <RotatedRect object> |
| cv.RotatedRect( | center, size, angle | ) -> | <RotatedRect object> |
| cv.RotatedRect( | point1, point2, point3 | ) -> | <RotatedRect object> |
Any 3 end points of the RotatedRect. They must be given in order (either clockwise or anticlockwise).
◆ boundingRect()
Rect cv::RotatedRect::boundingRect |
( |
| ) |
const |
Python: |
---|
| cv.RotatedRect.boundingRect( | | ) -> | retval |
returns the minimal up-right integer rectangle containing the rotated rectangle
◆ boundingRect2f()
Rect2f cv::RotatedRect::boundingRect2f |
( |
| ) |
const |
Python: |
---|
| cv.RotatedRect.boundingRect2f( | | ) -> | retval |
returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images
◆ points() [1/2]
void cv::RotatedRect::points |
( |
Point2f |
pts[] | ) |
const |
Python: |
---|
| cv.RotatedRect.points( | | ) -> | pts |
returns 4 vertices of the rotated rectangle
- Parameters
-
pts | The points array for storing rectangle vertices. The order is bottomLeft, topLeft, topRight, bottomRight. |
- Note
- Bottom, Top, Left and Right sides refer to the original rectangle (angle is 0), so after 180 degree rotation bottomLeft point will be located at the top right corner of the rectangle.
- Examples
- samples/cpp/fitellipse.cpp, and samples/cpp/minarea.cpp.
◆ points() [2/2]
void cv::RotatedRect::points |
( |
std::vector< Point2f > & |
pts | ) |
const |
Python: |
---|
| cv.RotatedRect.points( | | ) -> | pts |
◆ angle
float cv::RotatedRect::angle |
returns the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle.
◆ center
◆ size
The documentation for this class was generated from the following file: