diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 591d50ade6..0e8091a54d 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -910,8 +910,10 @@ public: //! returns 4 vertices of the rectangle void points(Point2f pts[]) const; - //! returns the minimal up-right rectangle containing the rotated rectangle + //! returns the minimal up-right integer rectangle containing the rotated rectangle Rect boundingRect() const; + //! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images + Rect_ boundingRect2f() const; //! conversion to the old-style CvBox2D structure operator CvBox2D() const; diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 57abffc3ca..aee377f665 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -4277,6 +4277,16 @@ Rect RotatedRect::boundingRect() const return r; } + +Rect_ RotatedRect::boundingRect2f() const +{ + Point2f pt[4]; + points(pt); + Rect_ r(Point_(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)), + Point_(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))); + return r; +} + } /* End of file. */