-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
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
rotatedRectangleIntersection does not return all intersection points as expected #23546
Closed
4 tasks done
Labels
Milestone
Comments
Can confirm on 26a7b33 (green are rect1, rect2 and blue color is intersection): import numpy as np
import cv2 as cv
rect1 = cv.RotatedRect((824.6421183672817, 280.28737007069833), (565.0, 140.0), -177.80506896972656)
rect2 = cv.RotatedRect((567.3310438828003, 270.42527355719545), (275.0, 50.0), 92.19493103027344)
_, inter_pts = cv.rotatedRectangleIntersection(rect1, rect2)
img = np.zeros((512, 1200, 3), dtype=np.uint8)
cv.polylines(img, rect1.points().astype(np.int32).reshape(1, 4, 2), True, (0, 255, 0))
cv.polylines(img, rect2.points().astype(np.int32).reshape(1, 4, 2), True, (0, 255, 0))
cv.polylines(img, inter_pts.astype(np.int32).reshape(1, -1, 2), True, (255, 255, 0))
cv.imwrite("img.png", img) necessary changes with |
I have tried to use double precision instead of float precision in |
6 tasks
6 tasks
chacha21
added a commit
to chacha21/opencv
that referenced
this issue
May 26, 2023
Added accuracy test for opencv#23546
asmorkalov
pushed a commit
that referenced
this issue
May 30, 2023
…precision better accuracy for _rotatedRectangleIntersection() (proposal for #23546) #23690 _rotatedRectangleIntersection() can be (statically) customized to use double instead of float for better accuracy this is a proposal for experimentation around #23546 for better accuracy, _rotatedRectangleIntersection() could use double. It will still return cv::Point2f list for backward compatibility, but the inner computations are controlled by a typedef - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
asmorkalov
pushed a commit
that referenced
this issue
Jun 22, 2023
Python binding for RotatedRect #23702 ### Pull Request Readiness Checklist related: #23546 (comment) See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
thewoz
pushed a commit
to thewoz/opencv
that referenced
this issue
Jan 4, 2024
…ction_precision better accuracy for _rotatedRectangleIntersection() (proposal for opencv#23546) opencv#23690 _rotatedRectangleIntersection() can be (statically) customized to use double instead of float for better accuracy this is a proposal for experimentation around opencv#23546 for better accuracy, _rotatedRectangleIntersection() could use double. It will still return cv::Point2f list for backward compatibility, but the inner computations are controlled by a typedef - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
thewoz
pushed a commit
to thewoz/opencv
that referenced
this issue
Jan 4, 2024
Python binding for RotatedRect opencv#23702 ### Pull Request Readiness Checklist related: opencv#23546 (comment) See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
thewoz
pushed a commit
to thewoz/opencv
that referenced
this issue
May 29, 2024
…ction_precision better accuracy for _rotatedRectangleIntersection() (proposal for opencv#23546) opencv#23690 _rotatedRectangleIntersection() can be (statically) customized to use double instead of float for better accuracy this is a proposal for experimentation around opencv#23546 for better accuracy, _rotatedRectangleIntersection() could use double. It will still return cv::Point2f list for backward compatibility, but the inner computations are controlled by a typedef - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
thewoz
pushed a commit
to thewoz/opencv
that referenced
this issue
May 29, 2024
Python binding for RotatedRect opencv#23702 ### Pull Request Readiness Checklist related: opencv#23546 (comment) See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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 thencontourArea
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.
RotatedRect(center=(824.6421183672817, 280.28737007069833), extent=(565.0, 140.0), angle=-177.80506896972656)
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
Issue submission checklist
The text was updated successfully, but these errors were encountered: