CV_GpuNotSupported= -216,
CV_GpuApiCallError= -217,
CV_OpenGlNotSupported= -218,
- CV_OpenGlApiCallError= -219
+ CV_OpenGlApiCallError= -219,
+ CV_OpenCLDoubleNotSupported= -220,
+ CV_OpenCLInitError= -221
};
/****************************************************************************************\
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
+
#include "perf_precomp.hpp"
+
+#ifdef HAVE_CLAMDBLAS
+
using namespace perf;
using namespace std;
using namespace cv::ocl;
using namespace cv;
using std::tr1::tuple;
using std::tr1::get;
+
///////////// Kalman Filter ////////////////////////
-typedef tuple<int> KalmanFilterType;
-typedef TestBaseWithParam<KalmanFilterType> KalmanFilterFixture;
+typedef TestBaseWithParam<int> KalmanFilterFixture;
PERF_TEST_P(KalmanFilterFixture, KalmanFilter,
::testing::Values(1000, 1500))
{
- KalmanFilterType params = GetParam();
- const int dim = get<0>(params);
+ const int dim = GetParam();
cv::Mat sample(dim, 1, CV_32FC1), dresult;
randu(sample, -1, 1);
cv::Mat statePre_;
- if(RUN_PLAIN_IMPL)
+ if (RUN_PLAIN_IMPL)
{
cv::KalmanFilter kalman;
TEST_CYCLE()
kalman.predict();
}
statePre_ = kalman.statePre;
- }else if(RUN_OCL_IMPL)
+ }
+ else if(RUN_OCL_IMPL)
{
cv::ocl::oclMat dsample(sample);
cv::ocl::KalmanFilter kalman_ocl;
kalman_ocl.predict();
}
kalman_ocl.statePre.download(statePre_);
- }else
+ }
+ else
OCL_PERF_ELSE
+
SANITY_CHECK(statePre_);
-}
\ No newline at end of file
+}
+
+#endif // HAVE_CLAMDBLAS
bool hasDouble = clCxt->supportsFeature(FEATURE_CL_DOUBLE);
if (!hasDouble && (src1.depth() == CV_64F || src2.depth() == CV_64F || dst.depth() == CV_64F))
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
static void compare_run(const oclMat &src1, const oclMat &src2, oclMat &dst, int cmpOp,
string kernelName, const cv::ocl::ProgramEntry* source)
{
- CV_Assert(src1.type() == src2.type());
dst.create(src1.size(), CV_8UC1);
- Context *clCxt = src1.clCxt;
int depth = src1.depth();
size_t localThreads[3] = { 64, 4, 1 };
args.push_back( make_pair( sizeof(cl_int), (void *)&src1.cols ));
args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows ));
- openCLExecuteKernel(clCxt, source, kernelName, globalThreads, localThreads,
+ openCLExecuteKernel(src1.clCxt, source, kernelName, globalThreads, localThreads,
args, -1, -1, buildOptions.c_str());
}
{
if (!src1.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.depth() == CV_64F)
{
- cout << "Selected device do not support double" << endl;
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
- CV_Assert(src1.channels() == 1 && src2.channels() == 1);
+ CV_Assert(src1.type() == src2.type() && src1.channels() == 1);
CV_Assert(cmpOp >= CMP_EQ && cmpOp <= CMP_NE);
compare_run(src1, src2, dst, cmpOp, "arithm_compare", &arithm_compare);
{
if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return Scalar::all(0);
}
static sumFunc functab[3] =
{
if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return cv::Scalar::all(0);
}
{
if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return cv::Scalar::all(0);
}
static sumFunc functab[3] =
arithmetic_sum<double>
};
- int ddepth = src.depth() <= CV_32S ? CV_32S : CV_64F;
+ int ddepth = std::max(src.depth(), CV_32S);
sumFunc func = functab[ddepth - CV_32S];
return func(src, SQR_SUM, ddepth);
}
void cv::ocl::meanStdDev(const oclMat &src, Scalar &mean, Scalar &stddev)
{
+ if (src.depth() == CV_64F && !src.clCxt->supportsFeature(FEATURE_CL_DOUBLE))
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
double total = 1.0 / src.size().area();
mean = sum(src);
ostringstream stream;
stream << "-D T=" << typeMap[src.depth()] << channelMap[src.channels()];
stream << " -D MAX_VAL=" << (WT)numeric_limits<T>::max();
- stream << " -D MIN_VAL=" << (WT)numeric_limits<T>::min();
+ stream << " -D MIN_VAL=" << (numeric_limits<T>::is_integer ?
+ (WT)numeric_limits<T>::min() : -(WT)(std::numeric_limits<T>::max()));
string buildOptions = stream.str();
vector<pair<size_t , const void *> > args;
if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
static void arithm_absdiff_nonsaturate_run(const oclMat & src1, const oclMat & src2, oclMat & diff, int ntype)
{
- CV_Assert(src1.step % src1.elemSize() == 0 && (src2.empty() || src2.step % src2.elemSize() == 0));
Context *clCxt = src1.clCxt;
+ if (!clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+ CV_Assert(src1.step % src1.elemSize() == 0 && (src2.empty() || src2.step % src2.elemSize() == 0));
int ddepth = std::max(src1.depth(), CV_32S);
if (ntype == NORM_L2)
double cv::ocl::norm(const oclMat &src1, const oclMat &src2, int normType)
{
- CV_Assert(!src1.empty());
- CV_Assert(src2.empty() || (src1.type() == src2.type() && src1.size() == src2.size()));
-
if (!src1.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return -1;
}
+ CV_Assert(src2.empty() || (src1.type() == src2.type() && src1.size() == src2.size()));
bool isRelative = (normType & NORM_RELATIVE) != 0;
normType &= NORM_TYPE_MASK;
static void arithmetic_flip_rows_run(const oclMat &src, oclMat &dst, string kernelName)
{
- if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.type() == CV_64F)
- {
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
- return;
- }
-
- CV_Assert(src.cols == dst.cols && src.rows == dst.rows);
-
- CV_Assert(src.type() == dst.type());
-
- Context *clCxt = src.clCxt;
int channels = dst.oclchannels();
int depth = dst.depth();
args.push_back( make_pair( sizeof(cl_int), (void *)&rows ));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 ));
- openCLExecuteKernel(clCxt, &arithm_flip, kernelName, globalThreads, localThreads, args, -1, depth);
+ openCLExecuteKernel(src.clCxt, &arithm_flip, kernelName, globalThreads, localThreads, args, -1, depth);
}
static void arithmetic_flip_cols_run(const oclMat &src, oclMat &dst, string kernelName, bool isVertical)
{
- if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.type() == CV_64F)
- {
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
- return;
- }
-
- CV_Assert(src.cols == dst.cols && src.rows == dst.rows);
- CV_Assert(src.type() == dst.type());
-
- Context *clCxt = src.clCxt;
int channels = dst.oclchannels();
int depth = dst.depth();
const cv::ocl::ProgramEntry* source = isVertical ? &arithm_flip_rc : &arithm_flip;
- openCLExecuteKernel(clCxt, source, kernelName, globalThreads, localThreads, args, src.oclchannels(), depth);
+ openCLExecuteKernel(src.clCxt, source, kernelName, globalThreads, localThreads, args, src.oclchannels(), depth);
}
void cv::ocl::flip(const oclMat &src, oclMat &dst, int flipCode)
{
+ if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
dst.create(src.size(), src.type());
+
if (flipCode == 0)
- {
arithmetic_flip_rows_run(src, dst, "arithm_flip_rows");
- }
else if (flipCode > 0)
arithmetic_flip_cols_run(src, dst, "arithm_flip_cols", false);
else
static void arithmetic_lut_run(const oclMat &src, const oclMat &lut, oclMat &dst, string kernelName)
{
- Context *clCxt = src.clCxt;
int sdepth = src.depth();
int src_step1 = src.step1(), dst_step1 = dst.step1();
int src_offset1 = src.offset / src.elemSize1(), dst_offset1 = dst.offset / dst.elemSize1();
args.push_back( make_pair( sizeof(cl_int), (void *)&src_step1 ));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 ));
- openCLExecuteKernel(clCxt, &arithm_LUT, kernelName, globalSize, localSize,
+ openCLExecuteKernel(src.clCxt, &arithm_LUT, kernelName, globalSize, localSize,
args, lut.oclchannels(), -1, buildOptions.c_str());
}
void cv::ocl::LUT(const oclMat &src, const oclMat &lut, oclMat &dst)
{
+ if (!lut.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && lut.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
int cn = src.channels(), depth = src.depth();
+
CV_Assert(depth == CV_8U || depth == CV_8S);
CV_Assert(lut.channels() == 1 || lut.channels() == src.channels());
CV_Assert(lut.rows == 1 && lut.cols == 256);
+
dst.create(src.size(), CV_MAKETYPE(lut.depth(), cn));
- string kernelName = "LUT";
- arithmetic_lut_run(src, lut, dst, kernelName);
+ arithmetic_lut_run(src, lut, dst, "LUT");
}
//////////////////////////////////////////////////////////////////////////////
Context *clCxt = src.clCxt;
if (!clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
static void arithmetic_magnitude_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName)
{
- if (!src1.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.type() == CV_64F)
- {
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
- return;
- }
-
- Context *clCxt = src1.clCxt;
int channels = dst.oclchannels();
int depth = dst.depth();
args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows ));
args.push_back( make_pair( sizeof(cl_int), (void *)&cols ));
- openCLExecuteKernel(clCxt, &arithm_magnitude, kernelName, globalThreads, localThreads, args, -1, depth);
+ openCLExecuteKernel(src1.clCxt, &arithm_magnitude, kernelName, globalThreads, localThreads, args, -1, depth);
}
void cv::ocl::magnitude(const oclMat &src1, const oclMat &src2, oclMat &dst)
{
+ if (!src1.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
CV_Assert(src1.type() == src2.type() && src1.size() == src2.size() &&
(src1.depth() == CV_32F || src1.depth() == CV_64F));
static void arithmetic_phase_run(const oclMat &src1, const oclMat &src2, oclMat &dst, string kernelName, const cv::ocl::ProgramEntry* source)
{
- if (!src1.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.type() == CV_64F)
- {
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
- return;
- }
-
- Context *clCxt = src1.clCxt;
int depth = dst.depth(), cols1 = src1.cols * src1.oclchannels();
int src1step1 = src1.step / src1.elemSize1(), src1offset1 = src1.offset / src1.elemSize1();
int src2step1 = src2.step / src2.elemSize1(), src2offset1 = src2.offset / src2.elemSize1();
args.push_back( make_pair( sizeof(cl_int), (void *)&cols1 ));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst.rows ));
- openCLExecuteKernel(clCxt, source, kernelName, globalThreads, localThreads, args, -1, depth);
+ openCLExecuteKernel(src1.clCxt, source, kernelName, globalThreads, localThreads, args, -1, depth);
}
void cv::ocl::phase(const oclMat &x, const oclMat &y, oclMat &Angle, bool angleInDegrees)
{
+ if (!x.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && x.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
CV_Assert(x.type() == y.type() && x.size() == y.size() && (x.depth() == CV_32F || x.depth() == CV_64F));
CV_Assert(x.step % x.elemSize() == 0 && y.step % y.elemSize() == 0);
static void arithmetic_cartToPolar_run(const oclMat &src1, const oclMat &src2, oclMat &dst_mag, oclMat &dst_cart,
string kernelName, bool angleInDegrees)
{
- if (!src1.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.type() == CV_64F)
- {
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
- return;
- }
-
- Context *clCxt = src1.clCxt;
int channels = src1.oclchannels();
int depth = src1.depth();
args.push_back( make_pair( sizeof(cl_int), (void *)&cols ));
args.push_back( make_pair( sizeof(cl_int), (void *)&tmp ));
- openCLExecuteKernel(clCxt, &arithm_cartToPolar, kernelName, globalThreads, localThreads, args, -1, depth);
+ openCLExecuteKernel(src1.clCxt, &arithm_cartToPolar, kernelName, globalThreads, localThreads, args, -1, depth);
}
void cv::ocl::cartToPolar(const oclMat &x, const oclMat &y, oclMat &mag, oclMat &angle, bool angleInDegrees)
{
+ if (!x.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && x.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
CV_Assert(x.type() == y.type() && x.size() == y.size() && (x.depth() == CV_32F || x.depth() == CV_64F));
mag.create(x.size(), x.type());
static void arithmetic_ptc_run(const oclMat &src1, const oclMat &src2, oclMat &dst1, oclMat &dst2, bool angleInDegrees,
string kernelName)
{
- if (!src1.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.type() == CV_64F)
- {
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
- return;
- }
-
- Context *clCxt = src2.clCxt;
int channels = src2.oclchannels();
int depth = src2.depth();
args.push_back( make_pair( sizeof(cl_int), (void *)&cols ));
args.push_back( make_pair( sizeof(cl_int), (void *)&tmp ));
- openCLExecuteKernel(clCxt, &arithm_polarToCart, kernelName, globalThreads, localThreads, args, -1, depth);
+ openCLExecuteKernel(src1.clCxt, &arithm_polarToCart, kernelName, globalThreads, localThreads, args, -1, depth);
}
void cv::ocl::polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat &x, oclMat &y, bool angleInDegrees)
{
+ if (!magnitude.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && magnitude.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
CV_Assert(angle.depth() == CV_32F || angle.depth() == CV_64F);
+ CV_Assert(magnitude.size() == angle.size() && magnitude.type() == angle.type());
x.create(angle.size(), angle.type());
y.create(angle.size(), angle.type());
if ( magnitude.data )
- {
- CV_Assert( magnitude.size() == angle.size() && magnitude.type() == angle.type() );
arithmetic_ptc_run(magnitude, angle, x, y, angleInDegrees, "arithm_polarToCart_mag");
- }
else
arithmetic_ptc_run(magnitude, angle, x, y, angleInDegrees, "arithm_polarToCart");
}
{
if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
Context *clCxt = src.clCxt;
if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "selected device doesn't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "selected device doesn't support double");
+ return -1;
}
size_t groupnum = src.clCxt->getDeviceInfo().maxComputeUnits;
{
dst.create(src1.size(), src1.type());
-
- Context *clCxt = src1.clCxt;
int channels = dst.oclchannels();
int depth = dst.depth();
args.push_back( make_pair( sizeof(cl_int), (void *)&cols ));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1 ));
- openCLExecuteKernel(clCxt, source, kernelName, globalThreads, localThreads, args, -1, depth);
+ openCLExecuteKernel(src1.clCxt, source, kernelName, globalThreads, localThreads, args, -1, depth);
}
enum { AND = 0, OR, XOR };
static void bitwise_binary_run(const oclMat &src1, const oclMat &src2, const Scalar& src3, const oclMat &mask,
oclMat &dst, int operationType)
{
- Context *clCxt = src1.clCxt;
- if (!clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src1.depth() == CV_64F)
- {
- cout << "Selected device does not support double" << endl;
- return;
- }
-
CV_Assert(operationType >= AND && operationType <= XOR);
CV_Assert(src2.empty() || (!src2.empty() && src1.type() == src2.type() && src1.size() == src2.size()));
CV_Assert(mask.empty() || (!mask.empty() && mask.type() == CV_8UC1 && mask.size() == src1.size()));
args.push_back( make_pair( sizeof(cl_int), (void *)&cols1 ));
args.push_back( make_pair( sizeof(cl_int), (void *)&src1.rows ));
- openCLExecuteKernel(clCxt, mask.empty() ? (!src2.empty() ? &arithm_bitwise_binary : &arithm_bitwise_binary_scalar) :
+ openCLExecuteKernel(src1.clCxt, mask.empty() ? (!src2.empty() ? &arithm_bitwise_binary : &arithm_bitwise_binary_scalar) :
(!src2.empty() ? &arithm_bitwise_binary_mask : &arithm_bitwise_binary_scalar_mask),
kernelName, globalThreads, localThreads,
args, -1, -1, buildOptions.c_str());
void cv::ocl::bitwise_not(const oclMat &src, oclMat &dst)
{
- if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.type() == CV_64F)
+ if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- cout << "Selected device does not support double" << endl;
+ CV_Error(CV_OpenCLDoubleNotSupported, "selected device doesn't support double");
return;
}
dst.create(src.size(), src.type());
- string kernelName = "arithm_bitwise_not";
- bitwise_unary_run(src, dst, kernelName, &arithm_bitwise_not);
+ bitwise_unary_run(src, dst, "arithm_bitwise_not", &arithm_bitwise_not);
}
void cv::ocl::bitwise_or(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask)
static void transpose_run(const oclMat &src, oclMat &dst, string kernelName, bool inplace = false)
{
- Context *clCxt = src.clCxt;
- if (!clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
- {
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
- return;
- }
-
const char * const typeMap[] = { "uchar", "char", "ushort", "short", "int", "float", "double" };
const char channelsString[] = { ' ', ' ', '2', '4', '4' };
std::string buildOptions = format("-D T=%s%c", typeMap[src.depth()],
args.push_back( make_pair( sizeof(cl_int), (void *)&srcoffset1 ));
args.push_back( make_pair( sizeof(cl_int), (void *)&dstoffset1 ));
- openCLExecuteKernel(clCxt, &arithm_transpose, kernelName, globalThreads, localThreads,
+ openCLExecuteKernel(src.clCxt, &arithm_transpose, kernelName, globalThreads, localThreads,
args, -1, -1, buildOptions.c_str());
}
void cv::ocl::transpose(const oclMat &src, oclMat &dst)
{
- CV_Assert(src.depth() <= CV_64F && src.channels() <= 4);
+ if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
if ( src.data == dst.data && src.cols == src.rows && dst.offset == src.offset
&& dst.size() == src.size())
bool hasDouble = clCxt->supportsFeature(FEATURE_CL_DOUBLE);
if (!hasDouble && src1.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
static void arithmetic_pow_run(const oclMat &src1, double p, oclMat &dst, string kernelName, const cv::ocl::ProgramEntry* source)
{
- CV_Assert(src1.cols == dst.cols && src1.rows == dst.rows);
- CV_Assert(src1.type() == dst.type());
-
- Context *clCxt = src1.clCxt;
int channels = dst.oclchannels();
int depth = dst.depth();
else
args.push_back( make_pair( sizeof(cl_double), (void *)&p ));
- openCLExecuteKernel(clCxt, source, kernelName, globalThreads, localThreads, args, -1, depth);
+ openCLExecuteKernel(src1.clCxt, source, kernelName, globalThreads, localThreads, args, -1, depth);
}
void cv::ocl::pow(const oclMat &x, double p, oclMat &y)
{
- if (!x.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && x.type() == CV_64F)
+ if (!x.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && x.depth() == CV_64F)
{
- cout << "Selected device do not support double" << endl;
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
CV_Assert(x.depth() == CV_32F || x.depth() == CV_64F);
y.create(x.size(), x.type());
- string kernelName = "arithm_pow";
- arithmetic_pow_run(x, p, y, kernelName, &arithm_pow);
+ arithmetic_pow_run(x, p, y, "arithm_pow", &arithm_pow);
}
//////////////////////////////////////////////////////////////////////////////
void cv::ocl::setIdentity(oclMat& src, const Scalar & scalar)
{
- Context *clCxt = Context::getContext();
- if (!clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
+ if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device doesn't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
oclMat sc(1, 1, src.type(), scalar);
args.push_back( make_pair( sizeof(cl_mem), (void *)&sc.data ));
- openCLExecuteKernel(clCxt, &arithm_setidentity, "setIdentity", global_threads, local_threads,
+ openCLExecuteKernel(src.clCxt, &arithm_setidentity, "setIdentity", global_threads, local_threads,
args, -1, -1, buildOptions.c_str());
}
{
if (initializeOpenCLDevices() == 0)
{
- CV_Error(CV_GpuNotSupported, "OpenCL not available");
+ CV_Error(CV_OpenCLInitError, "OpenCL not available");
}
}
if (!__deviceSelected)
{
if (!selectOpenCLDevice())
{
- CV_Error(CV_GpuNotSupported, "Can't select OpenCL device");
+ CV_Error(CV_OpenCLInitError, "Can't select OpenCL device");
}
}
}
{
if (!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.type() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device don't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
CV_Assert(src.type() == CV_8UC1);
if(!src.clCxt->supportsFeature(ocl::FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "select device don't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "select device don't support double");
return;
}
{
if(!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "select device don't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "select device don't support double");
}
CV_Assert(src.cols >= blockSize / 2 && src.rows >= blockSize / 2);
CV_Assert(borderType == cv::BORDER_CONSTANT || borderType == cv::BORDER_REFLECT101 || borderType == cv::BORDER_REPLICATE || borderType == cv::BORDER_REFLECT);
{
if(!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.depth() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "select device don't support double");
+ CV_Error(CV_OpenCLDoubleNotSupported, "select device don't support double");
}
CV_Assert(src.cols >= blockSize / 2 && src.rows >= blockSize / 2);
CV_Assert(borderType == cv::BORDER_CONSTANT || borderType == cv::BORDER_REFLECT101 || borderType == cv::BORDER_REPLICATE || borderType == cv::BORDER_REFLECT);
if( src.depth() != CV_8U || src.oclchannels() != 4 )
CV_Error( CV_StsUnsupportedFormat, "Only 8-bit, 4-channel images are supported" );
- // if(!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE))
- // {
- // CV_Error( CV_GpuNotSupported, "Selected device doesn't support double, so a deviation exists.\nIf the accuracy is acceptable, the error can be ignored.\n");
- // }
+// if(!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE))
+// {
+// CV_Error( CV_OpenCLDoubleNotSupportedNotSupported, "Selected device doesn't support double, so a deviation exists.\nIf the accuracy is acceptable, the error can be ignored.\n");
+// return;
+// }
dstr.create( src.size(), CV_8UC4 );
dstsp.create( src.size(), CV_16SC2 );
{
//if(src.clCxt -> impl -> double_support == 0 && src.type() == CV_64F)
//{
- // CV_Error(CV_GpuNotSupported, "Selected device don't support double\r\n");
+ // CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
// return;
//}
void cv::ocl::oclMat::upload(const Mat &m)
{
+ if (!Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE) && m.depth() == CV_64F)
+ {
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
+ return;
+ }
+
CV_DbgAssert(!m.empty());
Size wholeSize;
Point ofs;
if (!clCxt->supportsFeature(FEATURE_CL_DOUBLE) &&
(depth() == CV_64F || dst.depth() == CV_64F))
{
- CV_Error(CV_GpuNotSupported, "Selected device don't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
{
if(!mat_dst.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && mat_dst.type() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device don't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
if(!mat_src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && mat_src.type() == CV_64F)
{
- CV_Error(CV_GpuNotSupported, "Selected device don't support double\r\n");
+ CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
void calc_non_rbf_base( int vec_count, const int row_idx, Qfloat* results, Mat& src);
void calc_rbf( int vec_count, const int row_idx, Qfloat* results, Mat& src);
};
+
class CvSVMSolver_ocl: public CvSVMSolver
{
public:
int idx;
float val;
} CvSparseVecElem32f;
+
static int icvCmpSparseVecElems( const void* a, const void* b )
{
return ((CvSparseVecElem32f*)a)->idx - ((CvSparseVecElem32f*)b)->idx;
}
+
void cvPreparePredictData( const CvArr* sample, int dims_all, const CvMat* comp_idx,
int class_count, const CvMat* prob, float** row_sample,
int as_sparse CV_DEFAULT(0) );
+
void cvPreparePredictData( const CvArr* _sample, int dims_all,
const CvMat* comp_idx, int class_count,
const CvMat* prob, float** _row_sample,
}
if( d == 1 )
- {
sizes[1] = 1;
- }
if( sizes[0] + sizes[1] - 1 != dims_all )
CV_ERROR( CV_StsUnmatchedSizes,
sample_step = CV_IS_MAT_CONT(sample->type) ? 1 : sample->step / sizeof(row_sample[0]);
if( !comp_idx && CV_IS_MAT_CONT(sample->type) && !as_sparse )
- {
*_row_sample = sample_data;
- }
else
{
CV_CALL( row_sample = (float*)cvAlloc( vec_size ));
if( !comp_idx )
for( i = 0; i < dims_selected; i++ )
- {
row_sample[i] = sample_data[sample_step * i];
- }
else
{
int* comp = comp_idx->data.i;
for( i = 0; i < dims_selected; i++ )
- {
row_sample[i] = sample_data[sample_step * comp[i]];
- }
}
*_row_sample = row_sample;
CV_CALL( inverse_comp_idx = (int*)cvAlloc( dims_all * sizeof(int) ));
memset( inverse_comp_idx, -1, dims_all * sizeof(int) );
for( i = 0; i < dims_selected; i++ )
- {
inverse_comp_idx[comp_idx->data.i[i]] = i;
- }
}
if( !as_sparse )
{
idx = inverse_comp_idx[idx];
if( idx < 0 )
- {
continue;
- }
}
row_sample[idx] = *(float*)CV_NODE_VAL( sparse, node );
}
{
idx = inverse_comp_idx[idx];
if( idx < 0 )
- {
continue;
- }
}
ptr->idx = idx;
ptr->val = *(float*)CV_NODE_VAL( sparse, node );
__END__;
if( inverse_comp_idx )
- {
cvFree( &inverse_comp_idx );
- }
if( cvGetErrStatus() < 0 && _row_sample )
{
*_row_sample = 0;
}
}
+
float CvSVM_OCL::predict( const int row_index, int row_len, Mat& src, bool returnDFVal ) const
{
assert( kernel );
((CvSVMKernel_ocl*)kernel)->calc( sv_count, row_index, buffer, src);
for( i = 0; i < sv_count; i++ )
- {
sum += buffer[i] * df->alpha[i];
- }
result = params.svm_type == ONE_CLASS ? (float)(sum > 0) : (float)sum;
}
double sum = 0.;
for( i = 0; i < class_count; i++ )
- {
for( j = i + 1; j < class_count; j++, df++ )
{
sum = -df->rho;
int sv_count = df->sv_count;
for( k = 0; k < sv_count; k++ )
- {
sum += df->alpha[k] * buffer[df->sv_index[k]];
- }
vote[sum > 0 ? i : j]++;
}
- }
for( i = 1, k = 0; i < class_count; i++ )
- {
if( vote[i] > vote[k] )
- {
k = i;
- }
- }
+
result = returnDFVal && class_count == 2 ? (float)sum : (float)(class_labels->data.i[k]);
}
else
return result;
}
+
float CvSVM_OCL::predict( const Mat& _sample, bool returnDFVal ) const
{
CvMat sample = _sample;
return CvSVM::predict(&sample, returnDFVal);
}
+
float CvSVM_OCL::predict( const int row_index, Mat& src, bool returnDFVal) const
{
float result = 0;
return result;
}
+
#undef get_C
#define get_C(i) (C[y[i]>0])
#undef is_upper_bound
{
params = _params;
}
+
float* CvSVMSolver_ocl::get_row( int i, float* dst, Mat& src )
{
bool existed = false;
float* row = get_row_base( i, &existed, src);
return (this->*get_row_func)( i, row, dst, existed );
}
+
float* CvSVMSolver_ocl::get_row_base( int i, bool* _existed, Mat& src )
{
int i1 = i < sample_count ? i : i - sample_count;
row->prev->next = row->next->prev = row;
if( !existed )
- {
((CvSVMKernel_ocl*)kernel)->calc( sample_count, i1, row->data, src);
- }
if( _existed )
- {
*_existed = existed;
- }
return row->data;
}
#ifndef HAVE_CLAMDBLAS
+
static void matmul_sigmod(oclMat & src, oclMat & src2, oclMat & dst, int src_rows, int src2_cols, int var_count, double alpha1, double beta1)
{
Context *clCxt = Context::getContext();
}
openCLExecuteKernel(clCxt, &svm, kernelName, globalThreads, localThreads, args, -1, -1);
}
+
static void matmul_poly(oclMat & src, oclMat & src2, oclMat & dst, int src_rows, int src2_cols, int var_count, double alpha1, double beta1, double degree1, bool flag)
{
Context *clCxt = Context::getContext();
}
openCLExecuteKernel(clCxt, &svm, kernelName, globalThreads, localThreads, args, -1, -1, build_options);
}
+
static void matmul_linear(oclMat & src, oclMat & src2, oclMat & dst, int src_rows, int src2_cols, int var_count, double alpha1, double beta1)
{
Context *clCxt = Context::getContext();
}
openCLExecuteKernel(clCxt, &svm, kernelName, globalThreads, localThreads, args, -1, -1);
}
+
#endif // #ifndef HAVE_CLAMDBLAS
static void matmul_rbf(oclMat& src, oclMat& src_e, oclMat& dst, int src_rows, int src2_cols, int var_count, double gamma1, bool flag)
char build_options[50];
if(flag)
- {
sprintf(build_options, "-D ADDEXP");
- }
+
vector< pair<size_t, const void *> > args;
args.push_back(make_pair(sizeof(cl_mem), (void* )&src.data));
args.push_back(make_pair(sizeof(cl_int), (void* )&src_step));
args.push_back(make_pair(sizeof(cl_float), (void* )&gamma));
}
else
- {
args.push_back(make_pair(sizeof(cl_double), (void* )&gamma1));
- }
openCLExecuteKernel(clCxt, &svm, kernelName, globalThreads, localThreads, args, -1, -1, build_options);
}
CV_CALL( cvPreparePredictData(&sample, var_all, var_idx,
class_count, 0, &row_sample ));
for(int j = 0; j < var_count; ++j)
- {
src_temp.at<float>(i, j) = row_sample[j];
- }
__END__;
}
Mat dst1;
- double alpha1 = 0.0, beta1 = 0.0, gamma1 = 0.0, degree1 = 0.0;
+ double alpha1 = 0.0, beta1 = 0.0, gamma1 = 0.0;
if(params.kernel_type == CvSVM::LINEAR)
{
alpha1 = 1;
{
alpha1 = params.gamma;
beta1 = params.coef0;
- degree1 = params.degree;
}
if(params.kernel_type == CvSVM::SIGMOID)
{
beta1 = - 2 * params.coef0;
}
if(params.kernel_type == CvSVM::RBF)
- {
gamma1 = - params.gamma;
- }
Mat sv_temp = Mat(sv_total, var_count, CV_32FC1, Scalar::all(0));
for(int i = 0; i < sv_total; ++i)
- {
for(int j = 0; j < var_count; ++j)
- {
sv_temp.at<float>(i, j) = sv[i][j];
- }
- }
+
oclMat src(sample_count, var_count, CV_32FC1, Scalar::all(0));
oclMat sv_;
src.upload(src_temp);
oclMat dst;
-#if defined HAVE_CLAMDBLAS
+#ifdef HAVE_CLAMDBLAS
dst = oclMat(sample_count, sv_total, CV_32FC1);
oclMat src3(sample_count, sv_total, CV_32FC1, Scalar::all(1));
}
#else
+ double degree1 = 0.0;
+ if (params.kernel_type == CvSVM::POLY)
+ degree1 = params.degree;
if(!Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE))
- {
dst = oclMat(sample_count, sv_total, CV_32FC1);
- }
else
- {
dst = oclMat(sample_count, sv_total, CV_64FC1);
- }
+
if(params.kernel_type == CvSVM::LINEAR)
{
sv_.upload(sv_temp);
{
sv_.upload(sv_temp);
if(sample_count > 0)
- {
matmul_poly(src, sv_, dst, sample_count, sv_total, var_count, alpha1, beta1, degree1, true);
- }
else
- {
matmul_poly(src, sv_, dst, sample_count, sv_total, var_count, alpha1, beta1, degree1, false);
- }
}
#endif
{
sv_.upload(sv_temp);
if(!Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE))
- {
dst = oclMat(sample_count, sv_total, CV_32FC1);
- }
else
- {
dst = oclMat(sample_count, sv_total, CV_64FC1);
- }
+
if(sample_count > 0)
- {
matmul_rbf(src, sv_, dst, sample_count, sv_total, var_count, gamma1, true);
- }
else
- {
matmul_rbf(src, sv_, dst, sample_count, sv_total, var_count, gamma1, false);
- }
}
dst.download(dst1);
{
int r = (int)this->predict(i, dst1);
if (results)
- {
results->data.fl[i] = (float)r;
- }
if (i == 0)
- {
result = (float)r;
- }
}
return result;
}
+
void CvSVM_OCL::predict( cv::InputArray _samples, cv::OutputArray _results ) const
{
_results.create(_samples.size().height, 1, CV_32F);
CvMat samples = _samples.getMat(), results = _results.getMat();
predict(&samples, &results);
}
+
bool CvSVMSolver_ocl::solve_generic( CvSVMSolutionInfo& si )
{
int iter = 0;
}
}
Mat dst1;
- double alpha1 = 0.0, beta1 = 0.0, gamma1 = 0.0, degree1 = 0.0;
+ double alpha1 = 0.0, beta1 = 0.0, gamma1 = 0.0;
if(params->kernel_type == CvSVM::LINEAR)
{
alpha1 = 1;
{
alpha1 = params->gamma;
beta1 = params->coef0;
- degree1 = params->degree;
}
if(params->kernel_type == CvSVM::SIGMOID)
{
src.upload(src1);
oclMat dst;
-#if defined HAVE_CLAMDBLAS
+#ifdef HAVE_CLAMDBLAS
dst = oclMat(sample_count, sample_count, CV_32FC1);
oclMat src3(sample_count, sample_count, CV_32FC1, Scalar::all(1));
}
#else
+ double degree1 = 0.0;
+ if(params->kernel_type == CvSVM::POLY)
+ degree1 = params->degree;
+
if(!Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE))
- {
dst = oclMat(sample_count, sample_count, CV_32FC1);
- }
else
- {
dst = oclMat(sample_count, sample_count, CV_64FC1);
- }
+
if(params->kernel_type == CvSVM::LINEAR )
{
src_e = src;
{
src_e = src;
if(sample_count > 0)
- {
matmul_poly(src, src_e, dst, sample_count, sample_count, var_count, alpha1, beta1, degree1, true);
- }
else
- {
matmul_poly(src, src_e, dst, sample_count, sample_count, var_count, alpha1, beta1, degree1, false);
- }
}
#endif
{
src_e = src;
if(!Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE))
- {
dst = oclMat(sample_count, sample_count, CV_32FC1);
- }
else
- {
dst = oclMat(sample_count, sample_count, CV_64FC1);
- }
+
if(sample_count > 0)
- {
matmul_rbf(src, src_e, dst, sample_count, sample_count, var_count, gamma1, true);
- }
else
- {
matmul_rbf(src, src_e, dst, sample_count, sample_count, var_count, gamma1, false);
- }
}
dst.download(dst1);
for( i = 0; i < alpha_count; i++ )
double alpha_i = alpha[i];
for( j = 0; j < alpha_count; j++ )
- {
G[j] += alpha_i * Q_i[j];
- }
}
}
for( i = 0; i < alpha_count; i++ )
{
if( fabs(G[i]) > 1e+300 )
- {
return false;
- }
if( fabs(alpha[i]) > 1e16 )
- {
return false;
- }
}
#endif
delta_alpha_j = alpha_j - old_alpha_j;
for( k = 0; k < alpha_count; k++ )
- {
G[k] += Q_i[k] * delta_alpha_i + Q_j[k] * delta_alpha_j;
- }
}
// calculate rho
// calculate objective value
for( i = 0, si.obj = 0; i < alpha_count; i++ )
- {
si.obj += alpha[i] * (G[i] + b[i]);
- }
si.obj *= 0.5;
const Qfloat max_val = (Qfloat)(FLT_MAX * 1e-3);
int j;
for( j = 0; j < vcount; j++ )
- {
if( results[j] > max_val )
- {
results[j] = max_val;
- }
- }
// FIXIT #endif
}
+
bool CvSVMKernel_ocl::create( const CvSVMParams* _params, Calc_ocl _calc_func, Calc _calc_func1 )
{
clear();
CvSVMKernel::clear();
CvSVMKernel_ocl::create( params, _calc_func, _calc_func1 );
}
+
void CvSVMKernel_ocl::calc_non_rbf_base( int vcount, const int row_idx, Qfloat* results, Mat& src)
{
-#if defined HAVE_CLAMDBLAS
+#ifdef HAVE_CLAMDBLAS
for(int i = 0; i < vcount; i++)
{
}
#endif
}
+
void CvSVMKernel_ocl::calc_rbf( int vcount, const int row_idx, Qfloat* results, Mat& src)
{
if(!Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE))
- {
for(int m = 0; m < vcount; m++)
- {
results[m] = (Qfloat) * src.ptr<float>(row_idx, m);
- }
- }
else
- {
for(int m = 0; m < vcount; m++)
- {
results[m] = (Qfloat) * src.ptr<double>(row_idx, m);
- }
- }
}
+
void CvSVMKernel_ocl::calc_linear( int vcount, const int row_idx, Qfloat* results, Mat& src )
{
calc_non_rbf_base( vcount, row_idx, results, src);
void CvSVMKernel_ocl::calc_poly( int vcount, const int row_idx, Qfloat* results, Mat& src)
{
-
calc_non_rbf_base( vcount, row_idx, results, src);
//FIXIT #if defined HAVE_CLAMDBLAS
CvMat R = cvMat( 1, vcount, QFLOAT_TYPE, results );
if( vcount > 0 )
- {
cvPow( &R, &R, params->degree );
- }
//FIXIT #endif
}
Qfloat t = results[j];
double e = ::exp(-fabs(t));
if( t > 0 )
- {
results[j] = (Qfloat)((1. - e) / (1. + e));
- }
else
- {
results[j] = (Qfloat)((e - 1.) / (e + 1.));
- }
}
//FIXIT #endif
}
+
CvSVM_OCL::CvSVM_OCL()
{
CvSVM();
{
kernel = new CvSVMKernel_ocl(¶ms, 0, 0);
}
+
void CvSVM_OCL::create_solver( )
{
solver = new CvSVMSolver_ocl(¶ms);
}
};
-TEST_P(Lut, Mat)
+OCL_TEST_P(Lut, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Exp;
-TEST_P(Exp, Mat)
+OCL_TEST_P(Exp, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Log;
-TEST_P(Log, Mat)
+OCL_TEST_P(Log, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Add;
-TEST_P(Add, Mat)
+OCL_TEST_P(Add, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Add, Mat_Mask)
+OCL_TEST_P(Add, Mat_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Add, Scalar)
+OCL_TEST_P(Add, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Add, Scalar_Mask)
+OCL_TEST_P(Add, Scalar_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Sub;
-TEST_P(Sub, Mat)
+OCL_TEST_P(Sub, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Sub, Mat_Mask)
+OCL_TEST_P(Sub, Mat_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Sub, Scalar)
+OCL_TEST_P(Sub, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Sub, Scalar_Mask)
+OCL_TEST_P(Sub, Scalar_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Mul;
-TEST_P(Mul, Mat)
+OCL_TEST_P(Mul, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Mul, Scalar)
+OCL_TEST_P(Mul, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Mul, Mat_Scalar)
+OCL_TEST_P(Mul, Mat_Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Div;
-TEST_P(Div, Mat)
+OCL_TEST_P(Div, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Div, Scalar)
+OCL_TEST_P(Div, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Div, Mat_Scalar)
+OCL_TEST_P(Div, Mat_Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
cv::divide(src1_roi, src2_roi, dst1_roi, val[0]);
cv::ocl::divide(gsrc1_roi, gsrc2_roi, gdst1_roi, val[0]);
- Near(gdst1_roi.depth() >= CV_32F ? 1e-3 : 1);
+ Near(gdst1_roi.depth() >= CV_32F ? 4e-3 : 1);
}
}
typedef ArithmTestBase Min;
-TEST_P(Min, Mat)
+OCL_TEST_P(Min, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Max;
-TEST_P(Max, Mat)
+OCL_TEST_P(Max, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Abs;
-TEST_P(Abs, Abs)
+OCL_TEST_P(Abs, Abs)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Absdiff;
-TEST_P(Absdiff, Mat)
+OCL_TEST_P(Absdiff, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Absdiff, Scalar)
+OCL_TEST_P(Absdiff, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase CartToPolar;
-TEST_P(CartToPolar, angleInDegree)
+OCL_TEST_P(CartToPolar, angleInDegree)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(CartToPolar, angleInRadians)
+OCL_TEST_P(CartToPolar, angleInRadians)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase PolarToCart;
-TEST_P(PolarToCart, angleInDegree)
+OCL_TEST_P(PolarToCart, angleInDegree)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(PolarToCart, angleInRadians)
+OCL_TEST_P(PolarToCart, angleInRadians)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Magnitude;
-TEST_P(Magnitude, Mat)
+OCL_TEST_P(Magnitude, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Transpose;
-TEST_P(Transpose, Mat)
+OCL_TEST_P(Transpose, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Transpose, SquareInplace)
+OCL_TEST_P(Transpose, SquareInplace)
{
const int type = CV_MAKE_TYPE(depth, cn);
typedef ArithmTestBase Flip;
-TEST_P(Flip, X)
+OCL_TEST_P(Flip, X)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Flip, Y)
+OCL_TEST_P(Flip, Y)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Flip, BOTH)
+OCL_TEST_P(Flip, BOTH)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase MinMax;
-TEST_P(MinMax, MAT)
+OCL_TEST_P(MinMax, MAT)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(MinMax, MASK)
+OCL_TEST_P(MinMax, MASK)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase MinMaxLoc;
-TEST_P(MinMaxLoc, MAT)
+OCL_TEST_P(MinMaxLoc, MAT)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(MinMaxLoc, MASK)
+OCL_TEST_P(MinMaxLoc, MASK)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Sum;
-TEST_P(Sum, MAT)
+OCL_TEST_P(Sum, MAT)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef Scalar (*sumFunc)(const Mat &);
-TEST_P(SqrSum, MAT)
+OCL_TEST_P(SqrSum, MAT)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
return sum;
}
-TEST_P(AbsSum, MAT)
+OCL_TEST_P(AbsSum, MAT)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase CountNonZero;
-TEST_P(CountNonZero, MAT)
+OCL_TEST_P(CountNonZero, MAT)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Phase;
-TEST_P(Phase, angleInDegrees)
+OCL_TEST_P(Phase, angleInDegrees)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Phase, angleInRadians)
+OCL_TEST_P(Phase, angleInRadians)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Bitwise_and;
-TEST_P(Bitwise_and, Mat)
+OCL_TEST_P(Bitwise_and, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_and, Mat_Mask)
+OCL_TEST_P(Bitwise_and, Mat_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_and, Scalar)
+OCL_TEST_P(Bitwise_and, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_and, Scalar_Mask)
+OCL_TEST_P(Bitwise_and, Scalar_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Bitwise_or;
-TEST_P(Bitwise_or, Mat)
+OCL_TEST_P(Bitwise_or, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_or, Mat_Mask)
+OCL_TEST_P(Bitwise_or, Mat_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_or, Scalar)
+OCL_TEST_P(Bitwise_or, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_or, Scalar_Mask)
+OCL_TEST_P(Bitwise_or, Scalar_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Bitwise_xor;
-TEST_P(Bitwise_xor, Mat)
+OCL_TEST_P(Bitwise_xor, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_xor, Mat_Mask)
+OCL_TEST_P(Bitwise_xor, Mat_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_xor, Scalar)
+OCL_TEST_P(Bitwise_xor, Scalar)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(Bitwise_xor, Scalar_Mask)
+OCL_TEST_P(Bitwise_xor, Scalar_Mask)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Bitwise_not;
-TEST_P(Bitwise_not, Mat)
+OCL_TEST_P(Bitwise_not, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Compare;
-TEST_P(Compare, Mat)
+OCL_TEST_P(Compare, Mat)
{
int cmp_codes[] = { CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE };
int cmp_num = sizeof(cmp_codes) / sizeof(int);
typedef ArithmTestBase Pow;
-TEST_P(Pow, Mat)
+OCL_TEST_P(Pow, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase AddWeighted;
-TEST_P(AddWeighted, Mat)
+OCL_TEST_P(AddWeighted, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
cv::addWeighted(src1_roi, alpha, src2_roi, beta, gama, dst1_roi);
cv::ocl::addWeighted(gsrc1_roi, alpha, gsrc2_roi, beta, gama, gdst1_roi);
- Near(1e-5);
+ Near(3e-4);
}
}
typedef ArithmTestBase SetIdentity;
-TEST_P(SetIdentity, Mat)
+OCL_TEST_P(SetIdentity, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase MeanStdDev;
-TEST_P(MeanStdDev, Mat)
+OCL_TEST_P(MeanStdDev, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef ArithmTestBase Norm;
-TEST_P(Norm, NORM_INF)
+OCL_TEST_P(Norm, NORM_INF)
{
for (int relative = 0; relative < 2; ++relative)
for (int j = 0; j < LOOP_TIMES; j++)
}
}
-TEST_P(Norm, NORM_L1)
+OCL_TEST_P(Norm, NORM_L1)
{
for (int relative = 0; relative < 2; ++relative)
for (int j = 0; j < LOOP_TIMES; j++)
const double cpuRes = cv::norm(src1_roi, src2_roi, type);
const double gpuRes = cv::ocl::norm(gsrc1_roi, gsrc2_roi, type);
- EXPECT_NEAR(cpuRes, gpuRes, 0.2);
+ EXPECT_NEAR(cpuRes, gpuRes, 0.1);
}
}
-TEST_P(Norm, NORM_L2)
+OCL_TEST_P(Norm, NORM_L2)
{
for (int relative = 0; relative < 2; ++relative)
for (int j = 0; j < LOOP_TIMES; j++)
}
};
-TEST_P(mog, Update)
+OCL_TEST_P(mog, Update)
{
std::string inputFile = string(cvtest::TS::ptr()->get_data_path()) + "gpu/video/768x576.avi";
cv::VideoCapture cap(inputFile);
}
};
-TEST_P(mog2, Update)
+OCL_TEST_P(mog2, Update)
{
std::string inputFile = string(cvtest::TS::ptr()->get_data_path()) + "gpu/video/768x576.avi";
cv::VideoCapture cap(inputFile);
}
}
-TEST_P(mog2, getBackgroundImage)
+OCL_TEST_P(mog2, getBackgroundImage)
{
if (useGray)
return;
}
};
-TEST_P(Blend, Accuracy)
+OCL_TEST_P(Blend, Accuracy)
{
int depth = CV_MAT_DEPTH(type);
}
};
- TEST_P(BruteForceMatcher, Match_Single)
+ OCL_TEST_P(BruteForceMatcher, Match_Single)
{
cv::ocl::BruteForceMatcher_OCL_base matcher(distType);
ASSERT_EQ(0, badCount);
}
- TEST_P(BruteForceMatcher, KnnMatch_2_Single)
+ OCL_TEST_P(BruteForceMatcher, KnnMatch_2_Single)
{
const int knn = 2;
ASSERT_EQ(0, badCount);
}
- TEST_P(BruteForceMatcher, RadiusMatch_Single)
+ OCL_TEST_P(BruteForceMatcher, RadiusMatch_Single)
{
float radius = 1.f / countFactor;
}
};
-TEST_P(StereoMatchBM, Regression)
+OCL_TEST_P(StereoMatchBM, Regression)
{
Mat left_image = readImage("gpu/stereobm/aloe-L.png", IMREAD_GRAYSCALE);
disc_single_jump_ = GET_PARAM(6);
}
};
-TEST_P(StereoMatchBP, Regression)
+OCL_TEST_P(StereoMatchBP, Regression)
{
Mat left_image = readImage("gpu/stereobp/aloe-L.png");
Mat right_image = readImage("gpu/stereobp/aloe-R.png");
msg_type_ = GET_PARAM(9);
}
};
-TEST_P(StereoMatchConstSpaceBP, Regression)
+OCL_TEST_P(StereoMatchConstSpaceBP, Regression)
{
Mat left_image = readImage("gpu/csstereobp/aloe-L.png");
Mat right_image = readImage("gpu/csstereobp/aloe-R.png");
}
};
-TEST_P(Canny, Accuracy)
+OCL_TEST_P(Canny, Accuracy)
{
cv::Mat img = readImage("cv/shared/fruits.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
};
#define CVTCODE(name) cv::COLOR_ ## name
-#define TEST_P_CVTCOLOR(name) TEST_P(CvtColor, name)\
+#define OCL_TEST_P_CVTCOLOR(name) OCL_TEST_P(CvtColor, name)\
{\
cv::Mat src = img;\
cv::ocl::oclMat ocl_img, dst;\
}
//add new ones here using macro
-TEST_P_CVTCOLOR(RGB2GRAY)
-TEST_P_CVTCOLOR(BGR2GRAY)
-TEST_P_CVTCOLOR(RGBA2GRAY)
-TEST_P_CVTCOLOR(BGRA2GRAY)
-
-TEST_P_CVTCOLOR(RGB2YUV)
-TEST_P_CVTCOLOR(BGR2YUV)
-TEST_P_CVTCOLOR(YUV2RGB)
-TEST_P_CVTCOLOR(YUV2BGR)
-TEST_P_CVTCOLOR(RGB2YCrCb)
-TEST_P_CVTCOLOR(BGR2YCrCb)
+OCL_TEST_P_CVTCOLOR(RGB2GRAY)
+OCL_TEST_P_CVTCOLOR(BGR2GRAY)
+OCL_TEST_P_CVTCOLOR(RGBA2GRAY)
+OCL_TEST_P_CVTCOLOR(BGRA2GRAY)
+
+OCL_TEST_P_CVTCOLOR(RGB2YUV)
+OCL_TEST_P_CVTCOLOR(BGR2YUV)
+OCL_TEST_P_CVTCOLOR(YUV2RGB)
+OCL_TEST_P_CVTCOLOR(YUV2BGR)
+OCL_TEST_P_CVTCOLOR(RGB2YCrCb)
+OCL_TEST_P_CVTCOLOR(BGR2YCrCb)
PARAM_TEST_CASE(CvtColor_Gray2RGB, cv::Size, MatDepth, int)
{
img = randomMat(size, CV_MAKETYPE(depth, 1), 0.0, depth == CV_32F ? 1.0 : 255.0);
}
};
-TEST_P(CvtColor_Gray2RGB, Accuracy)
+OCL_TEST_P(CvtColor_Gray2RGB, Accuracy)
{
cv::Mat src = img;
cv::ocl::oclMat ocl_img, dst;
}
};
-TEST_P(CvtColor_YUV420, Accuracy)
+OCL_TEST_P(CvtColor_YUV420, Accuracy)
{
cv::Mat src = img;
cv::ocl::oclMat ocl_img, dst;
//M*/
#include "test_precomp.hpp"
+
using namespace std;
+
#ifdef HAVE_CLAMDFFT
+
////////////////////////////////////////////////////////////////////////////
// Dft
+
PARAM_TEST_CASE(Dft, cv::Size, int)
{
cv::Size dft_size;
}
};
-TEST_P(Dft, C2C)
+OCL_TEST_P(Dft, C2C)
{
cv::Mat a = randomMat(dft_size, CV_32FC2, 0.0, 100.0);
cv::Mat b_gold;
EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), a.size().area() * 1e-4);
}
-TEST_P(Dft, R2C)
+OCL_TEST_P(Dft, R2C)
{
cv::Mat a = randomMat(dft_size, CV_32FC1, 0.0, 100.0);
cv::Mat b_gold, b_gold_roi;
EXPECT_MAT_NEAR(b_gold_roi, cv::Mat(d_b), a.size().area() * 1e-4);
}
-TEST_P(Dft, R2CthenC2R)
+OCL_TEST_P(Dft, R2CthenC2R)
{
cv::Mat a = randomMat(dft_size, CV_32FC1, 0.0, 10.0);
}
};
-TEST_P(Blur, Mat)
+OCL_TEST_P(Blur, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(Laplacian, Accuracy)
+OCL_TEST_P(Laplacian, Accuracy)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
};
-TEST_P(ErodeDilate, Mat)
+OCL_TEST_P(ErodeDilate, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(Sobel, Mat)
+OCL_TEST_P(Sobel, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(Scharr, Mat)
+OCL_TEST_P(Scharr, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(GaussianBlur, Mat)
+OCL_TEST_P(GaussianBlur, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(Filter2D, Mat)
+OCL_TEST_P(Filter2D, Mat)
{
cv::Mat kernel = randomMat(cv::Size(ksize.width, ksize.height), CV_32FC1, 0.0, 1.0);
for(int j = 0; j < LOOP_TIMES; j++)
}
};
-TEST_P(Bilateral, Mat)
+OCL_TEST_P(Bilateral, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(AdaptiveBilateral, Mat)
+OCL_TEST_P(AdaptiveBilateral, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(Gemm, Accuracy)
+OCL_TEST_P(Gemm, Accuracy)
{
cv::Mat a = randomMat(mat_size, type, 0.0, 10.0);
cv::Mat b = randomMat(mat_size, type, 0.0, 10.0);
struct equalizeHist : ImgprocTestBase {};
-TEST_P(equalizeHist, Mat)
+OCL_TEST_P(equalizeHist, Mat)
{
if (mat1.type() != CV_8UC1 || mat1.type() != dst.type())
{
struct CopyMakeBorder : ImgprocTestBase {};
-TEST_P(CopyMakeBorder, Mat)
+OCL_TEST_P(CopyMakeBorder, Mat)
{
int bordertype[] = {cv::BORDER_CONSTANT, cv::BORDER_REPLICATE, cv::BORDER_REFLECT, cv::BORDER_WRAP, cv::BORDER_REFLECT_101};
int top = rng.uniform(0, 10);
struct cornerMinEigenVal : ImgprocTestBase {};
-TEST_P(cornerMinEigenVal, Mat)
+OCL_TEST_P(cornerMinEigenVal, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
struct cornerHarris : ImgprocTestBase {};
-TEST_P(cornerHarris, Mat)
+OCL_TEST_P(cornerHarris, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
struct integral : ImgprocTestBase {};
-TEST_P(integral, Mat1)
+OCL_TEST_P(integral, Mat1)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
}
-TEST_P(integral, Mat2)
+OCL_TEST_P(integral, Mat2)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
struct WarpAffine : WarpTestBase {};
-TEST_P(WarpAffine, Mat)
+OCL_TEST_P(WarpAffine, Mat)
{
static const double coeffs[2][3] =
{
struct WarpPerspective : WarpTestBase {};
-TEST_P(WarpPerspective, Mat)
+OCL_TEST_P(WarpPerspective, Mat)
{
static const double coeffs[3][3] =
{
}
};
-TEST_P(Remap, Mat)
+OCL_TEST_P(Remap, Mat)
{
if((interpolation == 1 && map1Type == CV_16SC2) || (map1Type == CV_32FC1 && map2Type == nulltype) || (map1Type == CV_16SC2 && map2Type == CV_32FC1) || (map1Type == CV_32FC2 && map2Type == CV_32FC1))
{
};
-TEST_P(Resize, Mat)
+OCL_TEST_P(Resize, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
};
-TEST_P(Threshold, Mat)
+OCL_TEST_P(Threshold, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
/////////////////////////meanShiftFiltering/////////////////////////////
struct meanShiftFiltering : meanShiftTestBase {};
-TEST_P(meanShiftFiltering, Mat)
+OCL_TEST_P(meanShiftFiltering, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
///////////////////////////meanShiftProc//////////////////////////////////
struct meanShiftProc : meanShiftTestBase {};
-TEST_P(meanShiftProc, Mat)
+OCL_TEST_P(meanShiftProc, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
///////////////////////////calcHist///////////////////////////////////////
struct calcHist : histTestBase {};
-TEST_P(calcHist, Mat)
+OCL_TEST_P(calcHist, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(CLAHE, Accuracy)
+OCL_TEST_P(CLAHE, Accuracy)
{
cv::Ptr<cv::CLAHE> clahe = cv::ocl::createCLAHE(clipLimit, gridSize);
clahe->apply(g_src, g_dst);
dstdata[i * (z.step >> 2) + j] = temp;
}
}
-TEST_P(Convolve, Mat)
+OCL_TEST_P(Convolve, Mat)
{
if(mat1.type() != CV_32FC1)
{
}
};
-TEST_P(ColumnSum, Accuracy)
+OCL_TEST_P(ColumnSum, Accuracy)
{
cv::Mat src = randomMat(size, CV_32FC1, 0, 255);
cv::ocl::oclMat d_dst;
//M*/
#include "test_precomp.hpp"
+
#ifdef HAVE_OPENCL
+
+#ifdef HAVE_CLAMDBLAS
+
using namespace cv;
using namespace cv::ocl;
using namespace cvtest;
using namespace std;
//////////////////////////////////////////////////////////////////////////
+
PARAM_TEST_CASE(Kalman, int, int)
{
int size_;
}
};
-TEST_P(Kalman, Accuracy)
+OCL_TEST_P(Kalman, Accuracy)
{
const int Dim = size_;
const int Steps = iteration;
//test end
EXPECT_MAT_NEAR(kalman_filter_cpu.statePost, kalman_filter_ocl.statePost, 0);
}
+
INSTANTIATE_TEST_CASE_P(OCL_Video, Kalman, Combine(Values(3, 7), Values(30)));
-#endif // HAVE_OPENCL
\ No newline at end of file
+#endif // HAVE_CLAMDBLAS
+
+#endif // HAVE_OPENCL
}
}
};
-TEST_P(Kmeans, Mat){
+OCL_TEST_P(Kmeans, Mat){
if(flags & KMEANS_USE_INITIAL_LABELS)
{
}
};
-TEST_P(MatchTemplate8U, Accuracy)
+OCL_TEST_P(MatchTemplate8U, Accuracy)
{
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn), 0, 255);
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn), 0, 255);
}
};
-TEST_P(MatchTemplate32F, Accuracy)
+OCL_TEST_P(MatchTemplate32F, Accuracy)
{
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn), 0, 255);
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn), 0, 255);
typedef ConvertToTestBase ConvertTo;
-TEST_P(ConvertTo, Accuracy)
+OCL_TEST_P(ConvertTo, Accuracy)
{
if((src_depth == CV_64F || dst_depth == CV_64F) &&
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
typedef CopyToTestBase CopyTo;
-TEST_P(CopyTo, Without_mask)
+OCL_TEST_P(CopyTo, Without_mask)
{
if((src.depth() == CV_64F) &&
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
}
}
-TEST_P(CopyTo, With_mask)
+OCL_TEST_P(CopyTo, With_mask)
{
if(src.depth() == CV_64F &&
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
typedef SetToTestBase SetTo;
-TEST_P(SetTo, Without_mask)
+OCL_TEST_P(SetTo, Without_mask)
{
if(depth == CV_64F &&
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
}
}
-TEST_P(SetTo, With_mask)
+OCL_TEST_P(SetTo, With_mask)
{
if(depth == CV_64F &&
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
}
};
-TEST_P(convertC3C4, Accuracy)
+OCL_TEST_P(convertC3C4, Accuracy)
{
if(depth == CV_64F &&
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
//M*/
#include "test_precomp.hpp"
+
#ifdef HAVE_OPENCL
+
using namespace cv;
using namespace cv::ocl;
using namespace cvtest;
using namespace testing;
+
///////K-NEAREST NEIGHBOR//////////////////////////
+
static void genTrainData(cv::RNG& rng, Mat& trainData, int trainDataRow, int trainDataCol,
Mat& trainLabel = Mat().setTo(Scalar::all(0)), int nClasses = 0)
{
}
};
-TEST_P(KNN, Accuracy)
+OCL_TEST_P(KNN, Accuracy)
{
Mat trainData, trainLabels;
const int trainDataRow = 500;
EXPECT_MAT_NEAR(Mat(best_label_ocl), best_label_cpu, 0.0);
}
}
+
INSTANTIATE_TEST_CASE_P(OCL_ML, KNN, Combine(Values(6, 5), Values(Size(200, 400), Size(300, 600)),
Values(4, 3), Values(false, true)));
////////////////////////////////SVM/////////////////////////////////////////////////
+
+#ifdef HAVE_CLAMDBLAS
+
PARAM_TEST_CASE(SVM_OCL, int, int, int)
{
cv::Size size;
labels_predict.convertTo(labels_predict, CV_32FC1);
}
};
-TEST_P(SVM_OCL, Accuracy)
+
+OCL_TEST_P(SVM_OCL, Accuracy)
{
CvSVMParams params;
params.degree = 0.4;
}
}
}
+
// TODO FIXIT: CvSVM::EPS_SVR case is crashed inside CPU implementation
// Anonymous enums are not supported well so cast them to 'int'
+
INSTANTIATE_TEST_CASE_P(OCL_ML, SVM_OCL, testing::Combine(
Values((int)CvSVM::LINEAR, (int)CvSVM::POLY, (int)CvSVM::RBF, (int)CvSVM::SIGMOID),
Values((int)CvSVM::C_SVC, (int)CvSVM::NU_SVC, (int)CvSVM::ONE_CLASS, (int)CvSVM::NU_SVR),
Values(2, 3, 4)
));
+#endif // HAVE_CLAMDBLAS
+
#endif // HAVE_OPENCL
};
-TEST_P(MomentsTest, Mat)
+OCL_TEST_P(MomentsTest, Mat)
{
bool binaryImage = 0;
}
};
-TEST_P(HOG, GetDescriptors)
+OCL_TEST_P(HOG, GetDescriptors)
{
// Convert image
Mat img;
EXPECT_MAT_SIMILAR(down_descriptors, cpu_descriptors, 1e-2);
}
-TEST_P(HOG, Detect)
+OCL_TEST_P(HOG, Detect)
{
// Convert image
Mat img;
}
};
-TEST_P(Haar, FaceDetect)
+OCL_TEST_P(Haar, FaceDetect)
{
MemStorage storage(cvCreateMemStorage(0));
CvSeq *_objects;
EXPECT_LT(checkRectSimilarity(img.size(), faces, oclfaces), 1.0);
}
-TEST_P(Haar, FaceDetectUseBuf)
+OCL_TEST_P(Haar, FaceDetectUseBuf)
{
ocl::OclCascadeClassifierBuf cascadebuf;
ASSERT_TRUE(cascadebuf.load(cascadeName)) << "could not load classifier cascade for FaceDetectUseBuf!";
}
};
-TEST_P(GoodFeaturesToTrack, Accuracy)
+OCL_TEST_P(GoodFeaturesToTrack, Accuracy)
{
cv::Mat frame = readImage("gpu/opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty());
ASSERT_LE(bad_ratio, 0.01);
}
-TEST_P(GoodFeaturesToTrack, EmptyCorners)
+OCL_TEST_P(GoodFeaturesToTrack, EmptyCorners)
{
int maxCorners = 1000;
double qualityLevel = 0.01;
};
-TEST_P(TVL1, Accuracy)
+OCL_TEST_P(TVL1, Accuracy)
{
cv::Mat frame0 = readImage("gpu/opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
}
};
-TEST_P(Sparse, Mat)
+OCL_TEST_P(Sparse, Mat)
{
cv::Mat frame0 = readImage("gpu/opticalflow/rubberwhale1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
ASSERT_FALSE(frame0.empty());
}
};
-TEST_P(Farneback, Accuracy)
+OCL_TEST_P(Farneback, Accuracy)
{
cv::Mat frame0 = readImage("gpu/opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
typedef PyrBase PyrDown;
-TEST_P(PyrDown, Mat)
+OCL_TEST_P(PyrDown, Mat)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
typedef PyrBase PyrUp;
-TEST_P(PyrUp, Accuracy)
+OCL_TEST_P(PyrUp, Accuracy)
{
for (int j = 0; j < LOOP_TIMES; j++)
{
}
};
-TEST_P(SortByKey, Accuracy)
+OCL_TEST_P(SortByKey, Accuracy)
{
using namespace cv;
ocl::oclMat oclmat_key(mat_key);
struct Merge : MergeTestBase {};
-TEST_P(Merge, Accuracy)
+OCL_TEST_P(Merge, Accuracy)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
struct Split : SplitTestBase {};
-TEST_P(Split, Accuracy)
+OCL_TEST_P(Split, Accuracy)
{
for(int j = 0; j < LOOP_TIMES; j++)
{
#ifndef __OPENCV_TEST_UTILITY_HPP__
#define __OPENCV_TEST_UTILITY_HPP__
-#define LOOP_TIMES 10
+#define LOOP_TIMES 1
#define MWIDTH 256
#define MHEIGHT 256
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
CV_FLAGS(DftFlags, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
+# define OCL_TEST_P(test_case_name, test_name) \
+ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : \
+ public test_case_name { \
+ public: \
+ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() { } \
+ virtual void TestBody(); \
+ void OCLTestBody(); \
+ private: \
+ static int AddToRegistry() \
+ { \
+ ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
+ GetTestCasePatternHolder<test_case_name>(\
+ #test_case_name, __FILE__, __LINE__)->AddTestPattern(\
+ #test_case_name, \
+ #test_name, \
+ new ::testing::internal::TestMetaFactory< \
+ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
+ return 0; \
+ } \
+ \
+ static int gtest_registering_dummy_; \
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(\
+ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
+ }; \
+ \
+ int GTEST_TEST_CLASS_NAME_(test_case_name, \
+ test_name)::gtest_registering_dummy_ = \
+ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
+ \
+ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() \
+ { \
+ try \
+ { \
+ OCLTestBody(); \
+ } \
+ catch (const cv::Exception & ex) \
+ { \
+ if (ex.code != CV_OpenCLDoubleNotSupported) \
+ throw; \
+ else \
+ std::cout << "Test skipped (selected device does not support double)" << std::endl; \
+ } \
+ } \
+ \
+ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::OCLTestBody()
+
#endif // __OPENCV_TEST_UTILITY_HPP__