From 97484089c504b8e679f97dd30c3e7d44464d9f41 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Fri, 10 Dec 2010 08:06:54 +0000 Subject: [PATCH] added support of CV_8U & CV_TM_CCORR into gpu::matchTemplate --- modules/gpu/src/match_template.cpp | 30 ++++++++++++++++++++---------- tests/gpu/src/match_template.cpp | 10 ++++++++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/modules/gpu/src/match_template.cpp b/modules/gpu/src/match_template.cpp index b5090f6..b06d6bc 100644 --- a/modules/gpu/src/match_template.cpp +++ b/modules/gpu/src/match_template.cpp @@ -85,15 +85,6 @@ namespace bh = std::min(bh, h); } #endif - - - template <> - void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result) - { - result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32F); - imgproc::matchTemplateNaive_8U_SQDIFF(image, templ, result); - } - template <> void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result) @@ -242,6 +233,24 @@ namespace } #endif + + template <> + void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result) + { + result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32F); + imgproc::matchTemplateNaive_8U_SQDIFF(image, templ, result); + } + + + template <> + void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result) + { + GpuMat imagef, templf; + image.convertTo(imagef, CV_32F); + templ.convertTo(templf, CV_32F); + matchTemplate(imagef, templf, result); + } + } @@ -252,7 +261,8 @@ void cv::gpu::matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& re typedef void (*Caller)(const GpuMat&, const GpuMat&, GpuMat&); - static const Caller callers8U[] = { ::matchTemplate, 0, 0, 0, 0, 0 }; + static const Caller callers8U[] = { ::matchTemplate, 0, + ::matchTemplate, 0, 0, 0 }; static const Caller callers32F[] = { ::matchTemplate, 0, ::matchTemplate, 0, 0, 0 }; diff --git a/tests/gpu/src/match_template.cpp b/tests/gpu/src/match_template.cpp index 1805678..8aa8315 100644 --- a/tests/gpu/src/match_template.cpp +++ b/tests/gpu/src/match_template.cpp @@ -87,6 +87,16 @@ struct CV_GpuMatchTemplateTest: CvTest F(cout << "gpu_block: " << clock() - t << endl;) if (!check(dst_gold, Mat(dst), 5 * h * w * 1e-5f)) return; + gen(image, n, m, CV_8U); + gen(templ, h, w, CV_8U); + F(t = clock();) + matchTemplate(image, templ, dst_gold, CV_TM_CCORR); + F(cout << "cpu:" << clock() - t << endl;) + F(t = clock();) + gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR); + F(cout << "gpu_block: " << clock() - t << endl;) + if (!check(dst_gold, Mat(dst), 5 * h * w * 1e-5f)) return; + gen(image, n, m, CV_32F); gen(templ, h, w, CV_32F); F(t = clock();) -- 2.7.4