Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Embed: (wiki syntax)

« Back to documentation index

RotatedRect Class Reference

RotatedRect Class Reference
[Basic structures]

The class represents rotated (i.e. More...

#include <types.hpp>

Public Member Functions

 RotatedRect ()
 various constructors
 RotatedRect (const Point2f &center, const Size2f &size, float angle)
 RotatedRect (const Point2f &point1, const Point2f &point2, const Point2f &point3)
 Any 3 end points of the RotatedRect.
void points (Point2f pts[]) const
 returns 4 vertices of the rectangle
Rect boundingRect () const
 returns the minimal up-right rectangle containing the rotated rectangle

Detailed Description

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 cv::Size2f structure) and the rotation angle in degrees.

The sample below demonstrates how to use RotatedRect:

    Mat 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(image, vertices[i], vertices[(i+1)%4], Scalar(0,255,0));

    Rect brect = rRect.boundingRect();
    rectangle(image, brect, Scalar(255,0,0));

    imshow("rectangles", image);
    waitKey(0);

![image](pics/rotatedrect.png)

See also:
CamShift, fitEllipse, minAreaRect, CvBox2D

Definition at line 457 of file types.hpp.


Constructor & Destructor Documentation

RotatedRect (  )

various constructors

RotatedRect ( const Point2f center,
const Size2f size,
float  angle 
)
Parameters:
centerThe rectangle mass center.
sizeWidth and height of the rectangle.
angleThe rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle.
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).

Definition at line 5461 of file matrix.cpp.


Member Function Documentation

Rect boundingRect (  ) const

returns the minimal up-right rectangle containing the rotated rectangle

Definition at line 5501 of file matrix.cpp.

void points ( Point2f  pts[] ) const

returns 4 vertices of the rectangle

Parameters:
ptsThe points array for storing rectangle vertices.

Definition at line 5485 of file matrix.cpp.