ocl tests: show diff when cv::countNonZero(diff) > 0

This commit is contained in:
Ilya Lavrenov 2013-10-25 18:48:39 +04:00
parent 55ede74022
commit eb2f8a2948
2 changed files with 13 additions and 9 deletions

View File

@ -231,21 +231,25 @@ double checkRectSimilarity(Size sz, std::vector<Rect>& ob1, std::vector<Rect>& o
return final_test_result; 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; Mat diff;
absdiff(gold, actual, diff); absdiff(gold, actual, diff);
diff.convertTo(diff, CV_32F);
threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY); threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY);
namedWindow("gold", WINDOW_NORMAL); if (alwaysShow || cv::countNonZero(diff.reshape(1)) > 0)
namedWindow("actual", WINDOW_NORMAL); {
namedWindow("diff", WINDOW_NORMAL); namedWindow("gold", WINDOW_NORMAL);
namedWindow("actual", WINDOW_NORMAL);
namedWindow("diff", WINDOW_NORMAL);
imshow("gold", gold); imshow("gold", gold);
imshow("actual", actual); imshow("actual", actual);
imshow("diff", diff); imshow("diff", diff);
waitKey(); waitKey();
}
} }
} // namespace cvtest } // namespace cvtest

View File

@ -52,7 +52,7 @@ extern int LOOP_TIMES;
namespace cvtest { 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 createMat_ocl(cv::RNG& rng, Size size, int type, bool useRoi);
cv::ocl::oclMat loadMat_ocl(cv::RNG& rng, const Mat& m, bool useRoi); cv::ocl::oclMat loadMat_ocl(cv::RNG& rng, const Mat& m, bool useRoi);