-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Assertion error when running rotatedRectangleIntersection #19824
Copy link
Copy link
Closed
Labels
Milestone
Description
System information (version)
- OpenCV => 4.2.0.34 / 4.5.1.48 (python)
- Operating System / Platform => Ubuntu 20.04 (linux 5.8.0-48-generic), x86_64
- Compiler => N/A
Detailed description
OpenCV is throwing an assertion error when running rotatedRectangleIntersection:
cv2.error: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/intersection.cpp:271: error: (-215:Assertion failed) fabs(normL2Sqr<float>(intersection[minI] - intersection[minJ]) - minD) < 1e-6 in function 'rotatedRectangleIntersection'
Issue has been discussed on the OpenCV forum here.
TL;DR
Assertion error is solved by applying an offset to bring the rectangles closer to the (0, 0), which implies that maybe it is linked to the rectangle being "far away".
Steps to reproduce
import cv2 as cv
import numpy as np
def box(box):
return ((box[0], box[1]), (box[2], box[3]), box[4])
box_1 = np.array([ 246805.033 , 4002326.94 , 26.40587, 6.20026, -62.10156])
box_2 = np.array([ 246805.122 , 4002326.59 , 27.4821 , 8.5361 , -56.33761])
try:
print(cv.rotatedRectangleIntersection(box(box_1), box(box_2))) # Assertion error
except Exception as e:
print(e)
offset = (246805, 4002326, 0, 0, 0)
box_1 -= offset
box_2 -= offset
print(cv.rotatedRectangleIntersection(box(box_1), box(box_2))) # that worksIssue 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 solution - I updated to 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