Merge pull request #2494 from ilya-lavrenov:tapi_merge

This commit is contained in:
Andrey Pavlenko 2014-03-20 13:39:39 +04:00 committed by OpenCV Buildbot
commit 2299e2ed1b
31 changed files with 376 additions and 336 deletions

View File

@ -1299,7 +1299,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
int type1 = _src1.type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); int type1 = _src1.type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1);
bool haveMask = !_mask.empty(); bool haveMask = !_mask.empty();
if( ((haveMask || haveScalar) && cn > 4) ) if ( (haveMask || haveScalar) && cn > 4 )
return false; return false;
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), wdepth = std::max(CV_32S, CV_MAT_DEPTH(wtype)); int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), wdepth = std::max(CV_32S, CV_MAT_DEPTH(wtype));
@ -1320,14 +1320,11 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
"-D convertToWT2=%s -D convertToDT=%s%s -D cn=%d", "-D convertToWT2=%s -D convertToDT=%s%s -D cn=%d",
(haveMask ? "MASK_" : ""), (haveScalar ? "UNARY_OP" : "BINARY_OP"), (haveMask ? "MASK_" : ""), (haveScalar ? "UNARY_OP" : "BINARY_OP"),
oclop2str[oclop], ocl::typeToStr(CV_MAKETYPE(depth1, kercn)), oclop2str[oclop], ocl::typeToStr(CV_MAKETYPE(depth1, kercn)),
ocl::typeToStr(CV_MAKETYPE(depth1, 1)), ocl::typeToStr(depth1), ocl::typeToStr(CV_MAKETYPE(depth2, kercn)),
ocl::typeToStr(CV_MAKETYPE(depth2, kercn)), ocl::typeToStr(depth2), ocl::typeToStr(CV_MAKETYPE(ddepth, kercn)),
ocl::typeToStr(CV_MAKETYPE(depth2, 1)), ocl::typeToStr(ddepth), ocl::typeToStr(CV_MAKETYPE(wdepth, kercn)),
ocl::typeToStr(CV_MAKETYPE(ddepth, kercn)),
ocl::typeToStr(CV_MAKETYPE(ddepth, 1)),
ocl::typeToStr(CV_MAKETYPE(wdepth, kercn)),
ocl::typeToStr(CV_MAKETYPE(wdepth, scalarcn)), ocl::typeToStr(CV_MAKETYPE(wdepth, scalarcn)),
ocl::typeToStr(CV_MAKETYPE(wdepth, 1)), wdepth, ocl::typeToStr(wdepth), wdepth,
ocl::convertTypeStr(depth1, wdepth, kercn, cvtstr[0]), ocl::convertTypeStr(depth1, wdepth, kercn, cvtstr[0]),
ocl::convertTypeStr(depth2, wdepth, kercn, cvtstr[1]), ocl::convertTypeStr(depth2, wdepth, kercn, cvtstr[1]),
ocl::convertTypeStr(wdepth, ddepth, kercn, cvtstr[2]), ocl::convertTypeStr(wdepth, ddepth, kercn, cvtstr[2]),
@ -1347,7 +1344,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
} }
ocl::Kernel k("KF", ocl::core::arithm_oclsrc, opts); ocl::Kernel k("KF", ocl::core::arithm_oclsrc, opts);
if( k.empty() ) if (k.empty())
return false; return false;
UMat src1 = _src1.getUMat(), src2; UMat src1 = _src1.getUMat(), src2;
@ -1388,12 +1385,12 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
if( !haveMask ) if( !haveMask )
{ {
if(n == 0) if (n == 0)
k.args(src1arg, src2arg, dstarg); k.args(src1arg, src2arg, dstarg);
else if(n == 1) else if (n == 1)
k.args(src1arg, src2arg, dstarg, k.args(src1arg, src2arg, dstarg,
ocl::KernelArg(0, 0, 0, 0, usrdata_p, usrdata_esz)); ocl::KernelArg(0, 0, 0, 0, usrdata_p, usrdata_esz));
else if(n == 3) else if (n == 3)
k.args(src1arg, src2arg, dstarg, k.args(src1arg, src2arg, dstarg,
ocl::KernelArg(0, 0, 0, 0, usrdata_p, usrdata_esz), ocl::KernelArg(0, 0, 0, 0, usrdata_p, usrdata_esz),
ocl::KernelArg(0, 0, 0, 0, usrdata_p + usrdata_esz, usrdata_esz), ocl::KernelArg(0, 0, 0, 0, usrdata_p + usrdata_esz, usrdata_esz),

View File

@ -415,42 +415,54 @@ namespace cv {
static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst ) static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst )
{ {
std::vector<UMat> src; std::vector<UMat> src, ksrc;
_mv.getUMatVector(src); _mv.getUMatVector(src);
CV_Assert(!src.empty()); CV_Assert(!src.empty());
int type = src[0].type(), depth = CV_MAT_DEPTH(type); int type = src[0].type(), depth = CV_MAT_DEPTH(type);
Size size = src[0].size(); Size size = src[0].size();
size_t srcsize = src.size(); for (size_t i = 0, srcsize = src.size(); i < srcsize; ++i)
for (size_t i = 0; i < srcsize; ++i)
{ {
int itype = src[i].type(), icn = CV_MAT_CN(itype), idepth = CV_MAT_DEPTH(itype); int itype = src[i].type(), icn = CV_MAT_CN(itype), idepth = CV_MAT_DEPTH(itype),
if (src[i].dims > 2 || icn != 1) esz1 = CV_ELEM_SIZE1(idepth);
if (src[i].dims > 2)
return false; return false;
CV_Assert(size == src[i].size() && depth == idepth);
}
String srcargs, srcdecl, processelem; CV_Assert(size == src[i].size() && depth == idepth);
for (size_t i = 0; i < srcsize; ++i)
for (int cn = 0; cn < icn; ++cn)
{
UMat tsrc = src[i];
tsrc.offset += cn * esz1;
ksrc.push_back(tsrc);
}
}
int dcn = (int)ksrc.size();
String srcargs, srcdecl, processelem, cndecl;
for (int i = 0; i < dcn; ++i)
{ {
srcargs += format("DECLARE_SRC_PARAM(%d)", i); srcargs += format("DECLARE_SRC_PARAM(%d)", i);
srcdecl += format("DECLARE_DATA(%d)", i); srcdecl += format("DECLARE_DATA(%d)", i);
processelem += format("PROCESS_ELEM(%d)", i); processelem += format("PROCESS_ELEM(%d)", i);
cndecl += format(" -D scn%d=%d", i, ksrc[i].channels());
} }
ocl::Kernel k("merge", ocl::core::split_merge_oclsrc, ocl::Kernel k("merge", ocl::core::split_merge_oclsrc,
format("-D OP_MERGE -D cn=%d -D T=%s -D DECLARE_SRC_PARAMS_N=%s -D DECLARE_DATA_N=%s -D PROCESS_ELEMS_N=%s", format("-D OP_MERGE -D cn=%d -D T=%s -D DECLARE_SRC_PARAMS_N=%s"
(int)srcsize, ocl::memopTypeToStr(depth), srcargs.c_str(), srcdecl.c_str(), processelem.c_str())); " -D DECLARE_DATA_N=%s -D PROCESS_ELEMS_N=%s%s",
dcn, ocl::memopTypeToStr(depth), srcargs.c_str(),
srcdecl.c_str(), processelem.c_str(), cndecl.c_str()));
if (k.empty()) if (k.empty())
return false; return false;
_dst.create(size, CV_MAKE_TYPE(depth, (int)srcsize)); _dst.create(size, CV_MAKE_TYPE(depth, dcn));
UMat dst = _dst.getUMat(); UMat dst = _dst.getUMat();
int argidx = 0; int argidx = 0;
for (size_t i = 0; i < srcsize; ++i) for (int i = 0; i < dcn; ++i)
argidx = k.set(argidx, ocl::KernelArg::ReadOnlyNoSize(src[i])); argidx = k.set(argidx, ocl::KernelArg::ReadOnlyNoSize(ksrc[i]));
k.set(argidx, ocl::KernelArg::WriteOnly(dst)); k.set(argidx, ocl::KernelArg::WriteOnly(dst));
size_t globalsize[2] = { dst.cols, dst.rows }; size_t globalsize[2] = { dst.cols, dst.rows };

View File

@ -2041,7 +2041,7 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst,
const char * const op = issqrt ? "OP_SQRT" : is_ipower ? "OP_POWN" : "OP_POW"; const char * const op = issqrt ? "OP_SQRT" : is_ipower ? "OP_POWN" : "OP_POW";
ocl::Kernel k("KF", ocl::core::arithm_oclsrc, ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
format("-D dstT=%s -D %s -D UNARY_OP%s", ocl::typeToStr(CV_MAKE_TYPE(depth, 1)), format("-D dstT=%s -D %s -D UNARY_OP%s", ocl::typeToStr(depth),
op, doubleSupport ? " -D DOUBLE_SUPPORT" : "")); op, doubleSupport ? " -D DOUBLE_SUPPORT" : ""));
if (k.empty()) if (k.empty())
return false; return false;
@ -2081,7 +2081,7 @@ void pow( InputArray _src, double power, OutputArray _dst )
{ {
if( ipower < 0 ) if( ipower < 0 )
{ {
divide( 1., _src, _dst ); divide( Scalar::all(1), _src, _dst );
if( ipower == -1 ) if( ipower == -1 )
return; return;
ipower = -ipower; ipower = -ipower;
@ -2115,10 +2115,7 @@ void pow( InputArray _src, double power, OutputArray _dst )
Mat src, dst; Mat src, dst;
if (same) if (same)
{ src = dst = _dst.getMat();
dst = _dst.getMat();
src = dst;
}
else else
{ {
src = _src.getMat(); src = _src.getMat();

View File

@ -4348,7 +4348,7 @@ int predictOptimalVectorWidth(InputArray src1, InputArray src2, InputArray src3,
InputArray src4, InputArray src5, InputArray src6, InputArray src4, InputArray src5, InputArray src6,
InputArray src7, InputArray src8, InputArray src9) InputArray src7, InputArray src8, InputArray src9)
{ {
int type = src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); int type = src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(depth);
Size ssize = src1.size(); Size ssize = src1.size();
const ocl::Device & d = ocl::Device::getDefault(); const ocl::Device & d = ocl::Device::getDefault();
@ -4372,7 +4372,8 @@ int predictOptimalVectorWidth(InputArray src1, InputArray src2, InputArray src3,
PROCESS_SRC(src9); PROCESS_SRC(src9);
size_t size = offsets.size(); size_t size = offsets.size();
std::vector<int> dividers(size, width); int wsz = width * esz;
std::vector<int> dividers(size, wsz);
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
while (offsets[i] % dividers[i] != 0 || steps[i] % dividers[i] != 0 || cols[i] % dividers[i] != 0) while (offsets[i] % dividers[i] != 0 || steps[i] % dividers[i] != 0 || cols[i] % dividers[i] != 0)
@ -4380,7 +4381,7 @@ int predictOptimalVectorWidth(InputArray src1, InputArray src2, InputArray src3,
// default strategy // default strategy
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
if (dividers[i] != width) if (dividers[i] != wsz)
{ {
width = 1; width = 1;
break; break;

View File

@ -45,7 +45,7 @@
#define DECLARE_SRC_PARAM(index) __global const uchar * src##index##ptr, int src##index##_step, int src##index##_offset, #define DECLARE_SRC_PARAM(index) __global const uchar * src##index##ptr, int src##index##_step, int src##index##_offset,
#define DECLARE_DATA(index) __global const T * src##index = \ #define DECLARE_DATA(index) __global const T * src##index = \
(__global T *)(src##index##ptr + mad24(src##index##_step, y, mad24(x, (int)sizeof(T), src##index##_offset))); (__global T *)(src##index##ptr + mad24(src##index##_step, y, mad24(x, (int)sizeof(T) * scn##index, src##index##_offset)));
#define PROCESS_ELEM(index) dst[index] = src##index[0]; #define PROCESS_ELEM(index) dst[index] = src##index[0];
__kernel void merge(DECLARE_SRC_PARAMS_N __kernel void merge(DECLARE_SRC_PARAMS_N

View File

@ -57,9 +57,9 @@ PARAM_TEST_CASE(Lut, MatDepth, MatDepth, Channels, bool, bool)
int cn; int cn;
bool use_roi, same_cn; bool use_roi, same_cn;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_INPUT_PARAMETER(lut) TEST_DECLARE_INPUT_PARAMETER(lut);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -87,14 +87,14 @@ PARAM_TEST_CASE(Lut, MatDepth, MatDepth, Channels, bool, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, dst_type, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, dst_type, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_INPUT_PARAMETER(lut) UMAT_UPLOAD_INPUT_PARAMETER(lut);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.) void Near(double threshold = 0.)
{ {
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
}; };
@ -121,11 +121,11 @@ PARAM_TEST_CASE(ArithmTestBase, MatDepth, Channels, bool)
cv::Scalar val; cv::Scalar val;
cv::Scalar val_in_range; cv::Scalar val_in_range;
TEST_DECLARE_INPUT_PARAMETER(src1) TEST_DECLARE_INPUT_PARAMETER(src1);
TEST_DECLARE_INPUT_PARAMETER(src2) TEST_DECLARE_INPUT_PARAMETER(src2);
TEST_DECLARE_INPUT_PARAMETER(mask) TEST_DECLARE_INPUT_PARAMETER(mask);
TEST_DECLARE_OUTPUT_PARAMETER(dst1) TEST_DECLARE_OUTPUT_PARAMETER(dst1);
TEST_DECLARE_OUTPUT_PARAMETER(dst2) TEST_DECLARE_OUTPUT_PARAMETER(dst2);
virtual void SetUp() virtual void SetUp()
{ {
@ -167,21 +167,21 @@ PARAM_TEST_CASE(ArithmTestBase, MatDepth, Channels, bool)
rng.uniform(minV, maxV), rng.uniform(minV, maxV)); rng.uniform(minV, maxV), rng.uniform(minV, maxV));
} }
UMAT_UPLOAD_INPUT_PARAMETER(src1) UMAT_UPLOAD_INPUT_PARAMETER(src1);
UMAT_UPLOAD_INPUT_PARAMETER(src2) UMAT_UPLOAD_INPUT_PARAMETER(src2);
UMAT_UPLOAD_INPUT_PARAMETER(mask) UMAT_UPLOAD_INPUT_PARAMETER(mask);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst1) UMAT_UPLOAD_OUTPUT_PARAMETER(dst1);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst2) UMAT_UPLOAD_OUTPUT_PARAMETER(dst2);
} }
void Near(double threshold = 0.) void Near(double threshold = 0.)
{ {
OCL_EXPECT_MATS_NEAR(dst1, threshold) OCL_EXPECT_MATS_NEAR(dst1, threshold);
} }
void Near1(double threshold = 0.) void Near1(double threshold = 0.)
{ {
OCL_EXPECT_MATS_NEAR(dst2, threshold) OCL_EXPECT_MATS_NEAR(dst2, threshold);
} }
}; };
@ -556,6 +556,12 @@ OCL_TEST_P(Transpose, Mat)
{ {
generateTestData(); generateTestData();
Size roiSize = src1_roi.size();
Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst1, dst1_roi, Size(roiSize.height, roiSize.width), dst1Border, src1.type(), 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(dst1);
OCL_OFF(cv::transpose(src1_roi, dst1_roi)); OCL_OFF(cv::transpose(src1_roi, dst1_roi));
OCL_ON(cv::transpose(usrc1_roi, udst1_roi)); OCL_ON(cv::transpose(usrc1_roi, udst1_roi));
@ -580,7 +586,7 @@ OCL_TEST_P(Transpose, SquareInplace)
OCL_OFF(cv::transpose(src1_roi, src1_roi)); OCL_OFF(cv::transpose(src1_roi, src1_roi));
OCL_ON(cv::transpose(usrc1_roi, usrc1_roi)); OCL_ON(cv::transpose(usrc1_roi, usrc1_roi));
OCL_EXPECT_MATS_NEAR(src1, 0) OCL_EXPECT_MATS_NEAR(src1, 0);
} }
} }
@ -761,7 +767,7 @@ OCL_TEST_P(Bitwise_not, Mat)
typedef ArithmTestBase Compare; typedef ArithmTestBase Compare;
static const int cmp_codes[] = { CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE }; static const int cmp_codes[] = { CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE };
static const char* cmp_strs[] = { "CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE" }; static const char * cmp_strs[] = { "CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE" };
static const int cmp_num = sizeof(cmp_codes) / sizeof(int); static const int cmp_num = sizeof(cmp_codes) / sizeof(int);
OCL_TEST_P(Compare, Mat) OCL_TEST_P(Compare, Mat)
@ -826,12 +832,14 @@ OCL_TEST_P(Pow, Mat)
for (int j = 0; j < test_loop_times; j++) for (int j = 0; j < test_loop_times; j++)
for (int k = 0, size = sizeof(pows) / sizeof(double); k < size; ++k) for (int k = 0, size = sizeof(pows) / sizeof(double); k < size; ++k)
{ {
SCOPED_TRACE(pows[k]);
generateTestData(); generateTestData();
OCL_OFF(cv::pow(src1_roi, pows[k], dst1_roi)); OCL_OFF(cv::pow(src1_roi, pows[k], dst1_roi));
OCL_ON(cv::pow(usrc1_roi, pows[k], udst1_roi)); OCL_ON(cv::pow(usrc1_roi, pows[k], udst1_roi));
Near(1); // FIXIT: Relative error check! OCL_EXPECT_MATS_NEAR_RELATIVE(dst1, 1e-5);
} }
} }
@ -893,8 +901,8 @@ struct RepeatTestCase :
Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst1, dst1_roi, dstRoiSize, dst1Border, type, 5, 16); randomSubMat(dst1, dst1_roi, dstRoiSize, dst1Border, type, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src1) UMAT_UPLOAD_INPUT_PARAMETER(src1);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst1) UMAT_UPLOAD_OUTPUT_PARAMETER(dst1);
} }
}; };
@ -1450,10 +1458,10 @@ PARAM_TEST_CASE(InRange, MatDepth, Channels, bool /*Scalar or not*/, bool /*Roi*
bool scalars, use_roi; bool scalars, use_roi;
cv::Scalar val1, val2; cv::Scalar val1, val2;
TEST_DECLARE_INPUT_PARAMETER(src1) TEST_DECLARE_INPUT_PARAMETER(src1);
TEST_DECLARE_INPUT_PARAMETER(src2) TEST_DECLARE_INPUT_PARAMETER(src2);
TEST_DECLARE_INPUT_PARAMETER(src3) TEST_DECLARE_INPUT_PARAMETER(src3);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -1485,15 +1493,15 @@ PARAM_TEST_CASE(InRange, MatDepth, Channels, bool /*Scalar or not*/, bool /*Roi*
val2 = cv::Scalar(rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0), val2 = cv::Scalar(rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0),
rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0)); rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0));
UMAT_UPLOAD_INPUT_PARAMETER(src1) UMAT_UPLOAD_INPUT_PARAMETER(src1);
UMAT_UPLOAD_INPUT_PARAMETER(src2) UMAT_UPLOAD_INPUT_PARAMETER(src2);
UMAT_UPLOAD_INPUT_PARAMETER(src3) UMAT_UPLOAD_INPUT_PARAMETER(src3);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near() void Near()
{ {
OCL_EXPECT_MATS_NEAR(dst, 0) OCL_EXPECT_MATS_NEAR(dst, 0);
} }
}; };
@ -1565,7 +1573,7 @@ PARAM_TEST_CASE(PatchNaNs, Channels, bool)
bool use_roi; bool use_roi;
double value; double value;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
virtual void SetUp() virtual void SetUp()
{ {
@ -1592,12 +1600,12 @@ PARAM_TEST_CASE(PatchNaNs, Channels, bool)
value = randomDouble(-100, 100); value = randomDouble(-100, 100);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
} }
void Near() void Near()
{ {
OCL_EXPECT_MATS_NEAR(src, 0) OCL_EXPECT_MATS_NEAR(src, 0);
} }
}; };
@ -1640,8 +1648,8 @@ PARAM_TEST_CASE(Reduce, std::pair<MatDepth, MatDepth>, Channels, int, bool)
int sdepth, ddepth, cn, dim, dtype; int sdepth, ddepth, cn, dim, dtype;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -1666,8 +1674,8 @@ PARAM_TEST_CASE(Reduce, std::pair<MatDepth, MatDepth>, Channels, int, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, dstRoiSize, dstBorder, dtype, 5, 16); randomSubMat(dst, dst_roi, dstRoiSize, dstBorder, dtype, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };
@ -1683,7 +1691,7 @@ OCL_TEST_P(ReduceSum, Mat)
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_SUM, dtype)); OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_SUM, dtype));
double eps = ddepth <= CV_32S ? 1 : 1e-4; double eps = ddepth <= CV_32S ? 1 : 1e-4;
OCL_EXPECT_MATS_NEAR(dst, eps) OCL_EXPECT_MATS_NEAR(dst, eps);
} }
} }
@ -1698,7 +1706,7 @@ OCL_TEST_P(ReduceMax, Mat)
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MAX, dtype)); OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MAX, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MAX, dtype)); OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MAX, dtype));
OCL_EXPECT_MATS_NEAR(dst, 0) OCL_EXPECT_MATS_NEAR(dst, 0);
} }
} }
@ -1713,7 +1721,7 @@ OCL_TEST_P(ReduceMin, Mat)
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MIN, dtype)); OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MIN, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MIN, dtype)); OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MIN, dtype));
OCL_EXPECT_MATS_NEAR(dst, 0) OCL_EXPECT_MATS_NEAR(dst, 0);
} }
} }
@ -1729,7 +1737,7 @@ OCL_TEST_P(ReduceAvg, Mat)
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_AVG, dtype)); OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_AVG, dtype));
double eps = ddepth <= CV_32S ? 1 : 5e-6; double eps = ddepth <= CV_32S ? 1 : 5e-6;
OCL_EXPECT_MATS_NEAR(dst, eps) OCL_EXPECT_MATS_NEAR(dst, eps);
} }
} }

View File

@ -54,16 +54,16 @@ namespace ocl {
//////////////////////////////////////// Merge /////////////////////////////////////////////// //////////////////////////////////////// Merge ///////////////////////////////////////////////
PARAM_TEST_CASE(Merge, MatDepth, Channels, bool) PARAM_TEST_CASE(Merge, MatDepth, int, bool)
{ {
int depth, cn; int depth, nsrc;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src1) TEST_DECLARE_INPUT_PARAMETER(src1);
TEST_DECLARE_INPUT_PARAMETER(src2) TEST_DECLARE_INPUT_PARAMETER(src2);
TEST_DECLARE_INPUT_PARAMETER(src3) TEST_DECLARE_INPUT_PARAMETER(src3);
TEST_DECLARE_INPUT_PARAMETER(src4) TEST_DECLARE_INPUT_PARAMETER(src4);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
std::vector<Mat> src_roi; std::vector<Mat> src_roi;
std::vector<UMat> usrc_roi; std::vector<UMat> usrc_roi;
@ -71,10 +71,15 @@ PARAM_TEST_CASE(Merge, MatDepth, Channels, bool)
virtual void SetUp() virtual void SetUp()
{ {
depth = GET_PARAM(0); depth = GET_PARAM(0);
cn = GET_PARAM(1); nsrc = GET_PARAM(1);
use_roi = GET_PARAM(2); use_roi = GET_PARAM(2);
CV_Assert(cn >= 1 && cn <= 4); CV_Assert(nsrc >= 1 && nsrc <= 4);
}
int type()
{
return CV_MAKE_TYPE(depth, randomInt(1, 3));
} }
void generateTestData() void generateTestData()
@ -83,34 +88,39 @@ PARAM_TEST_CASE(Merge, MatDepth, Channels, bool)
{ {
Border src1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); Border src1Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(src1, src1_roi, roiSize, src1Border, depth, 2, 11); randomSubMat(src1, src1_roi, roiSize, src1Border, type(), 2, 11);
Border src2Border = randomBorder(0, use_roi ? MAX_VALUE : 0); Border src2Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(src2, src2_roi, roiSize, src2Border, depth, -1540, 1740); randomSubMat(src2, src2_roi, roiSize, src2Border, type(), -1540, 1740);
Border src3Border = randomBorder(0, use_roi ? MAX_VALUE : 0); Border src3Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(src3, src3_roi, roiSize, src3Border, depth, -1540, 1740); randomSubMat(src3, src3_roi, roiSize, src3Border, type(), -1540, 1740);
Border src4Border = randomBorder(0, use_roi ? MAX_VALUE : 0); Border src4Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(src4, src4_roi, roiSize, src4Border, depth, -1540, 1740); randomSubMat(src4, src4_roi, roiSize, src4Border, type(), -1540, 1740);
} }
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); UMAT_UPLOAD_INPUT_PARAMETER(src1);
randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_MAKE_TYPE(depth, cn), 5, 16); UMAT_UPLOAD_INPUT_PARAMETER(src2);
UMAT_UPLOAD_INPUT_PARAMETER(src3);
UMAT_UPLOAD_INPUT_PARAMETER(src1) UMAT_UPLOAD_INPUT_PARAMETER(src4);
UMAT_UPLOAD_INPUT_PARAMETER(src2)
UMAT_UPLOAD_INPUT_PARAMETER(src3)
UMAT_UPLOAD_INPUT_PARAMETER(src4)
UMAT_UPLOAD_OUTPUT_PARAMETER(dst)
src_roi.push_back(src1_roi), usrc_roi.push_back(usrc1_roi); src_roi.push_back(src1_roi), usrc_roi.push_back(usrc1_roi);
if (cn >= 2) if (nsrc >= 2)
src_roi.push_back(src2_roi), usrc_roi.push_back(usrc2_roi); src_roi.push_back(src2_roi), usrc_roi.push_back(usrc2_roi);
if (cn >= 3) if (nsrc >= 3)
src_roi.push_back(src3_roi), usrc_roi.push_back(usrc3_roi); src_roi.push_back(src3_roi), usrc_roi.push_back(usrc3_roi);
if (cn >= 4) if (nsrc >= 4)
src_roi.push_back(src4_roi), usrc_roi.push_back(usrc4_roi); src_roi.push_back(src4_roi), usrc_roi.push_back(usrc4_roi);
int dcn = 0;
for (int i = 0; i < nsrc; ++i)
dcn += src_roi[i].channels();
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_MAKE_TYPE(depth, dcn), 5, 16);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.) void Near(double threshold = 0.)
@ -139,11 +149,11 @@ PARAM_TEST_CASE(Split, MatType, Channels, bool)
int depth, cn; int depth, cn;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst1) TEST_DECLARE_OUTPUT_PARAMETER(dst1);
TEST_DECLARE_OUTPUT_PARAMETER(dst2) TEST_DECLARE_OUTPUT_PARAMETER(dst2);
TEST_DECLARE_OUTPUT_PARAMETER(dst3) TEST_DECLARE_OUTPUT_PARAMETER(dst3);
TEST_DECLARE_OUTPUT_PARAMETER(dst4) TEST_DECLARE_OUTPUT_PARAMETER(dst4);
std::vector<Mat> dst_roi, dst; std::vector<Mat> dst_roi, dst;
std::vector<UMat> udst_roi, udst; std::vector<UMat> udst_roi, udst;
@ -177,11 +187,11 @@ PARAM_TEST_CASE(Split, MatType, Channels, bool)
randomSubMat(dst4, dst4_roi, roiSize, dst4Border, depth, -1540, 1740); randomSubMat(dst4, dst4_roi, roiSize, dst4Border, depth, -1540, 1740);
} }
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst1) UMAT_UPLOAD_OUTPUT_PARAMETER(dst1);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst2) UMAT_UPLOAD_OUTPUT_PARAMETER(dst2);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst3) UMAT_UPLOAD_OUTPUT_PARAMETER(dst3);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst4) UMAT_UPLOAD_OUTPUT_PARAMETER(dst4);
dst_roi.push_back(dst1_roi), udst_roi.push_back(udst1_roi), dst_roi.push_back(dst1_roi), udst_roi.push_back(udst1_roi),
dst.push_back(dst1), udst.push_back(udst1); dst.push_back(dst1), udst.push_back(udst1);
@ -221,14 +231,14 @@ PARAM_TEST_CASE(MixChannels, MatType, bool)
int depth; int depth;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src1) TEST_DECLARE_INPUT_PARAMETER(src1);
TEST_DECLARE_INPUT_PARAMETER(src2) TEST_DECLARE_INPUT_PARAMETER(src2);
TEST_DECLARE_INPUT_PARAMETER(src3) TEST_DECLARE_INPUT_PARAMETER(src3);
TEST_DECLARE_INPUT_PARAMETER(src4) TEST_DECLARE_INPUT_PARAMETER(src4);
TEST_DECLARE_OUTPUT_PARAMETER(dst1) TEST_DECLARE_OUTPUT_PARAMETER(dst1);
TEST_DECLARE_OUTPUT_PARAMETER(dst2) TEST_DECLARE_OUTPUT_PARAMETER(dst2);
TEST_DECLARE_OUTPUT_PARAMETER(dst3) TEST_DECLARE_OUTPUT_PARAMETER(dst3);
TEST_DECLARE_OUTPUT_PARAMETER(dst4) TEST_DECLARE_OUTPUT_PARAMETER(dst4);
std::vector<Mat> src_roi, dst_roi, dst; std::vector<Mat> src_roi, dst_roi, dst;
std::vector<UMat> usrc_roi, udst_roi, udst; std::vector<UMat> usrc_roi, udst_roi, udst;
@ -287,15 +297,15 @@ PARAM_TEST_CASE(MixChannels, MatType, bool)
randomSubMat(dst4, dst4_roi, roiSize, dst4Border, type(), -1540, 1740); randomSubMat(dst4, dst4_roi, roiSize, dst4Border, type(), -1540, 1740);
} }
UMAT_UPLOAD_INPUT_PARAMETER(src1) UMAT_UPLOAD_INPUT_PARAMETER(src1);
UMAT_UPLOAD_INPUT_PARAMETER(src2) UMAT_UPLOAD_INPUT_PARAMETER(src2);
UMAT_UPLOAD_INPUT_PARAMETER(src3) UMAT_UPLOAD_INPUT_PARAMETER(src3);
UMAT_UPLOAD_INPUT_PARAMETER(src4) UMAT_UPLOAD_INPUT_PARAMETER(src4);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst1) UMAT_UPLOAD_OUTPUT_PARAMETER(dst1);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst2) UMAT_UPLOAD_OUTPUT_PARAMETER(dst2);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst3) UMAT_UPLOAD_OUTPUT_PARAMETER(dst3);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst4) UMAT_UPLOAD_OUTPUT_PARAMETER(dst4);
int nsrc = randomInt(1, 5), ndst = randomInt(1, 5); int nsrc = randomInt(1, 5), ndst = randomInt(1, 5);
@ -360,8 +370,8 @@ PARAM_TEST_CASE(InsertChannel, MatDepth, Channels, bool)
int depth, cn, coi; int depth, cn, coi;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -381,8 +391,8 @@ PARAM_TEST_CASE(InsertChannel, MatDepth, Channels, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_MAKE_TYPE(depth, cn), 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_MAKE_TYPE(depth, cn), 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };
@ -406,8 +416,8 @@ PARAM_TEST_CASE(ExtractChannel, MatDepth, Channels, bool)
int depth, cn, coi; int depth, cn, coi;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -427,8 +437,8 @@ PARAM_TEST_CASE(ExtractChannel, MatDepth, Channels, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, depth, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, depth, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };
@ -447,7 +457,7 @@ OCL_TEST_P(ExtractChannel, Accuracy)
//////////////////////////////////////// Instantiation /////////////////////////////////////////////// //////////////////////////////////////// Instantiation ///////////////////////////////////////////////
OCL_INSTANTIATE_TEST_CASE_P(Channels, Merge, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); OCL_INSTANTIATE_TEST_CASE_P(Channels, Merge, Combine(OCL_ALL_DEPTHS, Values(1, 2, 3, 4), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Channels, Split, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); OCL_INSTANTIATE_TEST_CASE_P(Channels, Split, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Channels, MixChannels, Combine(OCL_ALL_DEPTHS, Bool())); OCL_INSTANTIATE_TEST_CASE_P(Channels, MixChannels, Combine(OCL_ALL_DEPTHS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Channels, InsertChannel, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); OCL_INSTANTIATE_TEST_CASE_P(Channels, InsertChannel, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));

View File

@ -60,8 +60,8 @@ PARAM_TEST_CASE(Dft, cv::Size, MatDepth, bool, bool, bool, bool)
int dft_flags, depth; int dft_flags, depth;
bool inplace; bool inplace;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -106,9 +106,9 @@ PARAM_TEST_CASE(MulSpectrums, bool, bool)
{ {
bool ccorr, useRoi; bool ccorr, useRoi;
TEST_DECLARE_INPUT_PARAMETER(src1) TEST_DECLARE_INPUT_PARAMETER(src1);
TEST_DECLARE_INPUT_PARAMETER(src2) TEST_DECLARE_INPUT_PARAMETER(src2);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -129,9 +129,9 @@ PARAM_TEST_CASE(MulSpectrums, bool, bool)
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, srcRoiSize, dstBorder, CV_32FC2, 5, 16); randomSubMat(dst, dst_roi, srcRoiSize, dstBorder, CV_32FC2, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src1) UMAT_UPLOAD_INPUT_PARAMETER(src1);
UMAT_UPLOAD_INPUT_PARAMETER(src2) UMAT_UPLOAD_INPUT_PARAMETER(src2);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };

View File

@ -67,10 +67,10 @@ PARAM_TEST_CASE(Gemm,
double alpha, beta; double alpha, beta;
TEST_DECLARE_INPUT_PARAMETER(A) TEST_DECLARE_INPUT_PARAMETER(A);
TEST_DECLARE_INPUT_PARAMETER(B) TEST_DECLARE_INPUT_PARAMETER(B);
TEST_DECLARE_INPUT_PARAMETER(C) TEST_DECLARE_INPUT_PARAMETER(C);
TEST_DECLARE_OUTPUT_PARAMETER(D) TEST_DECLARE_OUTPUT_PARAMETER(D);
virtual void SetUp() virtual void SetUp()
{ {
@ -119,10 +119,10 @@ PARAM_TEST_CASE(Gemm,
alpha = randomDouble(-4, 4); alpha = randomDouble(-4, 4);
beta = randomDouble(-4, 4); beta = randomDouble(-4, 4);
UMAT_UPLOAD_INPUT_PARAMETER(A) UMAT_UPLOAD_INPUT_PARAMETER(A);
UMAT_UPLOAD_INPUT_PARAMETER(B) UMAT_UPLOAD_INPUT_PARAMETER(B);
UMAT_UPLOAD_INPUT_PARAMETER(C) UMAT_UPLOAD_INPUT_PARAMETER(C);
UMAT_UPLOAD_OUTPUT_PARAMETER(D) UMAT_UPLOAD_OUTPUT_PARAMETER(D);
} }
}; };

View File

@ -59,8 +59,8 @@ PARAM_TEST_CASE(ConvertTo, MatDepth, MatDepth, Channels, bool)
int src_depth, cn, dstType; int src_depth, cn, dstType;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -80,8 +80,8 @@ PARAM_TEST_CASE(ConvertTo, MatDepth, MatDepth, Channels, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, dstType, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, dstType, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };
@ -108,9 +108,9 @@ PARAM_TEST_CASE(CopyTo, MatDepth, Channels, bool, bool)
int depth, cn; int depth, cn;
bool use_roi, use_mask; bool use_roi, use_mask;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_INPUT_PARAMETER(mask) TEST_DECLARE_INPUT_PARAMETER(mask);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -139,10 +139,10 @@ PARAM_TEST_CASE(CopyTo, MatDepth, Channels, bool, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
if (use_mask) if (use_mask)
UMAT_UPLOAD_INPUT_PARAMETER(mask) UMAT_UPLOAD_INPUT_PARAMETER(mask);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };
@ -169,7 +169,7 @@ OCL_TEST_P(CopyTo, Accuracy)
} }
OCL_INSTANTIATE_TEST_CASE_P(MatrixOperation, ConvertTo, Combine( OCL_INSTANTIATE_TEST_CASE_P(MatrixOperation, ConvertTo, Combine(
OCL_ALL_DEPTHS, OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); OCL_ALL_DEPTHS, OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(MatrixOperation, CopyTo, Combine( OCL_INSTANTIATE_TEST_CASE_P(MatrixOperation, CopyTo, Combine(
OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool(), Bool())); OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool(), Bool()));

View File

@ -58,10 +58,10 @@ PARAM_TEST_CASE(AccumulateBase, std::pair<MatDepth, MatDepth>, Channels, bool)
bool useRoi; bool useRoi;
double alpha; double alpha;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_INPUT_PARAMETER(mask) TEST_DECLARE_INPUT_PARAMETER(mask);
TEST_DECLARE_INPUT_PARAMETER(src2) TEST_DECLARE_INPUT_PARAMETER(src2);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -90,10 +90,10 @@ PARAM_TEST_CASE(AccumulateBase, std::pair<MatDepth, MatDepth>, Channels, bool)
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, dtype, -MAX_VALUE, MAX_VALUE); randomSubMat(dst, dst_roi, roiSize, dstBorder, dtype, -MAX_VALUE, MAX_VALUE);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_INPUT_PARAMETER(mask) UMAT_UPLOAD_INPUT_PARAMETER(mask);
UMAT_UPLOAD_INPUT_PARAMETER(src2) UMAT_UPLOAD_INPUT_PARAMETER(src2);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
alpha = randomDouble(-5, 5); alpha = randomDouble(-5, 5);
} }

View File

@ -57,11 +57,11 @@ PARAM_TEST_CASE(BlendLinear, MatDepth, Channels, bool)
int depth, channels; int depth, channels;
bool useRoi; bool useRoi;
TEST_DECLARE_INPUT_PARAMETER(src1) TEST_DECLARE_INPUT_PARAMETER(src1);
TEST_DECLARE_INPUT_PARAMETER(src2) TEST_DECLARE_INPUT_PARAMETER(src2);
TEST_DECLARE_INPUT_PARAMETER(weights2) TEST_DECLARE_INPUT_PARAMETER(weights2);
TEST_DECLARE_INPUT_PARAMETER(weights1) TEST_DECLARE_INPUT_PARAMETER(weights1);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -89,22 +89,22 @@ PARAM_TEST_CASE(BlendLinear, MatDepth, Channels, bool)
randomSubMat(weights2, weights2_roi, roiSize, weights2Border, CV_32FC1, 1e-2, upValue); randomSubMat(weights2, weights2_roi, roiSize, weights2Border, CV_32FC1, 1e-2, upValue);
weights2_roi -= weights1_roi; weights2_roi -= weights1_roi;
CV_Assert(checkNorm(weights2_roi, weights2(Rect(weights2Border.lef, weights2Border.top, CV_Assert(checkNorm2(weights2_roi, weights2(Rect(weights2Border.lef, weights2Border.top,
roiSize.width, roiSize.height))) < 1e-6); roiSize.width, roiSize.height))) < 1e-6);
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src1) UMAT_UPLOAD_INPUT_PARAMETER(src1);
UMAT_UPLOAD_INPUT_PARAMETER(src2) UMAT_UPLOAD_INPUT_PARAMETER(src2);
UMAT_UPLOAD_INPUT_PARAMETER(weights1) UMAT_UPLOAD_INPUT_PARAMETER(weights1);
UMAT_UPLOAD_INPUT_PARAMETER(weights2) UMAT_UPLOAD_INPUT_PARAMETER(weights2);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double eps = 0.0) void Near(double eps = 0.0)
{ {
OCL_EXPECT_MATS_NEAR(dst, eps) OCL_EXPECT_MATS_NEAR(dst, eps);
} }
}; };

View File

@ -61,8 +61,8 @@ PARAM_TEST_CASE(BoxFilterBase, MatDepth, Channels, BorderType, bool, bool)
Point anchor; Point anchor;
bool normalize, useRoi; bool normalize, useRoi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -76,7 +76,6 @@ PARAM_TEST_CASE(BoxFilterBase, MatDepth, Channels, BorderType, bool, bool)
void random_roi() void random_roi()
{ {
int type = CV_MAKE_TYPE(depth, cn); int type = CV_MAKE_TYPE(depth, cn);
dsize = randomSize(1, MAX_VALUE);
ksize = randomSize(kernelMinSize, kernelMaxSize); ksize = randomSize(kernelMinSize, kernelMaxSize);
Size roiSize = randomSize(ksize.width, MAX_VALUE, ksize.height, MAX_VALUE); Size roiSize = randomSize(ksize.width, MAX_VALUE, ksize.height, MAX_VALUE);
@ -84,18 +83,18 @@ PARAM_TEST_CASE(BoxFilterBase, MatDepth, Channels, BorderType, bool, bool)
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, roiSize, dstBorder, type, -MAX_VALUE, MAX_VALUE);
anchor.x = randomInt(-1, ksize.width); anchor.x = randomInt(-1, ksize.width);
anchor.y = randomInt(-1, ksize.height); anchor.y = randomInt(-1, ksize.height);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)
{ {
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
}; };

View File

@ -63,8 +63,8 @@ PARAM_TEST_CASE(Canny, AppertureSize, L2gradient, UseRoi)
int apperture_size; int apperture_size;
bool useL2gradient, use_roi; bool useL2gradient, use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -89,8 +89,8 @@ PARAM_TEST_CASE(Canny, AppertureSize, L2gradient, UseRoi)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };

View File

@ -59,8 +59,8 @@ PARAM_TEST_CASE(CvtColor, MatDepth, bool)
int depth; int depth;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -80,13 +80,13 @@ PARAM_TEST_CASE(CvtColor, MatDepth, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, dstType, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, dstType, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold) void Near(double threshold)
{ {
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
void performTest(int channelsIn, int channelsOut, int code, double threshold = 1e-3) void performTest(int channelsIn, int channelsOut, int code, double threshold = 1e-3)
@ -287,8 +287,8 @@ struct CvtColor_YUV420 :
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, dstType, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, dstType, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };

View File

@ -63,8 +63,8 @@ PARAM_TEST_CASE(Filter2D, MatDepth, Channels, BorderType, bool, bool)
bool useRoi; bool useRoi;
Mat kernel; Mat kernel;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -91,8 +91,8 @@ PARAM_TEST_CASE(Filter2D, MatDepth, Channels, BorderType, bool, bool)
anchor.x = randomInt(-1, ksize.width); anchor.x = randomInt(-1, ksize.width);
anchor.y = randomInt(-1, ksize.height); anchor.y = randomInt(-1, ksize.height);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)

View File

@ -69,8 +69,8 @@ PARAM_TEST_CASE(FilterTestBase, MatType,
double param; double param;
bool useRoi; bool useRoi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -94,8 +94,8 @@ PARAM_TEST_CASE(FilterTestBase, MatType,
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -60, 70); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -60, 70);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near() void Near()
@ -112,15 +112,9 @@ PARAM_TEST_CASE(FilterTestBase, MatType,
void Near(double threshold, bool relative) void Near(double threshold, bool relative)
{ {
if (relative) if (relative)
{ OCL_EXPECT_MATS_NEAR_RELATIVE(dst, threshold);
EXPECT_MAT_NEAR_RELATIVE(dst, udst, threshold);
EXPECT_MAT_NEAR_RELATIVE(dst_roi, udst_roi, threshold);
}
else else
{ OCL_EXPECT_MATS_NEAR(dst, threshold);
EXPECT_MAT_NEAR(dst, udst, threshold);
EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
}
} }
}; };

View File

@ -60,7 +60,7 @@ PARAM_TEST_CASE(GoodFeaturesToTrack, double, bool)
static const int maxCorners; static const int maxCorners;
static const double qualityLevel; static const double qualityLevel;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
UMat points, upoints; UMat points, upoints;
virtual void SetUp() virtual void SetUp()
@ -79,7 +79,7 @@ PARAM_TEST_CASE(GoodFeaturesToTrack, double, bool)
randomSubMat(src, src_roi, roiSize, srcBorder, frame.type(), 5, 256); randomSubMat(src, src_roi, roiSize, srcBorder, frame.type(), 5, 256);
src_roi.copyTo(frame); src_roi.copyTo(frame);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
} }
void UMatToVector(const UMat & um, std::vector<Point2f> & v) const void UMatToVector(const UMat & um, std::vector<Point2f> & v) const

View File

@ -76,8 +76,8 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
std::vector<UMat> uimages; std::vector<UMat> uimages;
std::vector<UMat> uimages_roi; std::vector<UMat> uimages_roi;
TEST_DECLARE_INPUT_PARAMETER(hist) TEST_DECLARE_INPUT_PARAMETER(hist);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -139,8 +139,8 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
uimages_roi[i] = uimages[i](Rect(ofs.x, ofs.y, images_roi[i].cols, images_roi[i].rows)); uimages_roi[i] = uimages[i](Rect(ofs.x, ofs.y, images_roi[i].cols, images_roi[i].rows));
} }
UMAT_UPLOAD_INPUT_PARAMETER(hist) UMAT_UPLOAD_INPUT_PARAMETER(hist);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
scale = randomDouble(0.1, 1); scale = randomDouble(0.1, 1);
} }
@ -157,7 +157,7 @@ OCL_TEST_P(CalcBackProject, Mat)
OCL_OFF(cv::calcBackProject(images_roi, channels, hist_roi, dst_roi, ranges, scale)); OCL_OFF(cv::calcBackProject(images_roi, channels, hist_roi, dst_roi, ranges, scale));
OCL_ON(cv::calcBackProject(uimages_roi, channels, uhist_roi, udst_roi, ranges, scale)); OCL_ON(cv::calcBackProject(uimages_roi, channels, uhist_roi, udst_roi, ranges, scale));
OCL_EXPECT_MATS_NEAR(dst, 0.0) OCL_EXPECT_MATS_NEAR(dst, 0.0);
} }
} }
@ -167,8 +167,8 @@ PARAM_TEST_CASE(CalcHist, bool)
{ {
bool useRoi; bool useRoi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(hist) TEST_DECLARE_OUTPUT_PARAMETER(hist);
virtual void SetUp() virtual void SetUp()
{ {
@ -185,8 +185,8 @@ PARAM_TEST_CASE(CalcHist, bool)
Border histBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border histBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(hist, hist_roi, Size(1, 256), histBorder, CV_32SC1, 0, MAX_VALUE); randomSubMat(hist, hist_roi, Size(1, 256), histBorder, CV_32SC1, 0, MAX_VALUE);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(hist) UMAT_UPLOAD_OUTPUT_PARAMETER(hist);
} }
}; };
@ -205,7 +205,7 @@ OCL_TEST_P(CalcHist, Mat)
OCL_OFF(cv::calcHist(std::vector<Mat>(1, src_roi), channels, noArray(), hist_roi, histSize, ranges, false)); OCL_OFF(cv::calcHist(std::vector<Mat>(1, src_roi), channels, noArray(), hist_roi, histSize, ranges, false));
OCL_ON(cv::calcHist(std::vector<UMat>(1, usrc_roi), channels, noArray(), uhist_roi, histSize, ranges, false)); OCL_ON(cv::calcHist(std::vector<UMat>(1, usrc_roi), channels, noArray(), uhist_roi, histSize, ranges, false));
OCL_EXPECT_MATS_NEAR(hist, 0.0) OCL_EXPECT_MATS_NEAR(hist, 0.0);
} }
} }

View File

@ -70,8 +70,8 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType,
int type, borderType, blockSize; int type, borderType, blockSize;
bool useRoi; bool useRoi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -90,16 +90,16 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType,
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0, bool relative = false) void Near(double threshold = 0.0, bool relative = false)
{ {
if (relative) if (relative)
OCL_EXPECT_MATS_NEAR_RELATIVE(dst, threshold) OCL_EXPECT_MATS_NEAR_RELATIVE(dst, threshold);
else else
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
}; };
@ -117,8 +117,8 @@ PARAM_TEST_CASE(CopyMakeBorder, MatDepth, // depth
TestUtils::Border border; TestUtils::Border border;
Scalar val; Scalar val;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -148,13 +148,13 @@ PARAM_TEST_CASE(CopyMakeBorder, MatDepth, // depth
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -MAX_VALUE, MAX_VALUE); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -MAX_VALUE, MAX_VALUE);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near() void Near()
{ {
OCL_EXPECT_MATS_NEAR(dst, 0) OCL_EXPECT_MATS_NEAR(dst, 0);
} }
}; };
@ -217,8 +217,8 @@ struct CornerTestBase :
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_32FC1, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_32FC1, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };
@ -286,7 +286,7 @@ struct Integral :
{ {
int sdepth, sqdepth; int sdepth, sqdepth;
TEST_DECLARE_OUTPUT_PARAMETER(dst2) TEST_DECLARE_OUTPUT_PARAMETER(dst2);
virtual void SetUp() virtual void SetUp()
{ {
@ -310,17 +310,17 @@ struct Integral :
Border dst2Border = randomBorder(0, useRoi ? 2 : 0); Border dst2Border = randomBorder(0, useRoi ? 2 : 0);
randomSubMat(dst2, dst2_roi, isize, dst2Border, sqdepth, 5, 16); randomSubMat(dst2, dst2_roi, isize, dst2Border, sqdepth, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst2) UMAT_UPLOAD_OUTPUT_PARAMETER(dst2);
} }
void Near2(double threshold = 0.0, bool relative = false) void Near2(double threshold = 0.0, bool relative = false)
{ {
if (relative) if (relative)
OCL_EXPECT_MATS_NEAR_RELATIVE(dst2, threshold) OCL_EXPECT_MATS_NEAR_RELATIVE(dst2, threshold);
else else
OCL_EXPECT_MATS_NEAR(dst2, threshold) OCL_EXPECT_MATS_NEAR(dst2, threshold);
} }
}; };
@ -390,8 +390,8 @@ PARAM_TEST_CASE(CLAHETest, Size, double, bool)
double clipLimit; double clipLimit;
bool useRoi; bool useRoi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -409,13 +409,13 @@ PARAM_TEST_CASE(CLAHETest, Size, double, bool)
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_8UC1, 5, 16); randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_8UC1, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)
{ {
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
}; };

View File

@ -62,9 +62,9 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool)
int method; int method;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(image) TEST_DECLARE_INPUT_PARAMETER(image);
TEST_DECLARE_INPUT_PARAMETER(templ) TEST_DECLARE_INPUT_PARAMETER(templ);
TEST_DECLARE_OUTPUT_PARAMETER(result) TEST_DECLARE_OUTPUT_PARAMETER(result);
virtual void SetUp() virtual void SetUp()
{ {
@ -92,9 +92,9 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool)
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_32FC1, -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);
UMAT_UPLOAD_OUTPUT_PARAMETER(result) UMAT_UPLOAD_OUTPUT_PARAMETER(result);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)

View File

@ -57,8 +57,8 @@ PARAM_TEST_CASE(MedianFilter, MatDepth, Channels, int, bool)
int ksize; int ksize;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -76,8 +76,8 @@ PARAM_TEST_CASE(MedianFilter, MatDepth, Channels, int, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -MAX_VALUE, MAX_VALUE); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -MAX_VALUE, MAX_VALUE);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)

View File

@ -57,8 +57,8 @@ PARAM_TEST_CASE(PyrTestBase, MatDepth, Channels, bool)
int depth, channels; int depth, channels;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -75,8 +75,8 @@ PARAM_TEST_CASE(PyrTestBase, MatDepth, Channels, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, dst_roiSize, dstBorder, CV_MAKETYPE(depth, channels), -MAX_VALUE, MAX_VALUE); randomSubMat(dst, dst_roi, dst_roiSize, dstBorder, CV_MAKETYPE(depth, channels), -MAX_VALUE, MAX_VALUE);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)

View File

@ -62,8 +62,8 @@ PARAM_TEST_CASE(SepFilter2D, MatDepth, Channels, BorderType, bool, bool)
bool useRoi; bool useRoi;
Mat kernelX, kernelY; Mat kernelX, kernelY;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -103,8 +103,8 @@ PARAM_TEST_CASE(SepFilter2D, MatDepth, Channels, BorderType, bool, bool)
anchor.x = -1; anchor.x = -1;
anchor.y = -1; anchor.y = -1;
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)

View File

@ -73,8 +73,8 @@ PARAM_TEST_CASE(WarpTestBase, MatType, Interpolation, bool, bool)
Size dsize; Size dsize;
bool useRoi, mapInverse; bool useRoi, mapInverse;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -98,13 +98,13 @@ PARAM_TEST_CASE(WarpTestBase, MatType, Interpolation, bool, bool)
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);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)
{ {
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
}; };
@ -164,8 +164,8 @@ PARAM_TEST_CASE(Resize, MatType, double, double, Interpolation, bool)
double fx, fy; double fx, fy;
bool useRoi; bool useRoi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -202,7 +202,7 @@ PARAM_TEST_CASE(Resize, MatType, double, double, Interpolation, bool)
void Near(double threshold = 0.0) void Near(double threshold = 0.0)
{ {
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
}; };
@ -230,10 +230,10 @@ PARAM_TEST_CASE(Remap, MatDepth, Channels, std::pair<MatType, MatType>, BorderTy
Scalar val; Scalar val;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_INPUT_PARAMETER(map1) TEST_DECLARE_INPUT_PARAMETER(map1);
TEST_DECLARE_INPUT_PARAMETER(map2) TEST_DECLARE_INPUT_PARAMETER(map2);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -269,16 +269,16 @@ PARAM_TEST_CASE(Remap, MatDepth, Channels, std::pair<MatType, MatType>, BorderTy
randomSubMat(map2, map2_roi, dstROISize, map2Border, map2Type, mapMinValue, mapMaxValue); randomSubMat(map2, map2_roi, dstROISize, map2Border, map2Type, mapMinValue, mapMaxValue);
} }
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_INPUT_PARAMETER(map1) UMAT_UPLOAD_INPUT_PARAMETER(map1);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
if (noType != map2Type) if (noType != map2Type)
UMAT_UPLOAD_INPUT_PARAMETER(map2) UMAT_UPLOAD_INPUT_PARAMETER(map2);
} }
void Near(double threshold = 0.0) void Near(double threshold = 0.0)
{ {
OCL_EXPECT_MATS_NEAR(dst, threshold) OCL_EXPECT_MATS_NEAR(dst, threshold);
} }
}; };

View File

@ -19,8 +19,8 @@ PARAM_TEST_CASE(FastNlMeansDenoisingTestBase, Channels, bool)
float h; float h;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(src) TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst) TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp() virtual void SetUp()
{ {
@ -52,8 +52,8 @@ PARAM_TEST_CASE(FastNlMeansDenoisingTestBase, Channels, bool)
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 0, 255); randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 0, 255);
UMAT_UPLOAD_INPUT_PARAMETER(src) UMAT_UPLOAD_INPUT_PARAMETER(src);
UMAT_UPLOAD_OUTPUT_PARAMETER(dst) UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
} }
}; };
@ -68,7 +68,7 @@ OCL_TEST_P(FastNlMeansDenoising, Mat)
OCL_OFF(cv::fastNlMeansDenoising(src_roi, dst_roi, h, templateWindowSize, searchWindowSize)); OCL_OFF(cv::fastNlMeansDenoising(src_roi, dst_roi, h, templateWindowSize, searchWindowSize));
OCL_ON(cv::fastNlMeansDenoising(usrc_roi, udst_roi, h, templateWindowSize, searchWindowSize)); OCL_ON(cv::fastNlMeansDenoising(usrc_roi, udst_roi, h, templateWindowSize, searchWindowSize));
OCL_EXPECT_MATS_NEAR(dst, 1) OCL_EXPECT_MATS_NEAR(dst, 1);
} }
} }
@ -83,7 +83,7 @@ OCL_TEST_P(FastNlMeansDenoisingColored, Mat)
OCL_OFF(cv::fastNlMeansDenoisingColored(src_roi, dst_roi, h, h, templateWindowSize, searchWindowSize)); OCL_OFF(cv::fastNlMeansDenoisingColored(src_roi, dst_roi, h, h, templateWindowSize, searchWindowSize));
OCL_ON(cv::fastNlMeansDenoisingColored(usrc_roi, udst_roi, h, h, templateWindowSize, searchWindowSize)); OCL_ON(cv::fastNlMeansDenoisingColored(usrc_roi, udst_roi, h, h, templateWindowSize, searchWindowSize));
OCL_EXPECT_MATS_NEAR(dst, 1) OCL_EXPECT_MATS_NEAR(dst, 1);
} }
} }

View File

@ -62,53 +62,73 @@ extern int test_loop_times;
#define MAX_VALUE 357 #define MAX_VALUE 357
#define EXPECT_MAT_NORM(mat, eps) \ #define EXPECT_MAT_NORM(mat, eps) \
do \
{ \ { \
EXPECT_LE(TestUtils::checkNorm(mat), eps) \ EXPECT_LE(TestUtils::checkNorm1(mat), eps) \
} } while ((void)0, 0)
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \ #define EXPECT_MAT_NEAR(mat1, mat2, eps) \
do \
{ \ { \
ASSERT_EQ(mat1.type(), mat2.type()); \ ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \ ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(TestUtils::checkNorm(mat1, mat2), eps) \ EXPECT_LE(TestUtils::checkNorm2(mat1, mat2), eps) \
<< "Size: " << mat1.size() << std::endl; \ << "Size: " << mat1.size() << std::endl; \
} } while ((void)0, 0)
#define EXPECT_MAT_NEAR_RELATIVE(mat1, mat2, eps) \ #define EXPECT_MAT_NEAR_RELATIVE(mat1, mat2, eps) \
do \
{ \ { \
ASSERT_EQ(mat1.type(), mat2.type()); \ ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \ ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(TestUtils::checkNormRelative(mat1, mat2), eps) \ EXPECT_LE(TestUtils::checkNormRelative(mat1, mat2), eps) \
<< "Size: " << mat1.size() << std::endl; \ << "Size: " << mat1.size() << std::endl; \
} } while ((void)0, 0)
#define OCL_EXPECT_MATS_NEAR(name, eps) \ #define OCL_EXPECT_MATS_NEAR(name, eps) \
do \
{ \ { \
EXPECT_MAT_NEAR(name ## _roi, u ## name ## _roi, eps); \ ASSERT_EQ(name ## _roi.type(), u ## name ## _roi.type()); \
int nextValue = rng.next(); \ ASSERT_EQ(name ## _roi.size(), u ## name ## _roi.size()); \
RNG dataRng1(nextValue), dataRng2(nextValue); \ EXPECT_LE(TestUtils::checkNorm2(name ## _roi, u ## name ## _roi), eps) \
dataRng1.fill(name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \ << "Size: " << name ## _roi.size() << std::endl; \
dataRng2.fill(u ## name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \ Point _offset; \
EXPECT_MAT_NEAR(name, u ## name, 0/*FLT_EPSILON*/); \ Size _wholeSize; \
} u ## name ## _roi.locateROI(_wholeSize, _offset); \
Mat _mask(name.size(), CV_8UC1, Scalar::all(255)); \
_mask(Rect(_offset, name ## _roi.size())).setTo(Scalar::all(0)); \
ASSERT_EQ(name.type(), u ## name.type()); \
ASSERT_EQ(name.size(), u ## name.size()); \
EXPECT_LE(TestUtils::checkNorm2(name, u ## name, _mask), eps) \
<< "Size: " << name ## _roi.size() << std::endl; \
} while ((void)0, 0)
#define OCL_EXPECT_MATS_NEAR_RELATIVE(name, eps) \ #define OCL_EXPECT_MATS_NEAR_RELATIVE(name, eps) \
do \
{ \ { \
EXPECT_MAT_NEAR_RELATIVE(name ## _roi, u ## name ## _roi, eps); \ ASSERT_EQ(name ## _roi.type(), u ## name ## _roi.type()); \
int nextValue = rng.next(); \ ASSERT_EQ(name ## _roi.size(), u ## name ## _roi.size()); \
RNG dataRng1(nextValue), dataRng2(nextValue); \ EXPECT_LE(TestUtils::checkNormRelative(name ## _roi, u ## name ## _roi), eps) \
dataRng1.fill(name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \ << "Size: " << name ## _roi.size() << std::endl; \
dataRng2.fill(u ## name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \ Point _offset; \
EXPECT_MAT_NEAR_RELATIVE(name, u ## name, 0/*FLT_EPSILON*/); \ Size _wholeSize; \
} name ## _roi.locateROI(_wholeSize, _offset); \
Mat _mask(name.size(), CV_8UC1, Scalar::all(255)); \
_mask(Rect(_offset, name ## _roi.size())).setTo(Scalar::all(0)); \
ASSERT_EQ(name.type(), u ## name.type()); \
ASSERT_EQ(name.size(), u ## name.size()); \
EXPECT_LE(TestUtils::checkNormRelative(name, u ## name, _mask), eps) \
<< "Size: " << name ## _roi.size() << std::endl; \
} while ((void)0, 0)
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \ #define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
do \
{ \ { \
ASSERT_EQ(mat1.type(), mat2.type()); \ ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \ ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkSimilarity(mat1, mat2), eps) \ EXPECT_LE(checkSimilarity(mat1, mat2), eps) \
<< "Size: " << mat1.size() << std::endl; \ << "Size: " << mat1.size() << std::endl; \
} } while ((void)0, 0)
using perf::MatDepth; using perf::MatDepth;
using perf::MatType; using perf::MatType;
@ -205,28 +225,30 @@ struct CV_EXPORTS TestUtils
static cv::Mat readImage(const String &fileName, int flags = cv::IMREAD_COLOR); static cv::Mat readImage(const String &fileName, int flags = cv::IMREAD_COLOR);
static cv::Mat readImageType(const String &fname, int type); static cv::Mat readImageType(const String &fname, int type);
static double checkNorm(InputArray m); static double checkNorm1(InputArray m, InputArray mask = noArray());
static double checkNorm(InputArray m1, InputArray m2); static double checkNorm2(InputArray m1, InputArray m2, InputArray mask = noArray());
static double checkSimilarity(InputArray m1, InputArray m2); static double checkSimilarity(InputArray m1, InputArray m2);
static void showDiff(InputArray _src, InputArray _gold, InputArray _actual, double eps, bool alwaysShow); static void showDiff(InputArray _src, InputArray _gold, InputArray _actual, double eps, bool alwaysShow);
static inline double checkNormRelative(InputArray m1, InputArray m2) static inline double checkNormRelative(InputArray m1, InputArray m2, InputArray mask = noArray())
{ {
return cv::norm(m1.getMat(), m2.getMat(), cv::NORM_INF) / return cv::norm(m1.getMat(), m2.getMat(), cv::NORM_INF, mask) /
std::max((double)std::numeric_limits<float>::epsilon(), std::max((double)std::numeric_limits<float>::epsilon(),
(double)std::max(cv::norm(m1.getMat(), cv::NORM_INF), norm(m2.getMat(), cv::NORM_INF))); (double)std::max(cv::norm(m1.getMat(), cv::NORM_INF), norm(m2.getMat(), cv::NORM_INF)));
} }
}; };
#define TEST_DECLARE_INPUT_PARAMETER(name) Mat name, name ## _roi; UMat u ## name, u ## name ## _roi; #define TEST_DECLARE_INPUT_PARAMETER(name) Mat name, name ## _roi; UMat u ## name, u ## name ## _roi
#define TEST_DECLARE_OUTPUT_PARAMETER(name) TEST_DECLARE_INPUT_PARAMETER(name) #define TEST_DECLARE_OUTPUT_PARAMETER(name) TEST_DECLARE_INPUT_PARAMETER(name)
#define UMAT_UPLOAD_INPUT_PARAMETER(name) \ #define UMAT_UPLOAD_INPUT_PARAMETER(name) \
do \
{ \ { \
name.copyTo(u ## name); \ name.copyTo(u ## name); \
Size _wholeSize; Point ofs; name ## _roi.locateROI(_wholeSize, ofs); \ Size _wholeSize; Point ofs; name ## _roi.locateROI(_wholeSize, ofs); \
u ## name ## _roi = u ## name(Rect(ofs.x, ofs.y, name ## _roi.size().width, name ## _roi.size().height)); \ u ## name ## _roi = u ## name(Rect(ofs.x, ofs.y, name ## _roi.size().width, name ## _roi.size().height)); \
} } while ((void)0, 0)
#define UMAT_UPLOAD_OUTPUT_PARAMETER(name) UMAT_UPLOAD_INPUT_PARAMETER(name) #define UMAT_UPLOAD_OUTPUT_PARAMETER(name) UMAT_UPLOAD_INPUT_PARAMETER(name)
template <typename T> template <typename T>

View File

@ -223,14 +223,14 @@ Mat TestUtils::readImageType(const String &fname, int type)
return src; return src;
} }
double TestUtils::checkNorm(InputArray m) double TestUtils::checkNorm1(InputArray m, InputArray mask)
{ {
return norm(m.getMat(), NORM_INF); return norm(m.getMat(), NORM_INF, mask);
} }
double TestUtils::checkNorm(InputArray m1, InputArray m2) double TestUtils::checkNorm2(InputArray m1, InputArray m2, InputArray mask)
{ {
return norm(m1.getMat(), m2.getMat(), NORM_INF); return norm(m1.getMat(), m2.getMat(), NORM_INF, mask);
} }
double TestUtils::checkSimilarity(InputArray m1, InputArray m2) double TestUtils::checkSimilarity(InputArray m1, InputArray m2)

View File

@ -70,7 +70,7 @@ OCL_TEST_P(Mog2_Update, Accuracy)
OCL_ON (mog2_ocl->apply(frame, u_foreground)); OCL_ON (mog2_ocl->apply(frame, u_foreground));
if (detectShadow) if (detectShadow)
EXPECT_MAT_SIMILAR(foreground, u_foreground, 15e-3) EXPECT_MAT_SIMILAR(foreground, u_foreground, 15e-3);
else else
EXPECT_MAT_NEAR(foreground, u_foreground, 0); EXPECT_MAT_NEAR(foreground, u_foreground, 0);
} }
@ -133,4 +133,4 @@ OCL_INSTANTIATE_TEST_CASE_P(OCL_Video, Mog2_getBackgroundImage, (Values(DetectSh
}}// namespace cvtest::ocl }}// namespace cvtest::ocl
#endif #endif
#endif #endif

View File

@ -18,8 +18,8 @@ PARAM_TEST_CASE(UpdateMotionHistory, bool)
double timestamp, duration; double timestamp, duration;
bool use_roi; bool use_roi;
TEST_DECLARE_INPUT_PARAMETER(silhouette) TEST_DECLARE_INPUT_PARAMETER(silhouette);
TEST_DECLARE_OUTPUT_PARAMETER(mhi) TEST_DECLARE_OUTPUT_PARAMETER(mhi);
virtual void SetUp() virtual void SetUp()
{ {
@ -40,8 +40,8 @@ PARAM_TEST_CASE(UpdateMotionHistory, bool)
if (timestamp < duration) if (timestamp < duration)
std::swap(timestamp, duration); std::swap(timestamp, duration);
UMAT_UPLOAD_INPUT_PARAMETER(silhouette) UMAT_UPLOAD_INPUT_PARAMETER(silhouette);
UMAT_UPLOAD_OUTPUT_PARAMETER(mhi) UMAT_UPLOAD_OUTPUT_PARAMETER(mhi);
} }
}; };
@ -54,7 +54,7 @@ OCL_TEST_P(UpdateMotionHistory, Mat)
OCL_OFF(cv::updateMotionHistory(silhouette_roi, mhi_roi, timestamp, duration)); OCL_OFF(cv::updateMotionHistory(silhouette_roi, mhi_roi, timestamp, duration));
OCL_ON(cv::updateMotionHistory(usilhouette_roi, umhi_roi, timestamp, duration)); OCL_ON(cv::updateMotionHistory(usilhouette_roi, umhi_roi, timestamp, duration));
OCL_EXPECT_MATS_NEAR(mhi, 0) OCL_EXPECT_MATS_NEAR(mhi, 0);
} }
} }

View File

@ -101,7 +101,7 @@ OCL_TEST_P(FarnebackOpticalFlow, Mat)
OCL_OFF(cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags)); OCL_OFF(cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags));
OCL_ON(cv::calcOpticalFlowFarneback(frame0, frame1, uflow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags)); OCL_ON(cv::calcOpticalFlowFarneback(frame0, frame1, uflow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags));
EXPECT_MAT_SIMILAR(flow, uflow, 0.1) EXPECT_MAT_SIMILAR(flow, uflow, 0.1);
} }
@ -117,4 +117,4 @@ OCL_INSTANTIATE_TEST_CASE_P(Video, FarnebackOpticalFlow,
} } // namespace cvtest::ocl } } // namespace cvtest::ocl
#endif // HAVE_OPENCL #endif // HAVE_OPENCL