diff --git a/modules/imgproc/test/test_fitellipse_ams.cpp b/modules/imgproc/test/test_fitellipse_ams.cpp index a4c51fae5198..92e7f2e7a214 100644 --- a/modules/imgproc/test/test_fitellipse_ams.cpp +++ b/modules/imgproc/test/test_fitellipse_ams.cpp @@ -8,6 +8,25 @@ namespace opencv_test { namespace { +static bool checkEllipse(const RotatedRect& ellipseAMSTest, const RotatedRect& ellipseAMSTrue, const float tol) { + Point2f ellipseAMSTrueVertices[4]; + Point2f ellipseAMSTestVertices[4]; + ellipseAMSTest.points(ellipseAMSTestVertices); + ellipseAMSTrue.points(ellipseAMSTrueVertices); + float AMSDiff = 0.0f; + for (size_t i=0; i <=3; i++) { + Point2f diff = ellipseAMSTrueVertices[i] - ellipseAMSTestVertices[0]; + float d = diff.x * diff.x + diff.y * diff.y; + for (size_t j=1; j <=3; j++) { + diff = ellipseAMSTrueVertices[i] - ellipseAMSTestVertices[j]; + float dd = diff.x * diff.x + diff.y * diff.y; + if(ddpts; pts.push_back(Point2f(173.41854895999165f, 125.84473135880411f)); @@ -51,29 +70,12 @@ TEST(Imgproc_FitEllipseAMS_Issue_1, accuracy) { pts.push_back(Point2f(6.719616410428614f, 50.15263031354927f)); pts.push_back(Point2f(5.122267598477748f, 46.03603214691343f)); - bool AMSGoodQ; float tol = 0.01f; RotatedRect ellipseAMSTrue = cv::RotatedRect(Point2f(94.4037f, 84.743f), Size2f(190.614f, 153.543f), 19.832f); RotatedRect ellipseAMSTest = fitEllipseAMS(pts); - Point2f ellipseAMSTrueVertices[4]; - Point2f ellipseAMSTestVertices[4]; - ellipseAMSTest.points(ellipseAMSTestVertices); - ellipseAMSTrue.points(ellipseAMSTrueVertices); - float AMSDiff = 0.0f; - for (size_t i=0; i <=3; i++) { - Point2f diff = ellipseAMSTrueVertices[i] - ellipseAMSTestVertices[0]; - float d = diff.x * diff.x + diff.y * diff.y; - for (size_t j=1; j <=3; j++) { - diff = ellipseAMSTrueVertices[i] - ellipseAMSTestVertices[j]; - float dd = diff.x * diff.x + diff.y * diff.y; - if(ddpts; pts.push_back(Point2f(173.41854895999165f, 125.84473135880411f)); @@ -51,29 +70,12 @@ TEST(Imgproc_FitEllipseDirect_Issue_1, accuracy) { pts.push_back(Point2f(6.719616410428614f, 50.15263031354927f)); pts.push_back(Point2f(5.122267598477748f, 46.03603214691343f)); - bool directGoodQ; float tol = 0.01f; RotatedRect ellipseDirectTrue = cv::RotatedRect(Point2f(91.3256f, 90.4668f),Size2f(187.211f, 140.031f), 21.5808f); RotatedRect ellipseDirectTest = fitEllipseDirect(pts); - Point2f ellipseDirectTrueVertices[4]; - Point2f ellipseDirectTestVertices[4]; - ellipseDirectTest.points(ellipseDirectTestVertices); - ellipseDirectTrue.points(ellipseDirectTrueVertices); - float directDiff = 0.0f; - for (size_t i=0; i <=3; i++) { - Point2f diff = ellipseDirectTrueVertices[i] - ellipseDirectTestVertices[0]; - float d = diff.x * diff.x + diff.y * diff.y; - for (size_t j=1; j <=3; j++) { - diff = ellipseDirectTrueVertices[i] - ellipseDirectTestVertices[j]; - float dd = diff.x * diff.x + diff.y * diff.y; - if(dd