From a80793667fd6d464207f5c64cbc01bf3959391f5 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Wed, 2 Feb 2011 09:58:22 +0000 Subject: [PATCH] fixed gpu image resize test --- tests/gpu/src/imgproc_gpu.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/gpu/src/imgproc_gpu.cpp b/tests/gpu/src/imgproc_gpu.cpp index 1de3bd65d..e7c234915 100644 --- a/tests/gpu/src/imgproc_gpu.cpp +++ b/tests/gpu/src/imgproc_gpu.cpp @@ -64,7 +64,8 @@ protected: virtual int test(const Mat& img) = 0; - int CheckNorm(const Mat& m1, const Mat& m2); + int CheckNorm(const Mat& m1, const Mat& m2); + int ChechSimilarity(const Mat& m1, const Mat& m2); }; @@ -117,6 +118,19 @@ int CV_GpuImageProcTest::CheckNorm(const Mat& m1, const Mat& m2) } } +int CV_GpuImageProcTest::ChechSimilarity(const Mat& m1, const Mat& m2) +{ + Mat diff; + cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED); + + float err = abs(diff.at(0, 0) - 1.f); + + if (err > 1e-3f) + return CvTS::FAIL_INVALID_OUTPUT; + + return CvTS::OK; +} + void CV_GpuImageProcTest::run( int ) { //load image @@ -241,14 +255,21 @@ struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest { ts->printf(CvTS::LOG, "Interpolation: %s\n", interpolations_str[i]); - Mat cpu_res; - cv::resize(img, cpu_res, Size(), 0.5, 0.5, interpolations[i]); + Mat cpu_res1, cpu_res2; + cv::resize(img, cpu_res1, Size(), 2.0, 2.0, interpolations[i]); + cv::resize(cpu_res1, cpu_res2, Size(), 0.5, 0.5, interpolations[i]); - GpuMat gpu1(img), gpu_res; - cv::gpu::resize(gpu1, gpu_res, Size(), 0.5, 0.5, interpolations[i]); + GpuMat gpu1(img), gpu_res1, gpu_res2; + cv::gpu::resize(gpu1, gpu_res1, Size(), 2.0, 2.0, interpolations[i]); + cv::gpu::resize(gpu_res1, gpu_res2, Size(), 0.5, 0.5, interpolations[i]); - if (CheckNorm(cpu_res, gpu_res) != CvTS::OK) - test_res = CvTS::FAIL_GENERIC; + switch (img.depth()) + { + case CV_8U: + if (ChechSimilarity(cpu_res2, gpu_res2) != CvTS::OK) + test_res = CvTS::FAIL_GENERIC; + break; + } } return test_res;