Skip to content

Commit ffcf866

Browse files
ia113alalek
authored andcommitted
Merge pull request opencv#7754 from LAZI-2240:toupstream2.4
Introducing boundingRect2f() (opencv#7754) * Introducing boundingRect2f to return exact bounding float rectangle for RotatedRect * Introducing boundingRect2f to return exact bounding float rectangle for RotatedRect * Introducing boundingRect2f() - update * Introducing boundingRect2f to return exact bounding float rectangle for RotatedRect * Introducing boundingRect2f() - update - tested
1 parent 7be4a0e commit ffcf866

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

modules/core/include/opencv2/core/core.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,10 @@ class CV_EXPORTS RotatedRect
910910

911911
//! returns 4 vertices of the rectangle
912912
void points(Point2f pts[]) const;
913-
//! returns the minimal up-right rectangle containing the rotated rectangle
913+
//! returns the minimal up-right integer rectangle containing the rotated rectangle
914914
Rect boundingRect() const;
915+
//! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images
916+
Rect_<float> boundingRect2f() const;
915917
//! conversion to the old-style CvBox2D structure
916918
operator CvBox2D() const;
917919

modules/core/src/matrix.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,6 +4277,16 @@ Rect RotatedRect::boundingRect() const
42774277
return r;
42784278
}
42794279

4280+
4281+
Rect_<float> RotatedRect::boundingRect2f() const
4282+
{
4283+
Point2f pt[4];
4284+
points(pt);
4285+
Rect_<float> r(Point_<float>(min(min(min(pt[0].x, pt[1].x), pt[2].x), pt[3].x), min(min(min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
4286+
Point_<float>(max(max(max(pt[0].x, pt[1].x), pt[2].x), pt[3].x), max(max(max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
4287+
return r;
4288+
}
4289+
42804290
}
42814291

42824292
/* End of file. */

0 commit comments

Comments
 (0)