cv::RotatedRect Class Reference 核心功能 » 基本结构


The class represents rotated (i.e. not up-right) rectangles on a plane. 更多...

#include <opencv2/core/types.hpp>

Public Member Functions

  RotatedRect ()
  default constructor 更多...
 
  RotatedRect (const Point2f & center , const Size2f & size , float angle )
 
  RotatedRect (const Point2f &point1, const Point2f &point2, const Point2f &point3)
 
Rect   boundingRect () const
  returns the minimal up-right integer rectangle containing the rotated rectangle 更多...
 
Rect_ < float >  boundingRect2f () const
  returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images 更多...
 
void  points ( Point2f pts[]) const
 

Public Attributes

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 :

Mat test_image(200, 200, CV_8UC3 , Scalar (0));
RotatedRect rRect = RotatedRect ( Point2f (100,100), Size2f (100,50), 30);
Point2f vertices[4];
rRect.points(vertices);
for ( int i = 0; i < 4; i++)
line (test_image, vertices[i], vertices[(i+1)%4], Scalar (0,255,0), 2);
Rect brect = rRect.boundingRect();
rectangle (test_image, brect, Scalar (255,0,0), 2);
imshow ( "rectangles" , test_image);
rotatedrect.png
image
另请参阅
CamShift , fitEllipse , minAreaRect , CvBox2D
范例:
samples/cpp/camshiftdemo.cpp , samples/cpp/fitellipse.cpp , samples/cpp/minarea.cpp ,和 samples/dnn/text_detection.cpp .

Constructor & Destructor Documentation

◆  RotatedRect() [1/3]

cv::RotatedRect::RotatedRect ( )

default constructor

◆  RotatedRect() [2/3]

cv::RotatedRect::RotatedRect ( const Point2f center ,
const Size2f size ,
float  angle  
)

full constructor

参数
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]

cv::RotatedRect::RotatedRect ( const Point2f point1 ,
const Point2f point2 ,
const Point2f point3  
)

Any 3 end points of the RotatedRect . They must be given in order (either clockwise or anticlockwise).

成员函数文档编制

◆  boundingRect()

Rect cv::RotatedRect::boundingRect ( ) const

returns the minimal up-right integer rectangle containing the rotated rectangle

◆  boundingRect2f()

Rect_ <float> cv::RotatedRect::boundingRect2f ( ) const

returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images

◆  points()

void cv::RotatedRect::points ( Point2f   pts [] ) const

returns 4 vertices of the rectangle

参数
pts The points array for storing rectangle vertices. The order is bottomLeft, topLeft, topRight, bottomRight.
范例:
samples/cpp/fitellipse.cpp , samples/cpp/minarea.cpp ,和 samples/dnn/text_detection.cpp .

Member Data Documentation

◆  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

Point2f cv::RotatedRect::center

returns the rectangle mass center

范例:
samples/cpp/fitellipse.cpp .

◆  size

Size2f cv::RotatedRect::size

returns width and height of the rectangle

范例:
samples/cpp/fitellipse.cpp .

The documentation for this class was generated from the following file: