Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Update rotatedRectangleIntersection function to calculate near to origin#19842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In the function that sets the points of a RotatedRect, the typesshould be double in order to keep the precision when dealing withRotatedRects that are defined far from the origin.This commit solves the problem in some assertions fromrotatedRectangleIntersection when dealing with rectangles far fromorigin.
crackwitz commentedApr 3, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
does this actually make a difference? it only applies double precision to the calculation itself but the result is still just FP32. the demo code uses values like 4002326. there is simply not enough precision to go around (6-7 digits). >>> [cx,cy,w,h,angle]=np.float32([246805.033 ,4002326.94 ,26.40587,6.20026,-62.10156])>>>_angle=angle*pi/180>>>a=np.sin(_angle)*0.5>>>b=np.cos(_angle)*0.5>>>f=np.float32;cx-f(a)*h-f(b)*w;cy+f(b)*h-f(a)*w246801.64002340.2>>>f=np.float64;cx-f(a)*h-f(b)*w;cy+f(b)*h-f(a)*w246801.593348281434002340.119037186 |
gasparitiago commentedApr 3, 2021
Yes. When testing the code provided by @jbwintergest here:#19824: when the function This is the content of Before: After: When the function |
crackwitz commentedApr 3, 2021
asenyaev commentedApr 8, 2021
jenkins cn please retry a build |
vpisarev commentedJun 6, 2021
@gasparitiago, thank you for the contribution! I wonder if you could also modify |
gasparitiago commentedJun 6, 2021
Hello@vpisarev, I'm doing it. When I finish I will update this PR and let you know. To be honest I will need some help on how to test the solution. |
gasparitiago commentedJun 6, 2021
@vpisarev can you take a look at my last commit? |
Uh oh!
There was an error while loading.Please reload this page.
This commit changes the rotatedRectangleIntersection function in orderto calculate the intersection of two rectangles considering that theyare shifted near the coordinates origin (0, 0).This commit solves the problem in some assertions fromrotatedRectangleIntersection when dealing with rectangles far fromorigin.
alalek left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for update!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
alalek left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good!
Please update PR's title and description before merge.
Uh oh!
There was an error while loading.Please reload this page.
alalek left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for contribution 👍

Uh oh!
There was an error while loading.Please reload this page.
This commit changes the rotatedRectangleIntersection function in order to calculate the intersection of two rectangles considering that they are shifted near the coordinates origin (0, 0).
This commit solves the problem in some assertions from rotatedRectangleIntersection when dealing with rectangles far from origin.
Original issue:#19824
Pull Request Readiness Checklist
See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.