Test for Rect2f in Python.

pull/24919/head
Alexander Smorkalov 10 months ago
parent fefc7e3749
commit cb92974914
  1. 2
      modules/core/include/opencv2/core/types.hpp
  2. 8
      modules/python/test/test_misc.py

@ -558,7 +558,7 @@ public:
//! returns the minimal up-right integer rectangle containing the rotated rectangle
CV_WRAP Rect boundingRect() const;
//! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images
Rect_<float> boundingRect2f() const;
CV_WRAP Rect2f boundingRect2f() const;
//! returns the rectangle mass center
CV_PROP_RW Point2f center;
//! returns width and height of the rectangle

@ -608,6 +608,14 @@ class Arguments(NewOpenCVTests):
_, inter_pts = cv.rotatedRectangleIntersection(rect1, rect2)
self.assertLess(np.max(np.abs(inter_pts.reshape(-1, 2) - pts)), 1e-4)
def test_result_rotated_rect_boundingRect2f(self):
center = (0, 0)
size = (10, 10)
angle = 0
gold_box = (-5.0, -5.0, 10.0, 10.0)
rect1 = cv.RotatedRect(center, size, angle)
bbox = rect1.boundingRect2f()
self.assertEqual(gold_box, bbox)
def test_parse_to_rotated_rect_not_convertible(self):
for not_convertible in ([], (), np.array([]), (123, (45, 34), 1), {1: 2, 3: 4}, 123,

Loading…
Cancel
Save