fixed bug in solvePnPRansac test (thanks to Pieter-Jan Busschaert)
authorAlexander Shishkov <no@email>
Fri, 29 Apr 2011 15:00:37 +0000 (15:00 +0000)
committerAlexander Shishkov <no@email>
Fri, 29 Apr 2011 15:00:37 +0000 (15:00 +0000)
test was refactored

modules/calib3d/src/solvepnp.cpp
modules/calib3d/test/test_solvepnp_ransac.cpp

index c121892..f19d795 100644 (file)
@@ -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);
index b2e8c1c..6dc9a98 100644 (file)
@@ -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<double> (1, 0) - 1) < eps);
                 isTestSuccess = isTestSuccess && (abs(tvec.at<double> (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);
+        }
     }
 };