Commit 03b1d133 authored by Alexander Alekhin's avatar Alexander Alekhin Committed by OpenCV Buildbot

Merge pull request #2660 from arkunze:pullreq/140423-filter2D

parents e9be4865 1f8b41f3
...@@ -4379,7 +4379,7 @@ String kernelToStr(InputArray _kernel, int ddepth, const char * name) ...@@ -4379,7 +4379,7 @@ String kernelToStr(InputArray _kernel, int ddepth, const char * name)
typedef std::string (* func_t)(const Mat &); typedef std::string (* func_t)(const Mat &);
static const func_t funcs[] = { kerToStr<uchar>, kerToStr<char>, kerToStr<ushort>, kerToStr<short>, static const func_t funcs[] = { kerToStr<uchar>, kerToStr<char>, kerToStr<ushort>, kerToStr<short>,
kerToStr<int>, kerToStr<float>, kerToStr<double>, 0 }; kerToStr<int>, kerToStr<float>, kerToStr<double>, 0 };
const func_t func = funcs[depth]; const func_t func = funcs[ddepth];
CV_Assert(func != 0); CV_Assert(func != 0);
return cv::format(" -D %s=%s", name ? name : "COEFF", func(kernel).c_str()); return cv::format(" -D %s=%s", name ? name : "COEFF", func(kernel).c_str());
......
This diff is collapsed.
This diff is collapsed.
...@@ -51,7 +51,7 @@ namespace ocl { ...@@ -51,7 +51,7 @@ namespace ocl {
///////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////
// Filter2D // Filter2D
PARAM_TEST_CASE(Filter2D, MatDepth, Channels, BorderType, bool, bool) PARAM_TEST_CASE(Filter2D, MatDepth, Channels, int, int, BorderType, bool, bool)
{ {
static const int kernelMinSize = 2; static const int kernelMinSize = 2;
static const int kernelMaxSize = 10; static const int kernelMaxSize = 10;
...@@ -60,6 +60,7 @@ PARAM_TEST_CASE(Filter2D, MatDepth, Channels, BorderType, bool, bool) ...@@ -60,6 +60,7 @@ PARAM_TEST_CASE(Filter2D, MatDepth, Channels, BorderType, bool, bool)
Size dsize; Size dsize;
Point anchor; Point anchor;
int borderType; int borderType;
int widthMultiple;
bool useRoi; bool useRoi;
Mat kernel; Mat kernel;
double delta; double delta;
...@@ -70,27 +71,30 @@ PARAM_TEST_CASE(Filter2D, MatDepth, Channels, BorderType, bool, bool) ...@@ -70,27 +71,30 @@ PARAM_TEST_CASE(Filter2D, MatDepth, Channels, BorderType, bool, bool)
virtual void SetUp() virtual void SetUp()
{ {
type = CV_MAKE_TYPE(GET_PARAM(0), GET_PARAM(1)); type = CV_MAKE_TYPE(GET_PARAM(0), GET_PARAM(1));
borderType = GET_PARAM(2) | (GET_PARAM(3) ? BORDER_ISOLATED : 0); Size ksize(GET_PARAM(2), GET_PARAM(2));
useRoi = GET_PARAM(4); widthMultiple = GET_PARAM(3);
borderType = GET_PARAM(4) | (GET_PARAM(5) ? BORDER_ISOLATED : 0);
useRoi = GET_PARAM(6);
Mat temp = randomMat(ksize, CV_MAKE_TYPE(((CV_64F == CV_MAT_DEPTH(type)) ? CV_64F : CV_32F), 1), -MAX_VALUE, MAX_VALUE);
cv::normalize(temp, kernel, 1.0, 0.0, NORM_L1);
} }
void random_roi() void random_roi()
{ {
dsize = randomSize(1, MAX_VALUE); dsize = randomSize(1, MAX_VALUE);
// Make sure the width is a multiple of the requested value, and no more.
dsize.width &= ~((widthMultiple * 2) - 1);
dsize.width += widthMultiple;
Size ksize = randomSize(kernelMinSize, kernelMaxSize); Size roiSize = randomSize(kernel.size[0], MAX_VALUE, kernel.size[1], MAX_VALUE);
Mat temp = randomMat(ksize, CV_MAKE_TYPE(((CV_64F == CV_MAT_DEPTH(type)) ? CV_64F : CV_32F), 1), -MAX_VALUE, MAX_VALUE);
cv::normalize(temp, kernel, 1.0, 0.0, NORM_L1);
Size roiSize = randomSize(ksize.width, MAX_VALUE, ksize.height, MAX_VALUE);
Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(src, src_roi, roiSize, srcBorder, type, -MAX_VALUE, MAX_VALUE); randomSubMat(src, src_roi, roiSize, srcBorder, type, -MAX_VALUE, MAX_VALUE);
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, dsize, dstBorder, type, -MAX_VALUE, MAX_VALUE); randomSubMat(dst, dst_roi, dsize, dstBorder, type, -MAX_VALUE, MAX_VALUE);
anchor.x = randomInt(-1, ksize.width); anchor.x = randomInt(-1, kernel.size[0]);
anchor.y = randomInt(-1, ksize.height); anchor.y = randomInt(-1, kernel.size[1]);
delta = randomDouble(-100, 100); delta = randomDouble(-100, 100);
...@@ -122,6 +126,8 @@ OCL_INSTANTIATE_TEST_CASE_P(ImageProc, Filter2D, ...@@ -122,6 +126,8 @@ OCL_INSTANTIATE_TEST_CASE_P(ImageProc, Filter2D,
Combine( Combine(
Values(CV_8U, CV_16U, CV_32F), Values(CV_8U, CV_16U, CV_32F),
OCL_ALL_CHANNELS, OCL_ALL_CHANNELS,
Values(3, 5, 9), // Kernel size
Values(1, 4, 8), // Width mutiple
Values((BorderType)BORDER_CONSTANT, Values((BorderType)BORDER_CONSTANT,
(BorderType)BORDER_REPLICATE, (BorderType)BORDER_REPLICATE,
(BorderType)BORDER_REFLECT, (BorderType)BORDER_REFLECT,
......
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