From 18d1be45300c984c4c5e16dbf2a1c2a9263101dc Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 25 Dec 2014 16:11:08 +0300 Subject: [PATCH] fix tests for match template --- .../cudaimgproc/test/test_match_template.cpp | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/cudaimgproc/test/test_match_template.cpp b/modules/cudaimgproc/test/test_match_template.cpp index 1c57a3b458..917923a07f 100644 --- a/modules/cudaimgproc/test/test_match_template.cpp +++ b/modules/cudaimgproc/test/test_match_template.cpp @@ -90,7 +90,18 @@ CUDA_TEST_P(MatchTemplate8U, Accuracy) cv::Mat dst_gold; cv::matchTemplate(image, templ, dst_gold, method); - EXPECT_MAT_NEAR(dst_gold, dst, templ_size.area() * 1e-1); + cv::Mat h_dst(dst); + ASSERT_EQ(dst_gold.size(), h_dst.size()); + ASSERT_EQ(dst_gold.type(), h_dst.type()); + for (int y = 0; y < h_dst.rows; ++y) + { + for (int x = 0; x < h_dst.cols; ++x) + { + float gold_val = dst_gold.at(y, x); + float actual_val = dst_gold.at(y, x); + ASSERT_FLOAT_EQ(gold_val, actual_val) << y << ", " << x; + } + } } INSTANTIATE_TEST_CASE_P(CUDA_ImgProc, MatchTemplate8U, testing::Combine( @@ -138,7 +149,18 @@ CUDA_TEST_P(MatchTemplate32F, Regression) cv::Mat dst_gold; cv::matchTemplate(image, templ, dst_gold, method); - EXPECT_MAT_NEAR(dst_gold, dst, templ_size.area() * 1e-1); + cv::Mat h_dst(dst); + ASSERT_EQ(dst_gold.size(), h_dst.size()); + ASSERT_EQ(dst_gold.type(), h_dst.type()); + for (int y = 0; y < h_dst.rows; ++y) + { + for (int x = 0; x < h_dst.cols; ++x) + { + float gold_val = dst_gold.at(y, x); + float actual_val = dst_gold.at(y, x); + ASSERT_FLOAT_EQ(gold_val, actual_val) << y << ", " << x; + } + } } INSTANTIATE_TEST_CASE_P(CUDA_ImgProc, MatchTemplate32F, testing::Combine(