Commit e844c082 authored by Ilya Lavrenov's avatar Ilya Lavrenov

some fixes and improvements in cv::matchTemplate

parent 02692f9a
......@@ -5,8 +5,6 @@
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#define CV_OPENCL_RUN_ASSERT
#ifdef HAVE_OPENCL
#ifdef CV_OPENCL_RUN_VERBOSE
......
......@@ -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,
__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 gidy = get_global_id(1);
......@@ -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,
__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 gidy = get_global_id(1);
......
This diff is collapsed.
......@@ -51,9 +51,12 @@
namespace cvtest {
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 depth;
......@@ -88,7 +91,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool)
randomSubMat(templ, templ_roi, templ_roiSize, templBorder, type, -upValue, upValue);
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(templ)
......@@ -97,7 +100,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool)
void Near(double threshold = 0.0)
{
OCL_EXPECT_MATS_NEAR(result,threshold);
OCL_EXPECT_MATS_NEAR_RELATIVE(result, threshold);
}
};
......@@ -107,20 +110,17 @@ OCL_TEST_P(MatchTemplate, Mat)
{
generateTestData();
OCL_OFF(cv::matchTemplate(image_roi,templ_roi,result_roi, method));
OCL_ON(cv::matchTemplate(uimage_roi,utempl_roi,uresult_roi, method));
OCL_OFF(cv::matchTemplate(image_roi, templ_roi, result_roi, method));
OCL_ON(cv::matchTemplate(uimage_roi, utempl_roi, uresult_roi, method));
if (method == 0)
Near(10.0f);
else
Near(method % 2 == 1 ? 0.001f : 1.0f);
Near(1.5e-4);
}
}
OCL_INSTANTIATE_TEST_CASE_P(ImageProc, MatchTemplate, Combine(
Values(CV_8U, CV_32F),
Values(1, 2, 4),
Values(0,1,2,3,4,5),
MatchTemplType::all(),
Bool())
);
} } // namespace cvtest::ocl
......
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