From 8a79d414c00eb6522868ac5f1a6ee6bb0376c117 Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Fri, 29 Apr 2011 15:00:37 +0000 Subject: [PATCH] fixed bug in solvePnPRansac test (thanks to Pieter-Jan Busschaert) test was refactored --- modules/calib3d/src/solvepnp.cpp | 2 +- modules/calib3d/test/test_solvepnp_ransac.cpp | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index c121892..f19d795 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -73,7 +73,7 @@ namespace cv Mat R(3, 3, CV_64FC1); Rodrigues(rvec, R); Mat transformation(3, 4, CV_64F); - Mat r = transformation.colRange(0, 2); + Mat r = transformation.colRange(0, 3); R.copyTo(r); Mat t = transformation.colRange(3, 4); tvec.copyTo(t); diff --git a/modules/calib3d/test/test_solvepnp_ransac.cpp b/modules/calib3d/test/test_solvepnp_ransac.cpp index b2e8c1c..6dc9a98 100644 --- a/modules/calib3d/test/test_solvepnp_ransac.cpp +++ b/modules/calib3d/test/test_solvepnp_ransac.cpp @@ -97,7 +97,11 @@ protected: } } double eps = 1.0e-7; - for (int testIndex = 0; testIndex< 10; testIndex++) + + int successfulTestsCount = 0; + int totalTestsCount = 10; + + for (int testIndex = 0; testIndex < totalTestsCount; testIndex++) { try { @@ -118,12 +122,9 @@ protected: isTestSuccess = isTestSuccess && (abs(tvec.at (1, 0) - 1) < eps); isTestSuccess = isTestSuccess && (abs(tvec.at (2, 0)) < eps); - if (!isTestSuccess) - { - ts.printf( cvtest::TS::LOG, "Invalid accuracy, inliers.size = %d\n", inliers.size()); - ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); - break; - } + + if (isTestSuccess) + successfulTestsCount++; } catch(...) @@ -132,6 +133,13 @@ protected: ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); } } + + if (successfulTestsCount < 0.8*totalTestsCount) + { + ts.printf( cvtest::TS::LOG, "Invalid accuracy, failed %d tests from %d\n", + totalTestsCount - successfulTestsCount, totalTestsCount); + ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); + } } }; -- 2.7.4