CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
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 our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In the function that sets the points of a RotatedRect, the types should be double in order to keep the precision when dealing with RotatedRects that are defined far from the origin. This commit solves the problem in some assertions from rotatedRectangleIntersection when dealing with rectangles far from origin.
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)*w
246801.6
4002340.2
>>> f = np.float64; cx - f(a)*h - f(b)*w; cy + f(b)*h - f(a)*w
246801.59334828143
4002340.119037186 |
Yes. When testing the code provided by @jbwintergest here: #19824:
when the function
This is the content of Before:
After:
When the function |
jenkins cn please retry a build |
@gasparitiago, thank you for the contribution! I wonder if you could also modify |
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. |
@vpisarev can you take a look at my last commit? |
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.
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!
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.
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 π
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 at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.