-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
rotatedRectangleIntersection does not return all intersection points as expected #23546
Copy link
Copy link
Closed
Labels
bugcategory: imgprocconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation complete
Milestone
Description
System Information
OpenCV python version: 4.7.0
Operating System / Platform: Windows 10
Python version: 3.10.10
Detailed description
During some testing of a system that used rotatedRectangleIntersection and then contourArea to get the intersection area of 2 overlapping rectangles, we got a size of ~3500mm² instead of the expected ~7000mm².
It seems to be related to the fact that one edge of each rectangle are on the same line.
- Rectangle 1:
RotatedRect(center=(824.6421183672817, 280.28737007069833), extent=(565.0, 140.0), angle=-177.80506896972656) - Rectangle 2:
RotatedRect(center=(567.3310438828003, 270.42527355719545), extent=(275.0, 50.0), angle=92.19493103027344)
This seems related to #21659, which should be fixed by #21677, but I haven't tested that as it hasn't been released.
Steps to reproduce
import cv2 as cv
res, points = cv.rotatedRectangleIntersection(
((824.6421183672817, 280.28737007069833), (565.0, 140.0), -177.80506896972656),
((567.3310438828003, 270.42527355719545), (275.0, 50.0), 92.19493103027344),
)
assert res == 1
assert points is not None
points = points.reshape(-1, 2)
area = cv.contourArea(points)
print(area) # expected ~7000, got ~3500Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugcategory: imgprocconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation complete