static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst)
{
- int dcn = _dst.channels(), lcn = _lut.channels(), dtype = _dst.type();
+ int dtype = _dst.type(), lcn = _lut.channels(), dcn = CV_MAT_CN(dtype), ddepth = CV_MAT_DEPTH(dtype);
+ bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
- if (_src.dims() > 2)
+ if (_src.dims() > 2 || (!doubleSupport && ddepth == CV_64F))
return false;
UMat src = _src.getUMat(), lut = _lut.getUMat();
UMat dst = _dst.getUMat();
ocl::Kernel k("LUT", ocl::core::lut_oclsrc,
- format("-D dcn=%d -D lcn=%d -D srcT=%s -D dstT=%s", dcn, lcn,
- ocl::typeToStr(src.depth()), ocl::typeToStr(dst.depth())));
+ format("-D dcn=%d -D lcn=%d -D srcT=%s -D dstT=%s%s", dcn, lcn,
+ ocl::typeToStr(src.depth()), ocl::typeToStr(ddepth),
+ doubleSupport ? " -D DOUBLE_SUPPORT" : ""));
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::ReadOnlyNoSize(lut),
ocl::KernelArg::WriteOnly(dst));
void Near(double threshold = 0.)
{
- EXPECT_MAT_NEAR(dst, udst, threshold);
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, threshold)
}
};
void Near(double threshold = 0.)
{
- EXPECT_MAT_NEAR(dst1, udst1, threshold);
- EXPECT_MAT_NEAR(dst1_roi, udst1_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst1, threshold)
}
void Near1(double threshold = 0.)
{
- EXPECT_MAT_NEAR(dst2, udst2, threshold);
- EXPECT_MAT_NEAR(dst2_roi, udst2_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst2, threshold)
}
};
OCL_OFF(cv::transpose(src1_roi, src1_roi));
OCL_ON(cv::transpose(usrc1_roi, usrc1_roi));
- EXPECT_MAT_NEAR(src1, usrc1, 0.0);
- EXPECT_MAT_NEAR(src1_roi, usrc1_roi, 0.0);
+ OCL_EXPECT_MATS_NEAR(src1, 0)
}
}
void Near(double threshold = 0.)
{
- EXPECT_MAT_NEAR(dst, udst, threshold);
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, threshold);
}
};
void Near(double threshold)
{
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
- EXPECT_MAT_NEAR(dst, udst, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, threshold)
}
void performTest(int channelsIn, int channelsOut, int code, double threshold = 1e-3)
void Near(double threshold = 0.0, bool relative = false)
{
if (relative)
- {
- EXPECT_MAT_NEAR_RELATIVE(dst, udst, threshold);
- EXPECT_MAT_NEAR_RELATIVE(dst_roi, udst_roi, threshold);
- }
+ OCL_EXPECT_MATS_NEAR_RELATIVE(dst, threshold)
else
- {
- EXPECT_MAT_NEAR(dst, udst, threshold);
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
- }
+ OCL_EXPECT_MATS_NEAR(dst, threshold)
}
};
UMAT_UPLOAD_OUTPUT_PARAMETER(dst)
}
- void Near(double threshold = 0.0)
+ void Near()
{
- EXPECT_MAT_NEAR(dst, udst, threshold);
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, 0)
}
};
void Near2(double threshold = 0.0, bool relative = false)
{
if (relative)
- {
- EXPECT_MAT_NEAR_RELATIVE(dst2, udst2, threshold);
- EXPECT_MAT_NEAR_RELATIVE(dst2_roi, udst2_roi, threshold);
- }
+ OCL_EXPECT_MATS_NEAR_RELATIVE(dst2, threshold)
else
- {
- EXPECT_MAT_NEAR(dst2, udst2, threshold);
- EXPECT_MAT_NEAR(dst2_roi, udst2_roi, threshold);
- }
+ OCL_EXPECT_MATS_NEAR(dst2, threshold)
}
};
void Near(double threshold = 0.0)
{
- EXPECT_MAT_NEAR(dst, udst, threshold);
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, threshold)
}
};
void Near(double threshold = 0.0)
{
- EXPECT_MAT_NEAR(dst, udst, threshold);
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, threshold)
}
};
void Near(double threshold = 0.0)
{
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
- EXPECT_MAT_NEAR(dst, udst, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, threshold)
}
};
void Near(double threshold = 0.0)
{
- EXPECT_MAT_NEAR(dst, udst, threshold);
- EXPECT_MAT_NEAR(dst_roi, udst_roi, threshold);
+ OCL_EXPECT_MATS_NEAR(dst, threshold)
}
};
<< cv::format("Size: %d x %d", mat1.size().width, mat1.size().height) << std::endl; \
}
+#define OCL_EXPECT_MATS_NEAR(name, eps) \
+{ \
+ EXPECT_MAT_NEAR(name ## _roi, u ## name ## _roi, eps); \
+ int nextValue = rng.next(); \
+ RNG dataRng1(nextValue), dataRng2(nextValue); \
+ dataRng1.fill(name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \
+ dataRng2.fill(u ## name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \
+ EXPECT_MAT_NEAR(name, u ## name, 0/*FLT_EPSILON*/); \
+}
+
+#define OCL_EXPECT_MATS_NEAR_RELATIVE(name, eps) \
+{ \
+ EXPECT_MAT_NEAR_RELATIVE(name ## _roi, u ## name ## _roi, eps); \
+ int nextValue = rng.next(); \
+ RNG dataRng1(nextValue), dataRng2(nextValue); \
+ dataRng1.fill(name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \
+ dataRng2.fill(u ## name ## _roi, RNG::UNIFORM, Scalar::all(-MAX_VALUE), Scalar::all(MAX_VALUE)); \
+ EXPECT_MAT_NEAR_RELATIVE(name, u ## name, 0/*FLT_EPSILON*/); \
+}
+
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
#define OCL_OFF(fn) cv::ocl::setUseOpenCL(false); fn
#define OCL_ON(fn) cv::ocl::setUseOpenCL(true); fn
-#define OCL_ALL_DEPTHS Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F)
+#define OCL_ALL_DEPTHS Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)
#define OCL_ALL_CHANNELS Values(1, 2, 3, 4)
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA)