better accuracy for _rotatedRectangleIntersection() (proposal for #23546)#23690
Conversation
…ad of float for better accuracy 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
dkurt
left a comment
There was a problem hiding this comment.
I do think that it might be overhead for this function. Is there a chance to find exact place where the corner points are missed? It seems to me that there is a logical bug somewhere rather than just precision issue.
I have logged all numeric values taken by the local variables of In I tried to reorder/change some computations to avoid accumulating too much error, but so far I could only get right results with |
|
Interesting : I tried to add in order to force the |
…le instead of float for better accuracy" This reverts commit 71d6f29.
forcing normalizationScale to be a power of 2 seems to be better for accuracy, since scaling by normalizationScale will result in a mere shift in exponent
|
@chacha21, can you please add a testcase from #23546 to https://github.com/opencv/opencv/blob/4.x/modules/imgproc/test/test_intersection.cpp? |
Added accuracy test for opencv#23546
Done, but now there is a regression with accuracy_21659. |
fixed regression with accuracy_21659
|
After the fix of |
…scale is no more useful" This reverts commit 025281a.
using adjustToZero(..., samePointEps) does not work, though, because samePointEps is not a fixed valeu and depend on the input. using adjustToZero(..., samePointEps) triggers regressions in test_intersection
by ordering the computation of s=A*x+B*y+C differently, it seems that normalizationScale and adjustToZero can just be get rid of
fixed commented code to understand code history
only the sign of A*x+B*y+C is important, so the code can be simplified to save one arithmetic operation, perhaps avoiding one more accuracy error accumulation
no changes in computations, just comments and refactoring as suggested for the sake of clarity
…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
…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
_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
Patch to opencv_extra has the same branch name.