ocl tests: show diff when cv::countNonZero(diff) > 0
authorIlya Lavrenov <ilya.lavrenov@itseez.com>
Fri, 25 Oct 2013 14:48:39 +0000 (18:48 +0400)
committerIlya Lavrenov <ilya.lavrenov@itseez.com>
Mon, 28 Oct 2013 14:20:02 +0000 (18:20 +0400)
modules/ocl/test/utility.cpp
modules/ocl/test/utility.hpp

index 43dbac6..b755ab3 100644 (file)
@@ -231,21 +231,25 @@ double checkRectSimilarity(Size sz, std::vector<Rect>& ob1, std::vector<Rect>& o
     return final_test_result;
 }
 
-void showDiff(const Mat& gold, const Mat& actual, double eps)
+void showDiff(const Mat& gold, const Mat& actual, double eps, bool alwaysShow)
 {
     Mat diff;
     absdiff(gold, actual, diff);
+    diff.convertTo(diff, CV_32F);
     threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY);
 
-    namedWindow("gold", WINDOW_NORMAL);
-    namedWindow("actual", WINDOW_NORMAL);
-    namedWindow("diff", WINDOW_NORMAL);
+    if (alwaysShow || cv::countNonZero(diff.reshape(1)) > 0)
+    {
+        namedWindow("gold", WINDOW_NORMAL);
+        namedWindow("actual", WINDOW_NORMAL);
+        namedWindow("diff", WINDOW_NORMAL);
 
-    imshow("gold", gold);
-    imshow("actual", actual);
-    imshow("diff", diff);
+        imshow("gold", gold);
+        imshow("actual", actual);
+        imshow("diff", diff);
 
-    waitKey();
+        waitKey();
+    }
 }
 
 } // namespace cvtest
index 5ad97b0..47da013 100644 (file)
@@ -52,7 +52,7 @@ extern int LOOP_TIMES;
 
 namespace cvtest {
 
-void showDiff(const Mat& gold, const Mat& actual, double eps);
+void showDiff(const Mat& gold, const Mat& actual, double eps, bool alwaysShow = false);
 
 cv::ocl::oclMat createMat_ocl(cv::RNG& rng, Size size, int type, bool useRoi);
 cv::ocl::oclMat loadMat_ocl(cv::RNG& rng, const Mat& m, bool useRoi);