bh = std::min(bh, h);\r
}\r
#endif\r
-\r
-\r
- template <>\r
- void matchTemplate<CV_8U, CV_TM_SQDIFF>(const GpuMat& image, const GpuMat& templ, GpuMat& result)\r
- {\r
- result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32F);\r
- imgproc::matchTemplateNaive_8U_SQDIFF(image, templ, result);\r
- }\r
-\r
\r
template <>\r
void matchTemplate<CV_32F, CV_TM_SQDIFF>(const GpuMat& image, const GpuMat& templ, GpuMat& result)\r
}\r
#endif\r
\r
+\r
+ template <>\r
+ void matchTemplate<CV_8U, CV_TM_SQDIFF>(const GpuMat& image, const GpuMat& templ, GpuMat& result)\r
+ {\r
+ result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32F);\r
+ imgproc::matchTemplateNaive_8U_SQDIFF(image, templ, result);\r
+ }\r
+\r
+ \r
+ template <>\r
+ void matchTemplate<CV_8U, CV_TM_CCORR>(const GpuMat& image, const GpuMat& templ, GpuMat& result)\r
+ {\r
+ GpuMat imagef, templf;\r
+ image.convertTo(imagef, CV_32F);\r
+ templ.convertTo(templf, CV_32F);\r
+ matchTemplate<CV_32F, CV_TM_SQDIFF>(imagef, templf, result);\r
+ }\r
+\r
}\r
\r
\r
\r
typedef void (*Caller)(const GpuMat&, const GpuMat&, GpuMat&);\r
\r
- static const Caller callers8U[] = { ::matchTemplate<CV_8U, CV_TM_SQDIFF>, 0, 0, 0, 0, 0 };\r
+ static const Caller callers8U[] = { ::matchTemplate<CV_8U, CV_TM_SQDIFF>, 0, \r
+ ::matchTemplate<CV_8U, CV_TM_CCORR>, 0, 0, 0 };\r
static const Caller callers32F[] = { ::matchTemplate<CV_32F, CV_TM_SQDIFF>, 0, \r
::matchTemplate<CV_32F, CV_TM_CCORR>, 0, 0, 0 };\r
\r
F(cout << "gpu_block: " << clock() - t << endl;)\r
if (!check(dst_gold, Mat(dst), 5 * h * w * 1e-5f)) return;\r
\r
+ gen(image, n, m, CV_8U);\r
+ gen(templ, h, w, CV_8U);\r
+ F(t = clock();)\r
+ matchTemplate(image, templ, dst_gold, CV_TM_CCORR);\r
+ F(cout << "cpu:" << clock() - t << endl;)\r
+ F(t = clock();)\r
+ gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR);\r
+ F(cout << "gpu_block: " << clock() - t << endl;)\r
+ if (!check(dst_gold, Mat(dst), 5 * h * w * 1e-5f)) return;\r
+\r
gen(image, n, m, CV_32F);\r
gen(templ, h, w, CV_32F);\r
F(t = clock();)\r