Table 3-5. Overloaded operators that take objects of type cv::Rect
Intersection of rectangles r1
and r2
cv::Rect r3 = r1 & r2;
r1 &= r2;
Minimum area rectangle
containing rectangles r1 and
r2
cv::Rect r3 = r1 | r2;
r1 |= r2;
Translate rectangle r by an
amount x
cv::Rect rx = r + v; // v is a cv::Point2i
r += v;
Enlarge a rectangle r by an
amount given by size s
cv::Rect rs = r + s; // s is a cv::Point2i
r += s;
Compare rectangles r1 and r2
for exact equality
Compare rectangles r1 and r2
for inequality
class cv::RotatedRect
The cv::RotatedRect class is one of the few classes in the C++ OpenCV interface that is not a
template underneath. It is a container, which holds a cv::Point2f called center, a cv::Size2f
called size, and one additional float called angle, with the latter representing the rotation of the
rectangle around center. One very important difference between cv::RotatedRect and cv::Rect
is the convention that a cv::RotatedRect is located in “space” relative to its center, while the
cv::Rect is located relative to its upper-left corner.
Table 3-6: Operations supported directly by class cv::RotatedRect
cv::RotatedRect rr2( rr1 );
Construct from two corners
cv::RotatedRect( p1, p2 );
Value constructors; takes a
point, a size, and an angle
cv::RotatedRect rr( p, sz, theta ) ;