Commit 6b9c4519 authored by Ilya Lavrenov's avatar Ilya Lavrenov

added CV_16UC(1, 3, 4), CV_16SC(1, 3, 4) data types support in ocl::pyrUp and ocl::pyrDown

parent 747f7178
This diff is collapsed.
This diff is collapsed.
......@@ -73,24 +73,11 @@ static void pyrdown_run(const oclMat &src, const oclMat &dst)
CV_Assert(src.depth() != CV_8S);
Context *clCxt = src.clCxt;
//int channels = dst.channels();
//int depth = dst.depth();
string kernelName = "pyrDown";
//int vector_lengths[4][7] = {{4, 0, 4, 4, 1, 1, 1},
// {4, 0, 4, 4, 1, 1, 1},
// {4, 0, 4, 4, 1, 1, 1},
// {4, 0, 4, 4, 1, 1, 1}
//};
//size_t vector_length = vector_lengths[channels-1][depth];
//int offset_cols = (dst.offset / dst.elemSize1()) & (vector_length - 1);
size_t localThreads[3] = { 256, 1, 1 };
size_t globalThreads[3] = { src.cols, dst.rows, 1};
//int dst_step1 = dst.cols * dst.elemSize();
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 ));
......@@ -107,7 +94,9 @@ static void pyrdown_run(const oclMat &src, const oclMat &dst)
void cv::ocl::pyrDown(const oclMat &src, oclMat &dst)
{
CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);
int depth = src.depth(), channels = src.channels();
CV_Assert(depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F);
CV_Assert(channels == 1 || channels == 3 || channels == 4);
dst.create((src.rows + 1) / 2, (src.cols + 1) / 2, src.type());
......
......@@ -61,6 +61,11 @@ namespace cv
extern const char *pyr_up;
void pyrUp(const cv::ocl::oclMat &src, cv::ocl::oclMat &dst)
{
int depth = src.depth(), channels = src.channels();
CV_Assert(depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F);
CV_Assert(channels == 1 || channels == 3 || channels == 4);
dst.create(src.rows * 2, src.cols * 2, src.type());
Context *clCxt = src.clCxt;
......
......@@ -57,60 +57,63 @@ using namespace std;
PARAM_TEST_CASE(PyrBase, MatType, int)
{
int type;
int depth;
int channels;
Mat dst_cpu;
oclMat gdst;
virtual void SetUp()
{
type = GET_PARAM(0);
depth = GET_PARAM(0);
channels = GET_PARAM(1);
}
};
/////////////////////// PyrDown //////////////////////////
struct PyrDown : PyrBase {};
typedef PyrBase PyrDown;
TEST_P(PyrDown, Mat)
{
for(int j = 0; j < LOOP_TIMES; j++)
for (int j = 0; j < LOOP_TIMES; j++)
{
Size size(MWIDTH, MHEIGHT);
Mat src = randomMat(size, CV_MAKETYPE(type, channels));
Mat src = randomMat(size, CV_MAKETYPE(depth, channels));
oclMat gsrc(src);
pyrDown(src, dst_cpu);
pyrDown(gsrc, gdst);
EXPECT_MAT_NEAR(dst_cpu, Mat(gdst), type == CV_32F ? 1e-4f : 1.0f);
EXPECT_MAT_NEAR(dst_cpu, Mat(gdst), depth == CV_32F ? 1e-4f : 1.0f);
}
}
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, PyrDown, Combine(
Values(CV_8U, CV_32F), Values(1, 3, 4)));
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(1, 3, 4)));
/////////////////////// PyrUp //////////////////////////
struct PyrUp : PyrBase {};
typedef PyrBase PyrUp;
TEST_P(PyrUp, Accuracy)
{
for(int j = 0; j < LOOP_TIMES; j++)
for (int j = 0; j < LOOP_TIMES; j++)
{
Size size(MWIDTH, MHEIGHT);
Mat src = randomMat(size, CV_MAKETYPE(type, channels));
Mat src = randomMat(size, CV_MAKETYPE(depth, channels));
oclMat gsrc(src);
pyrUp(src, dst_cpu);
pyrUp(gsrc, gdst);
EXPECT_MAT_NEAR(dst_cpu, Mat(gdst), (type == CV_32F ? 1e-4f : 1.0));
EXPECT_MAT_NEAR(dst_cpu, Mat(gdst), (depth == CV_32F ? 1e-4f : 1.0));
}
}
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, PyrUp, testing::Combine(
Values(CV_8U, CV_32F), Values(1, 3, 4)));
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, PyrUp, Combine(
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(1, 3, 4)));
#endif // HAVE_OPENCL
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment