fixed warpAffine and warpPerspective tests
authorAlexey Spizhevoy <no@email>
Wed, 2 Feb 2011 10:07:56 +0000 (10:07 +0000)
committerAlexey Spizhevoy <no@email>
Wed, 2 Feb 2011 10:07:56 +0000 (10:07 +0000)
tests/gpu/src/imgproc_gpu.cpp

index e7c2349..0414c48 100644 (file)
@@ -65,7 +65,7 @@ protected:
     virtual int test(const Mat& img) = 0;\r
 \r
     int CheckNorm(const Mat& m1, const Mat& m2);  \r
-    int ChechSimilarity(const Mat& m1, const Mat& m2);\r
+    int CheckSimilarity(const Mat& m1, const Mat& m2, float max_err=1e-3f);\r
 };\r
 \r
 \r
@@ -118,14 +118,14 @@ int CV_GpuImageProcTest::CheckNorm(const Mat& m1, const Mat& m2)
     }\r
 }\r
 \r
-int CV_GpuImageProcTest::ChechSimilarity(const Mat& m1, const Mat& m2)\r
+int CV_GpuImageProcTest::CheckSimilarity(const Mat& m1, const Mat& m2, float max_err)\r
 {\r
     Mat diff;\r
     cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);\r
 \r
     float err = abs(diff.at<float>(0, 0) - 1.f);\r
 \r
-    if (err > 1e-3f)\r
+    if (err > max_err)\r
         return CvTS::FAIL_INVALID_OUTPUT;\r
 \r
     return CvTS::OK;\r
@@ -263,13 +263,8 @@ struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest
             cv::gpu::resize(gpu1, gpu_res1, Size(), 2.0, 2.0, interpolations[i]);\r
             cv::gpu::resize(gpu_res1, gpu_res2, Size(), 0.5, 0.5, interpolations[i]);\r
 \r
-            switch (img.depth())\r
-            {\r
-            case CV_8U: \r
-                if (ChechSimilarity(cpu_res2, gpu_res2) != CvTS::OK)\r
-                    test_res = CvTS::FAIL_GENERIC;\r
-                break;\r
-            }\r
+            if (CheckSimilarity(cpu_res2, gpu_res2) != CvTS::OK)\r
+                test_res = CvTS::FAIL_GENERIC;\r
         }\r
 \r
         return test_res;\r
@@ -346,7 +341,7 @@ struct CV_GpuNppImageWarpAffineTest : public CV_GpuImageProcTest
             GpuMat gpudst;\r
             cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]);\r
 \r
-            if (CheckNorm(cpudst, gpudst) != CvTS::OK)\r
+            if (CheckSimilarity(cpudst, gpudst, 3e-3f) != CvTS::OK)\r
                 test_res = CvTS::FAIL_GENERIC;\r
         }\r
 \r
@@ -394,7 +389,7 @@ struct CV_GpuNppImageWarpPerspectiveTest : public CV_GpuImageProcTest
             GpuMat gpudst;\r
             cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]);\r
 \r
-            if (CheckNorm(cpudst, gpudst) != CvTS::OK)\r
+            if (CheckSimilarity(cpudst, gpudst, 3e-3f) != CvTS::OK)\r
                 test_res = CvTS::FAIL_GENERIC;\r
         }\r
 \r