Commit e844c082 authored by Ilya Lavrenov's avatar Ilya Lavrenov

some fixes and improvements in cv::matchTemplate

parent 02692f9a
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners. // Third party copyrights are property of their respective owners.
#define CV_OPENCL_RUN_ASSERT
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
#ifdef CV_OPENCL_RUN_VERBOSE #ifdef CV_OPENCL_RUN_VERBOSE
......
...@@ -54,4 +54,4 @@ namespace ocl { ...@@ -54,4 +54,4 @@ namespace ocl {
} }
} }
#endif // HAVE_OPENCL #endif // HAVE_OPENCL
\ No newline at end of file
...@@ -98,7 +98,7 @@ __kernel void matchTemplate_Naive_CCORR (__global const uchar * img,int img_step ...@@ -98,7 +98,7 @@ __kernel void matchTemplate_Naive_CCORR (__global const uchar * img,int img_step
__kernel void matchTemplate_CCORR_NORMED ( __global const uchar * img_sqsums, int img_sqsums_step, int img_sqsums_offset, __kernel void matchTemplate_CCORR_NORMED ( __global const uchar * img_sqsums, int img_sqsums_step, int img_sqsums_offset,
__global uchar * res, int res_step, int res_offset, int res_rows, int res_cols, __global uchar * res, int res_step, int res_offset, int res_rows, int res_cols,
int tpl_rows, int tpl_cols, ulong tpl_sqsum) int tpl_rows, int tpl_cols, float tpl_sqsum)
{ {
int gidx = get_global_id(0); int gidx = get_global_id(0);
int gidy = get_global_id(1); int gidy = get_global_id(1);
...@@ -157,7 +157,7 @@ __kernel void matchTemplate_Naive_SQDIFF(__global const uchar * img,int img_step ...@@ -157,7 +157,7 @@ __kernel void matchTemplate_Naive_SQDIFF(__global const uchar * img,int img_step
__kernel void matchTemplate_SQDIFF_NORMED ( __global const uchar * img_sqsums, int img_sqsums_step, int img_sqsums_offset, __kernel void matchTemplate_SQDIFF_NORMED ( __global const uchar * img_sqsums, int img_sqsums_step, int img_sqsums_offset,
__global uchar * res, int res_step, int res_offset, int res_rows, int res_cols, __global uchar * res, int res_step, int res_offset, int res_rows, int res_cols,
int tpl_rows, int tpl_cols, ulong tpl_sqsum) int tpl_rows, int tpl_cols, float tpl_sqsum)
{ {
int gidx = get_global_id(0); int gidx = get_global_id(0);
int gidy = get_global_id(1); int gidy = get_global_id(1);
...@@ -394,4 +394,4 @@ __kernel void matchTemplate_CCOEFF_NORMED_C4 (__global const uchar * img_sums, i ...@@ -394,4 +394,4 @@ __kernel void matchTemplate_CCOEFF_NORMED_C4 (__global const uchar * img_sums, i
__global float * result = (__global float *)(res+res_idx); __global float * result = (__global float *)(res+res_idx);
*result = normAcc((*result) - num, denum); *result = normAcc((*result) - num, denum);
} }
} }
\ No newline at end of file
This diff is collapsed.
...@@ -51,9 +51,12 @@ ...@@ -51,9 +51,12 @@
namespace cvtest { namespace cvtest {
namespace ocl { namespace ocl {
/////////////////////////////////////////////matchTemplate////////////////////////////////////////////////////////// ///////////////////////////////////////////// matchTemplate //////////////////////////////////////////////////////////
PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool) CV_ENUM(MatchTemplType, CV_TM_SQDIFF, CV_TM_SQDIFF_NORMED, CV_TM_CCORR,
CV_TM_CCORR_NORMED, CV_TM_CCOEFF, CV_TM_CCOEFF_NORMED)
PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool)
{ {
int type; int type;
int depth; int depth;
...@@ -88,7 +91,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool) ...@@ -88,7 +91,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool)
randomSubMat(templ, templ_roi, templ_roiSize, templBorder, type, -upValue, upValue); randomSubMat(templ, templ_roi, templ_roiSize, templBorder, type, -upValue, upValue);
Border resultBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border resultBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(result, result_roi, result_roiSize, resultBorder, CV_32F, -upValue, upValue); randomSubMat(result, result_roi, result_roiSize, resultBorder, CV_32FC1, -upValue, upValue);
UMAT_UPLOAD_INPUT_PARAMETER(image) UMAT_UPLOAD_INPUT_PARAMETER(image)
UMAT_UPLOAD_INPUT_PARAMETER(templ) UMAT_UPLOAD_INPUT_PARAMETER(templ)
...@@ -97,7 +100,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool) ...@@ -97,7 +100,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool)
void Near(double threshold = 0.0) void Near(double threshold = 0.0)
{ {
OCL_EXPECT_MATS_NEAR(result,threshold); OCL_EXPECT_MATS_NEAR_RELATIVE(result, threshold);
} }
}; };
...@@ -107,22 +110,19 @@ OCL_TEST_P(MatchTemplate, Mat) ...@@ -107,22 +110,19 @@ OCL_TEST_P(MatchTemplate, Mat)
{ {
generateTestData(); generateTestData();
OCL_OFF(cv::matchTemplate(image_roi,templ_roi,result_roi, method)); OCL_OFF(cv::matchTemplate(image_roi, templ_roi, result_roi, method));
OCL_ON(cv::matchTemplate(uimage_roi,utempl_roi,uresult_roi, method)); OCL_ON(cv::matchTemplate(uimage_roi, utempl_roi, uresult_roi, method));
if (method == 0) Near(1.5e-4);
Near(10.0f);
else
Near(method % 2 == 1 ? 0.001f : 1.0f);
} }
} }
OCL_INSTANTIATE_TEST_CASE_P(ImageProc, MatchTemplate, Combine( OCL_INSTANTIATE_TEST_CASE_P(ImageProc, MatchTemplate, Combine(
Values(CV_8U, CV_32F), Values(CV_8U, CV_32F),
Values(1, 2, 4), Values(1, 2, 4),
Values(0,1,2,3,4,5), MatchTemplType::all(),
Bool()) Bool())
); );
} } // namespace cvtest::ocl } } // namespace cvtest::ocl
#endif #endif
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment