cv::rotatedRectangleIntersection assertion failed.

asked 2015-10-29 16:09:03 -0600

moved gravatar image

Hi,

I'm working on finding the intersections between two rotatedRectangle.

RotatedRect r1 = RotatedRect(Point2f(1174.85852, 730.577332), Size2f(1318.08118, 400.503601), -2.31209111);
RotatedRect r2 = RotatedRect(Point2f(1172.80396, 728.535950), Size2f(1318.74963, 389.407377), -2.97718263);
vector<cv::Point2f> vertices;
int intersectionType = cv::rotatedRectangleIntersection(r1, r2, vertices);

then it throws this: OpenCV Error: Assertion failed (intersection.size() <= 8) in cv::rotatedRectangleIntersection, file ......, line 245 even if the verticies.size() is 6.

Strange thing is, it works fine in Debug mode, but it doesn't in Release mode... Can anyone help me?

Thanks in advance.

edit retag flag offensive close merge delete

Comments

os / bits / compiler / opencv version ?

(can't reproduce your problem)

berak gravatar imageberak ( 2015-10-30 02:26:21 -0600 )edit

Same problem ("error: (-215) intersection.size() <= 8 in function rotatedRectangleIntersection"). It seems rotatedRectangleIntersection fails when the two rectangles are very similar

Code:

#two rectangles defined as (midx,midy),(width,height), angle), almost superimposed
Rect1= ((633.5947875976562, 426.033447265625), (12.238635063171387, 86.6833267211914), -50.572174072265625)
Rect2= ((634.1143188476562, 425.833251953125), (13.197334289550781, 86.60831451416016), -53.923988342285156)
print ("FAILS>",cv2.rotatedRectangleIntersection(Rect1,Rect2))    #works if the values are rounded to 1 decimal place
ausbert gravatar imageausbert ( 2016-12-09 10:51:11 -0600 )edit

Replicated a couple dozen times (vs ~600k times where there was no problem). The intersection of 2 rectangles can be a point, line, or polygon with 3-8 sides. I suspect that given the "<=8" and the very similar rectangles, I would guess they are asserting the result has <=8 sides but they have a bug in an edge condition that erroneously is trying to return a ~9-sided polygon. every instance (so far) the problem does away if the vertices are rounded to 1 decimal place.

ausbert gravatar imageausbert ( 2016-12-09 13:54:19 -0600 )edit