1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #28043 from dkurt:d.kurtaev/convexHull_eps

Handle near-zero convexity in convexHull #28043

### Pull Request Readiness Checklist

resolves https://github.com/opencv/opencv/issues/21482
closes https://github.com/opencv/opencv/issues/14401

Also skip a code that determines orientation inside rotatingCalipers and rely on the order after convexHull

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
This commit is contained in:
Dmitry Kurtaev
2025-11-21 15:54:38 +08:00
committed by GitHub
parent c0364e4e31
commit 2cc5b69fd1
3 changed files with 48 additions and 9 deletions
+33
View File
@@ -1232,6 +1232,39 @@ TEST(minEnclosingPolygon, pentagon)
}
}
TEST(Imgproc_minAreaRect, reproducer_21482)
{
const int N = 4;
float pts_[N][2] = {
{ 188.8991f, 12.400669f },
{ 80.64467f, -49.644814f },
{ 469.59897f, 173.28242f },
{ 690.4597f, 299.86768f },
};
Mat contour(N, 1, CV_32FC2, (void*)pts_);
RotatedRect rr = cv::minAreaRect(contour);
EXPECT_TRUE(checkMinAreaRect(rr, contour)) << rr.center << " " << rr.size << " " << rr.angle;
EXPECT_NEAR(min(rr.size.width, rr.size.height), 0, 1e-5);
EXPECT_GE(max(rr.size.width, rr.size.height), 702);
}
TEST(Imgproc_minAreaRect, reproducer_21482_small_values)
{
const int N = 4;
float pts_[N][2] = { { 0.f, 0.f }, { 1e-4f, 0.f }, { 1e-4f, 1e-4f }, { 0.f, 1e-4f },};
Mat contour(N, 1, CV_32FC2, (void*)pts_);
RotatedRect rr = cv::minAreaRect(contour);
EXPECT_TRUE(checkMinAreaRect(rr, contour)) << rr.center << " " << rr.size << " " << rr.angle;
EXPECT_EQ(rr.size.width, 1e-4f);
EXPECT_EQ(rr.size.height, 1e-4f);
}
}} // namespace
/* End of file. */