Merge pull request #7754 from LAZI-2240:toupstream2.4

Introducing boundingRect2f() (#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
pull/7847/head
bedbad 8 years ago committed by Alexander Alekhin
parent 7be4a0ee2f
commit ffcf866e2f
  1. 4
      modules/core/include/opencv2/core/core.hpp
  2. 10
      modules/core/src/matrix.cpp

@ -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_<float> boundingRect2f() const;
//! conversion to the old-style CvBox2D structure
operator CvBox2D() const;

@ -4277,6 +4277,16 @@ Rect RotatedRect::boundingRect() const
return r;
}
Rect_<float> RotatedRect::boundingRect2f() const
{
Point2f pt[4];
points(pt);
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)),
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)));
return r;
}
}
/* End of file. */

Loading…
Cancel
Save