From da3b7c79b81ac0cab7023a0fff9c742741b24ee0 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 14 Oct 2013 14:45:15 +0400 Subject: [PATCH] refactored filters in the ocl module; added an accuracy tests for ocl::medianFilter --- modules/ocl/doc/image_filtering.rst | 14 + modules/ocl/include/opencv2/ocl/ocl.hpp | 5 +- modules/ocl/src/filtering.cpp | 31 +- modules/ocl/src/imgproc.cpp | 24 +- modules/ocl/src/opencl/filtering_laplacian.cl | 5 + modules/ocl/src/opencl/filtering_morph.cl | 4 + modules/ocl/src/opencl/imgproc_bilateral.cl | 69 ++-- modules/ocl/test/test_filters.cpp | 500 ++++++++++++-------------- modules/ocl/test/test_imgproc.cpp | 489 +++++++++++++------------ 9 files changed, 567 insertions(+), 574 deletions(-) diff --git a/modules/ocl/doc/image_filtering.rst b/modules/ocl/doc/image_filtering.rst index 9f18c8e..bd929b9 100644 --- a/modules/ocl/doc/image_filtering.rst +++ b/modules/ocl/doc/image_filtering.rst @@ -666,3 +666,17 @@ Performs linear blending of two images. :param weights2: Weights for second image. Must have tha same size as ``img2`` . Supports only ``CV_32F`` type. :param result: Destination image. + +ocl::medianFilter +-------------------- +Blurs an image using the median filter. + +.. ocv:function:: void ocl::medianFilter(const oclMat &src, oclMat &dst, int m) + + :param src: input ```1-``` or ```4```-channel image; the image depth should be ```CV_8U```, ```CV_32F```. + + :param dst: destination array of the same size and type as ```src```. + + :param m: aperture linear size; it must be odd and greater than ```1```. Currently only ```3```, ```5``` are supported. + +The function smoothes an image using the median filter with the \texttt{m} \times \texttt{m} aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported. diff --git a/modules/ocl/include/opencv2/ocl/ocl.hpp b/modules/ocl/include/opencv2/ocl/ocl.hpp index a2d5156..bf911f4 100644 --- a/modules/ocl/include/opencv2/ocl/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl/ocl.hpp @@ -839,11 +839,8 @@ namespace cv //! Applies a generic geometrical transformation to an image. // Supports INTER_NEAREST, INTER_LINEAR. - // Map1 supports CV_16SC2, CV_32FC2 types. - // Src supports CV_8UC1, CV_8UC2, CV_8UC4. - CV_EXPORTS void remap(const oclMat &src, oclMat &dst, oclMat &map1, oclMat &map2, int interpolation, int bordertype, const Scalar &value = Scalar()); //! copies 2D array to a larger destination array and pads borders with user-specifiable constant @@ -851,7 +848,7 @@ namespace cv CV_EXPORTS void copyMakeBorder(const oclMat &src, oclMat &dst, int top, int bottom, int left, int right, int boardtype, const Scalar &value = Scalar()); //! Smoothes image using median filter - // The source 1- or 4-channel image. When m is 3 or 5, the image depth should be CV 8U or CV 32F. + // The source 1- or 4-channel image. m should be 3 or 5, the image depth should be CV_8U or CV_32F. CV_EXPORTS void medianFilter(const oclMat &src, oclMat &dst, int m); //! warps the image using affine transformation diff --git a/modules/ocl/src/filtering.cpp b/modules/ocl/src/filtering.cpp index b54f616..185bf74 100644 --- a/modules/ocl/src/filtering.cpp +++ b/modules/ocl/src/filtering.cpp @@ -197,10 +197,10 @@ static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, (src.rows == dst.rows)); CV_Assert((src.oclchannels() == dst.oclchannels())); - int srcStep = src.step1() / src.oclchannels(); - int dstStep = dst.step1() / dst.oclchannels(); - int srcOffset = src.offset / src.elemSize(); - int dstOffset = dst.offset / dst.elemSize(); + int srcStep = src.step / src.elemSize(); + int dstStep = dst.step / dst.elemSize(); + int srcOffset = src.offset / src.elemSize(); + int dstOffset = dst.offset / dst.elemSize(); int srcOffset_x = srcOffset % srcStep; int srcOffset_y = srcOffset / srcStep; @@ -247,6 +247,7 @@ static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s %s", anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1], s, rectKernel?"-D RECTKERNEL":""); + vector< pair > args; args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data)); args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data)); @@ -260,6 +261,7 @@ static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholecols)); args.push_back(make_pair(sizeof(cl_int), (void *)&src.wholerows)); args.push_back(make_pair(sizeof(cl_int), (void *)&dstOffset)); + openCLExecuteKernel(clCxt, &filtering_morph, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); } @@ -351,7 +353,7 @@ Ptr cv::ocl::getMorphologyFilter_GPU(int op, int type, const Mat }; CV_Assert(op == MORPH_ERODE || op == MORPH_DILATE); - CV_Assert(type == CV_8UC1 || type == CV_8UC3 || type == CV_8UC4 || type == CV_32FC1 || type == CV_32FC1 || type == CV_32FC4); + CV_Assert(type == CV_8UC1 || type == CV_8UC3 || type == CV_8UC4 || type == CV_32FC1 || type == CV_32FC3 || type == CV_32FC4); oclMat gpu_krnl; normalizeKernel(kernel, gpu_krnl); @@ -361,9 +363,11 @@ Ptr cv::ocl::getMorphologyFilter_GPU(int op, int type, const Mat for(int i = 0; i < kernel.rows * kernel.cols; ++i) if(kernel.data[i] != 1) noZero = false; - MorphFilter_GPU* mfgpu=new MorphFilter_GPU(ksize, anchor, gpu_krnl, GPUMorfFilter_callers[op][CV_MAT_CN(type)]); + + MorphFilter_GPU* mfgpu = new MorphFilter_GPU(ksize, anchor, gpu_krnl, GPUMorfFilter_callers[op][CV_MAT_CN(type)]); if(noZero) mfgpu->rectKernel = true; + return Ptr(mfgpu); } @@ -445,9 +449,7 @@ void morphOp(int op, const oclMat &src, oclMat &dst, const Mat &_kernel, Point a iterations = 1; } else - { kernel = _kernel; - } Ptr f = createMorphologyFilter_GPU(op, src.type(), kernel, anchor, iterations); @@ -462,14 +464,10 @@ void cv::ocl::erode(const oclMat &src, oclMat &dst, const Mat &kernel, Point anc for (int i = 0; i < kernel.rows * kernel.cols; ++i) if (kernel.data[i] != 0) - { allZero = false; - } if (allZero) - { kernel.data[0] = 1; - } morphOp(MORPH_ERODE, src, dst, kernel, anchor, iterations, borderType, borderValue); } @@ -558,7 +556,7 @@ static void GPUFilter2D(const oclMat &src, oclMat &dst, const oclMat &mat_kernel Context *clCxt = src.clCxt; int filterWidth = ksize.width; - bool ksize_3x3 = filterWidth == 3 && src.type() != CV_32FC4; // CV_32FC4 is not tuned up with filter2d_3x3 kernel + bool ksize_3x3 = filterWidth == 3 && src.type() != CV_32FC4 && src.type() != CV_32FC3; // CV_32FC4 is not tuned up with filter2d_3x3 kernel string kernelName = ksize_3x3 ? "filter2D_3x3" : "filter2D"; @@ -649,9 +647,7 @@ Ptr cv::ocl::getLinearFilter_GPU(int srcType, int dstType, const Ptr cv::ocl::createLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, const Point &anchor, int borderType) { - Size ksize = kernel.size(); - Ptr linearFilter = getLinearFilter_GPU(srcType, dstType, kernel, ksize, anchor, borderType); return createFilter2D_GPU(linearFilter); @@ -659,11 +655,8 @@ Ptr cv::ocl::createLinearFilter_GPU(int srcType, int dstType, void cv::ocl::filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernel, Point anchor, int borderType) { - if (ddepth < 0) - { ddepth = src.depth(); - } dst.create(src.size(), CV_MAKETYPE(ddepth, src.channels())); @@ -1444,9 +1437,7 @@ Ptr cv::ocl::createGaussianFilter_GPU(int type, Size ksize, do int depth = CV_MAT_DEPTH(type); if (sigma2 <= 0) - { sigma2 = sigma1; - } // automatic detection of kernel size from sigma if (ksize.width <= 0 && sigma1 > 0) diff --git a/modules/ocl/src/imgproc.cpp b/modules/ocl/src/imgproc.cpp index 8d56c54..916d25c 100644 --- a/modules/ocl/src/imgproc.cpp +++ b/modules/ocl/src/imgproc.cpp @@ -408,20 +408,11 @@ namespace cv void medianFilter(const oclMat &src, oclMat &dst, int m) { CV_Assert( m % 2 == 1 && m > 1 ); - CV_Assert( m <= 5 || src.depth() == CV_8U ); - CV_Assert( src.cols <= dst.cols && src.rows <= dst.rows ); + CV_Assert( (src.depth() == CV_8U || src.depth() == CV_32F) && (src.channels() == 1 || src.channels() == 4)); + dst.create(src.size(), src.type()); - if (src.data == dst.data) - { - oclMat src1; - src.copyTo(src1); - return medianFilter(src1, dst, m); - } - - int srcStep = src.step1() / src.oclchannels(); - int dstStep = dst.step1() / dst.oclchannels(); - int srcOffset = src.offset / src.oclchannels() / src.elemSize1(); - int dstOffset = dst.offset / dst.oclchannels() / dst.elemSize1(); + int srcStep = src.step / src.elemSize(), dstStep = dst.step / dst.elemSize(); + int srcOffset = src.offset / src.elemSize(), dstOffset = dst.offset / dst.elemSize(); Context *clCxt = src.clCxt; @@ -1518,6 +1509,7 @@ namespace cv float *color_weight = &_color_weight[0]; float *space_weight = &_space_weight[0]; int *space_ofs = &_space_ofs[0]; + int dst_step_in_pixel = dst.step / dst.elemSize(); int dst_offset_in_pixel = dst.offset / dst.elemSize(); int temp_step_in_pixel = temp.step / temp.elemSize(); @@ -1548,7 +1540,7 @@ namespace cv if ((dst.type() == CV_8UC1) && ((dst.offset & 3) == 0) && ((dst.cols & 3) == 0)) { kernelName = "bilateral2"; - globalThreads[0] = dst.cols / 4; + globalThreads[0] = dst.cols >> 2; } vector > args; @@ -1566,15 +1558,17 @@ namespace cv args.push_back( make_pair( sizeof(cl_mem), (void *)&oclcolor_weight.data )); args.push_back( make_pair( sizeof(cl_mem), (void *)&oclspace_weight.data )); args.push_back( make_pair( sizeof(cl_mem), (void *)&oclspace_ofs.data )); + openCLExecuteKernel(src.clCxt, &imgproc_bilateral, kernelName, globalThreads, localThreads, args, dst.oclchannels(), dst.depth()); } + void bilateralFilter(const oclMat &src, oclMat &dst, int radius, double sigmaclr, double sigmaspc, int borderType) { dst.create( src.size(), src.type() ); if ( src.depth() == CV_8U ) oclbilateralFilter_8u( src, dst, radius, sigmaclr, sigmaspc, borderType ); else - CV_Error( CV_StsUnsupportedFormat, "Bilateral filtering is only implemented for 8uimages" ); + CV_Error( CV_StsUnsupportedFormat, "Bilateral filtering is only implemented for CV_8U images" ); } } diff --git a/modules/ocl/src/opencl/filtering_laplacian.cl b/modules/ocl/src/opencl/filtering_laplacian.cl index 3c0cc0d..7c5b0c3 100644 --- a/modules/ocl/src/opencl/filtering_laplacian.cl +++ b/modules/ocl/src/opencl/filtering_laplacian.cl @@ -169,6 +169,7 @@ __kernel void filter2D( int globalRow = groupStartRow + localRow; const int src_offset = mad24(src_offset_y, src_step, src_offset_x); const int dst_offset = mad24(dst_offset_y, dst_step, dst_offset_x); + #ifdef BORDER_CONSTANT for(int i = localRow; i < LOCAL_HEIGHT; i += get_local_size(1)) { @@ -208,6 +209,7 @@ __kernel void filter2D( } } #endif + barrier(CLK_LOCAL_MEM_FENCE); if(globalRow < rows && globalCol < cols) { @@ -231,6 +233,7 @@ __kernel void filter2D( ////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////Macro for define elements number per thread///////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// + #define ANX 1 #define ANY 1 @@ -249,6 +252,7 @@ __kernel void filter2D( /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////8uC1//////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// + __kernel void filter2D_3x3( __global T_IMG *src, __global T_IMG *dst, @@ -359,6 +363,7 @@ __kernel void filter2D_3x3( } } } + if(dst_rows_index < dst_rows_end) { T_IMGx4 tmp_dst = CONVERT_TYPEx4(sum); diff --git a/modules/ocl/src/opencl/filtering_morph.cl b/modules/ocl/src/opencl/filtering_morph.cl index e659a59..db88aca 100644 --- a/modules/ocl/src/opencl/filtering_morph.cl +++ b/modules/ocl/src/opencl/filtering_morph.cl @@ -45,6 +45,7 @@ //BORDER_CONSTANT: iiiiii|abcdefgh|iiiiiii #define ELEM(i,l_edge,r_edge,elem1,elem2) (i)<(l_edge) | (i) >= (r_edge) ? (elem1) : (elem2) #ifndef GENTYPE + __kernel void morph_C1_D0(__global const uchar * restrict src, __global uchar *dst, int src_offset_x, int src_offset_y, @@ -150,7 +151,9 @@ __kernel void morph_C1_D0(__global const uchar * restrict src, } } } + #else + __kernel void morph(__global const GENTYPE * restrict src, __global GENTYPE *dst, int src_offset_x, int src_offset_y, @@ -221,4 +224,5 @@ __kernel void morph(__global const GENTYPE * restrict src, dst[out_addr] = res; } } + #endif diff --git a/modules/ocl/src/opencl/imgproc_bilateral.cl b/modules/ocl/src/opencl/imgproc_bilateral.cl index f678b43..f13e967 100644 --- a/modules/ocl/src/opencl/imgproc_bilateral.cl +++ b/modules/ocl/src/opencl/imgproc_bilateral.cl @@ -47,25 +47,27 @@ __kernel void bilateral_C1_D0(__global uchar *dst, __constant float *space_weight, __constant int *space_ofs) { - int gidx = get_global_id(0); - int gidy = get_global_id(1); - if((gidy> 1; - cv::Size size = src_roi.size(); + Size size = src_roi.size(); for(int i = 0; i < size.height; i++, sptr += sstep - (size.width << 2), dptr += dstep - (size.width << 2), dCoorptr += dCoorstep - (size.width << 1)) @@ -301,7 +301,7 @@ void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi, int sp, PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bool) { int type1, type2, type3, type4, type5; - cv::Scalar val; + Scalar val; // set up roi int roicols; int roirows; @@ -317,32 +317,32 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo int masky; //mat - cv::Mat mat1; - cv::Mat mat2; - cv::Mat mask; - cv::Mat dst; - cv::Mat dst1; //bak, for two outputs + Mat mat1; + Mat mat2; + Mat mask; + Mat dst; + Mat dst1; //bak, for two outputs //mat with roi - cv::Mat mat1_roi; - cv::Mat mat2_roi; - cv::Mat mask_roi; - cv::Mat dst_roi; - cv::Mat dst1_roi; //bak + Mat mat1_roi; + Mat mat2_roi; + Mat mask_roi; + Mat dst_roi; + Mat dst1_roi; //bak //ocl mat - cv::ocl::oclMat clmat1; - cv::ocl::oclMat clmat2; - cv::ocl::oclMat clmask; - cv::ocl::oclMat cldst; - cv::ocl::oclMat cldst1; //bak + ocl::oclMat clmat1; + ocl::oclMat clmat2; + ocl::oclMat clmask; + ocl::oclMat cldst; + ocl::oclMat cldst1; //bak //ocl mat with roi - cv::ocl::oclMat clmat1_roi; - cv::ocl::oclMat clmat2_roi; - cv::ocl::oclMat clmask_roi; - cv::ocl::oclMat cldst_roi; - cv::ocl::oclMat cldst1_roi; + ocl::oclMat clmat1_roi; + ocl::oclMat clmat2_roi; + ocl::oclMat clmask_roi; + ocl::oclMat cldst_roi; + ocl::oclMat cldst1_roi; virtual void SetUp() { @@ -351,7 +351,7 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo type3 = GET_PARAM(2); type4 = GET_PARAM(3); type5 = GET_PARAM(4); - cv::Size size(MWIDTH, MHEIGHT); + Size size(MWIDTH, MHEIGHT); double min = 1, max = 20; if(type1 != nulltype) @@ -377,10 +377,10 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo if(type5 != nulltype) { mask = randomMat(size, CV_8UC1, 0, 2, false); - cv::threshold(mask, mask, 0.5, 255., type5); + threshold(mask, mask, 0.5, 255., type5); clmask = mask; } - val = cv::Scalar(rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0)); + val = Scalar(rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0)); } void random_roi() @@ -444,16 +444,16 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo void Near(double threshold) { - cv::Mat cpu_cldst; + Mat cpu_cldst; cldst.download(cpu_cldst); EXPECT_MAT_NEAR(dst, cpu_cldst, threshold); } }; ////////////////////////////////equalizeHist////////////////////////////////////////// -struct equalizeHist : ImgprocTestBase {}; +typedef ImgprocTestBase EqualizeHist; -OCL_TEST_P(equalizeHist, Mat) +OCL_TEST_P(EqualizeHist, Mat) { if (mat1.type() != CV_8UC1 || mat1.type() != dst.type()) { @@ -465,8 +465,8 @@ OCL_TEST_P(equalizeHist, Mat) for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::equalizeHist(mat1_roi, dst_roi); - cv::ocl::equalizeHist(clmat1_roi, cldst_roi); + equalizeHist(mat1_roi, dst_roi); + ocl::equalizeHist(clmat1_roi, cldst_roi); Near(1.1); } } @@ -475,11 +475,11 @@ OCL_TEST_P(equalizeHist, Mat) ////////////////////////////////copyMakeBorder//////////////////////////////////////////// -struct CopyMakeBorder : ImgprocTestBase {}; +typedef ImgprocTestBase CopyMakeBorder; OCL_TEST_P(CopyMakeBorder, Mat) { - int bordertype[] = {cv::BORDER_CONSTANT, cv::BORDER_REPLICATE, cv::BORDER_REFLECT, cv::BORDER_WRAP, cv::BORDER_REFLECT_101}; + int bordertype[] = {BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101}; int top = rng.uniform(0, 10); int bottom = rng.uniform(0, 10); int left = rng.uniform(0, 10); @@ -496,7 +496,7 @@ OCL_TEST_P(CopyMakeBorder, Mat) { random_roi(); #ifdef RANDOMROI - if(((bordertype[i] != cv::BORDER_CONSTANT) && (bordertype[i] != cv::BORDER_REPLICATE)) && (mat1_roi.cols <= left) || (mat1_roi.cols <= right) || (mat1_roi.rows <= top) || (mat1_roi.rows <= bottom)) + if(((bordertype[i] != BORDER_CONSTANT) && (bordertype[i] != BORDER_REPLICATE)) && (mat1_roi.cols <= left) || (mat1_roi.cols <= right) || (mat1_roi.rows <= top) || (mat1_roi.rows <= bottom)) { continue; } @@ -510,10 +510,10 @@ OCL_TEST_P(CopyMakeBorder, Mat) continue; } #endif - cv::copyMakeBorder(mat1_roi, dst_roi, top, bottom, left, right, bordertype[i] | cv::BORDER_ISOLATED, cv::Scalar(1.0)); - cv::ocl::copyMakeBorder(clmat1_roi, cldst_roi, top, bottom, left, right, bordertype[i] | cv::BORDER_ISOLATED, cv::Scalar(1.0)); + cv::copyMakeBorder(mat1_roi, dst_roi, top, bottom, left, right, bordertype[i] | BORDER_ISOLATED, Scalar(1.0)); + ocl::copyMakeBorder(clmat1_roi, cldst_roi, top, bottom, left, right, bordertype[i] | BORDER_ISOLATED, Scalar(1.0)); - cv::Mat cpu_cldst; + Mat cpu_cldst; #ifndef RANDOMROI cldst_roi.download(cpu_cldst); EXPECT_MAT_NEAR(dst_roi, cpu_cldst, 0.0); @@ -530,20 +530,20 @@ OCL_TEST_P(CopyMakeBorder, Mat) ////////////////////////////////cornerMinEigenVal////////////////////////////////////////// -struct cornerMinEigenVal : ImgprocTestBase {}; +struct CornerMinEigenVal : ImgprocTestBase {}; -OCL_TEST_P(cornerMinEigenVal, Mat) +OCL_TEST_P(CornerMinEigenVal, Mat) { for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); int blockSize = 3, apertureSize = 3;//1 + 2 * (rand() % 4); - //int borderType = cv::BORDER_CONSTANT; - //int borderType = cv::BORDER_REPLICATE; - int borderType = cv::BORDER_REFLECT; - cv::cornerMinEigenVal(mat1_roi, dst_roi, blockSize, apertureSize, borderType); - cv::ocl::cornerMinEigenVal(clmat1_roi, cldst_roi, blockSize, apertureSize, borderType); + //int borderType = BORDER_CONSTANT; + //int borderType = BORDER_REPLICATE; + int borderType = BORDER_REFLECT; + cornerMinEigenVal(mat1_roi, dst_roi, blockSize, apertureSize, borderType); + ocl::cornerMinEigenVal(clmat1_roi, cldst_roi, blockSize, apertureSize, borderType); Near(1.); } } @@ -552,9 +552,9 @@ OCL_TEST_P(cornerMinEigenVal, Mat) ////////////////////////////////cornerHarris////////////////////////////////////////// -struct cornerHarris : ImgprocTestBase {}; +typedef ImgprocTestBase CornerHarris; -OCL_TEST_P(cornerHarris, Mat) +OCL_TEST_P(CornerHarris, Mat) { for(int j = 0; j < LOOP_TIMES; j++) { @@ -562,11 +562,11 @@ OCL_TEST_P(cornerHarris, Mat) random_roi(); int blockSize = 3, apertureSize = 3; //1 + 2 * (rand() % 4); double k = 2; - //int borderType = cv::BORDER_CONSTANT; - //int borderType = cv::BORDER_REPLICATE; - int borderType = cv::BORDER_REFLECT; - cv::cornerHarris(mat1_roi, dst_roi, blockSize, apertureSize, k, borderType); - cv::ocl::cornerHarris(clmat1_roi, cldst_roi, blockSize, apertureSize, k, borderType); + //int borderType = BORDER_CONSTANT; + //int borderType = BORDER_REPLICATE; + int borderType = BORDER_REFLECT; + cornerHarris(mat1_roi, dst_roi, blockSize, apertureSize, k, borderType); + ocl::cornerHarris(clmat1_roi, cldst_roi, blockSize, apertureSize, k, borderType); Near(1.); } } @@ -574,31 +574,31 @@ OCL_TEST_P(cornerHarris, Mat) ////////////////////////////////integral///////////////////////////////////////////////// -struct integral : ImgprocTestBase {}; +typedef ImgprocTestBase Integral; -OCL_TEST_P(integral, Mat1) +OCL_TEST_P(Integral, Mat1) { for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::ocl::integral(clmat1_roi, cldst_roi); - cv::integral(mat1_roi, dst_roi); + ocl::integral(clmat1_roi, cldst_roi); + integral(mat1_roi, dst_roi); Near(0); } } -OCL_TEST_P(integral, Mat2) +OCL_TEST_P(Integral, Mat2) { for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::ocl::integral(clmat1_roi, cldst_roi, cldst1_roi); - cv::integral(mat1_roi, dst_roi, dst1_roi); + ocl::integral(clmat1_roi, cldst_roi, cldst1_roi); + integral(mat1_roi, dst_roi, dst1_roi); Near(0); - cv::Mat cpu_cldst1; + Mat cpu_cldst1; cldst1.download(cpu_cldst1); EXPECT_MAT_NEAR(dst1, cpu_cldst1, 0.0); } @@ -611,12 +611,12 @@ OCL_TEST_P(integral, Mat2) PARAM_TEST_CASE(WarpTestBase, MatType, int) { int type; - cv::Size size; + Size size; int interpolation; //src mat - cv::Mat mat1; - cv::Mat dst; + Mat mat1; + Mat dst; // set up roi int src_roicols; @@ -630,21 +630,21 @@ PARAM_TEST_CASE(WarpTestBase, MatType, int) //src mat with roi - cv::Mat mat1_roi; - cv::Mat dst_roi; + Mat mat1_roi; + Mat dst_roi; //ocl dst mat for testing - cv::ocl::oclMat gdst_whole; + ocl::oclMat gdst_whole; //ocl mat with roi - cv::ocl::oclMat gmat1; - cv::ocl::oclMat gdst; + ocl::oclMat gmat1; + ocl::oclMat gdst; virtual void SetUp() { type = GET_PARAM(0); interpolation = GET_PARAM(1); - size = cv::Size(MWIDTH, MHEIGHT); + size = Size(MWIDTH, MHEIGHT); mat1 = randomMat(size, type, 5, 16, false); dst = randomMat(size, type, 5, 16, false); @@ -688,7 +688,7 @@ PARAM_TEST_CASE(WarpTestBase, MatType, int) /////warpAffine -struct WarpAffine : WarpTestBase {}; +typedef WarpTestBase WarpAffine; OCL_TEST_P(WarpAffine, Mat) { @@ -703,10 +703,10 @@ OCL_TEST_P(WarpAffine, Mat) { random_roi(); - cv::warpAffine(mat1_roi, dst_roi, M, size, interpolation); - cv::ocl::warpAffine(gmat1, gdst, M, size, interpolation); + warpAffine(mat1_roi, dst_roi, M, size, interpolation); + ocl::warpAffine(gmat1, gdst, M, size, interpolation); - cv::Mat cpu_dst; + Mat cpu_dst; gdst_whole.download(cpu_dst); EXPECT_MAT_NEAR(dst, cpu_dst, 1.0); } @@ -716,7 +716,7 @@ OCL_TEST_P(WarpAffine, Mat) // warpPerspective -struct WarpPerspective : WarpTestBase {}; +typedef WarpTestBase WarpPerspective; OCL_TEST_P(WarpPerspective, Mat) { @@ -732,10 +732,10 @@ OCL_TEST_P(WarpPerspective, Mat) { random_roi(); - cv::warpPerspective(mat1_roi, dst_roi, M, size, interpolation); - cv::ocl::warpPerspective(gmat1, gdst, M, size, interpolation); + warpPerspective(mat1_roi, dst_roi, M, size, interpolation); + ocl::warpPerspective(gmat1, gdst, M, size, interpolation); - cv::Mat cpu_dst; + Mat cpu_dst; gdst_whole.download(cpu_dst); EXPECT_MAT_NEAR(dst, cpu_dst, 1.0); } @@ -751,17 +751,17 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int) int srcType; int map1Type; int map2Type; - cv::Scalar val; + Scalar val; int interpolation; int bordertype; - cv::Mat src; - cv::Mat dst; - cv::Mat map1; - cv::Mat map2; + Mat src; + Mat dst; + Mat map1; + Mat map2; - //std::vector oclinfo; + //std::vector oclinfo; int src_roicols; int src_roirows; @@ -780,19 +780,19 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int) int map2x; int map2y; - cv::Mat src_roi; - cv::Mat dst_roi; - cv::Mat map1_roi; - cv::Mat map2_roi; + Mat src_roi; + Mat dst_roi; + Mat map1_roi; + Mat map2_roi; //ocl mat for testing - cv::ocl::oclMat gdst; + ocl::oclMat gdst; //ocl mat with roi - cv::ocl::oclMat gsrc_roi; - cv::ocl::oclMat gdst_roi; - cv::ocl::oclMat gmap1_roi; - cv::ocl::oclMat gmap2_roi; + ocl::oclMat gsrc_roi; + ocl::oclMat gdst_roi; + ocl::oclMat gmap1_roi; + ocl::oclMat gmap2_roi; virtual void SetUp() { @@ -802,8 +802,8 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int) interpolation = GET_PARAM(3); bordertype = GET_PARAM(4); - cv::Size srcSize = cv::Size(MWIDTH, MHEIGHT); - cv::Size map1Size = cv::Size(MWIDTH, MHEIGHT); + Size srcSize = Size(MWIDTH, MHEIGHT); + Size map1Size = Size(MWIDTH, MHEIGHT); double min = 5, max = 16; if(srcType != nulltype) @@ -830,16 +830,16 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int) switch (src.channels()) { case 1: - val = cv::Scalar(rng.uniform(0.0, 10.0), 0, 0, 0); + val = Scalar(rng.uniform(0.0, 10.0), 0, 0, 0); break; case 2: - val = cv::Scalar(rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), 0, 0); + val = Scalar(rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), 0, 0); break; case 3: - val = cv::Scalar(rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), 0); + val = Scalar(rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), 0); break; case 4: - val = cv::Scalar(rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0)); + val = Scalar(rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0), rng.uniform(0.0, 10.0)); break; } @@ -894,14 +894,14 @@ OCL_TEST_P(Remap, Mat) cout << "Don't support the dataType" << endl; return; } - int bordertype[] = {cv::BORDER_CONSTANT, cv::BORDER_REPLICATE/*,BORDER_REFLECT,BORDER_WRAP,BORDER_REFLECT_101*/}; + int bordertype[] = {BORDER_CONSTANT, BORDER_REPLICATE/*,BORDER_REFLECT,BORDER_WRAP,BORDER_REFLECT_101*/}; for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::remap(src_roi, dst_roi, map1_roi, map2_roi, interpolation, bordertype[0], val); - cv::ocl::remap(gsrc_roi, gdst_roi, gmap1_roi, gmap2_roi, interpolation, bordertype[0], val); - cv::Mat cpu_dst; + remap(src_roi, dst_roi, map1_roi, map2_roi, interpolation, bordertype[0], val); + ocl::remap(gsrc_roi, gdst_roi, gmap1_roi, gmap2_roi, interpolation, bordertype[0], val); + Mat cpu_dst; gdst.download(cpu_dst); if(interpolation == 0) @@ -915,16 +915,16 @@ OCL_TEST_P(Remap, Mat) ///////////////////////////////////////////////////////////////////////////////////////////////// // resize -PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int) +PARAM_TEST_CASE(Resize, MatType, Size, double, double, int) { int type; - cv::Size dsize; + Size dsize; double fx, fy; int interpolation; //src mat - cv::Mat mat1; - cv::Mat dst; + Mat mat1; + Mat dst; // set up roi int src_roicols; @@ -937,15 +937,15 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int) int dsty; //src mat with roi - cv::Mat mat1_roi; - cv::Mat dst_roi; + Mat mat1_roi; + Mat dst_roi; //ocl dst mat for testing - cv::ocl::oclMat gdst_whole; + ocl::oclMat gdst_whole; //ocl mat with roi - cv::ocl::oclMat gmat1; - cv::ocl::oclMat gdst; + ocl::oclMat gmat1; + ocl::oclMat gdst; virtual void SetUp() { @@ -955,15 +955,15 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int) fy = GET_PARAM(3); interpolation = GET_PARAM(4); - cv::Size size(MWIDTH, MHEIGHT); + Size size(MWIDTH, MHEIGHT); - if(dsize == cv::Size() && !(fx > 0 && fy > 0)) + if(dsize == Size() && !(fx > 0 && fy > 0)) { cout << "invalid dsize and fx fy" << endl; return; } - if(dsize == cv::Size()) + if(dsize == Size()) { dsize.width = (int)(size.width * fx); dsize.height = (int)(size.height * fy); @@ -1018,13 +1018,13 @@ OCL_TEST_P(Resize, Mat) { random_roi(); - // cv::resize(mat1_roi, dst_roi, dsize, fx, fy, interpolation); - // cv::ocl::resize(gmat1, gdst, dsize, fx, fy, interpolation); + // resize(mat1_roi, dst_roi, dsize, fx, fy, interpolation); + // ocl::resize(gmat1, gdst, dsize, fx, fy, interpolation); if(dst_roicols < 1 || dst_roirows < 1) continue; - cv::resize(mat1_roi, dst_roi, dsize, fx, fy, interpolation); - cv::ocl::resize(gmat1, gdst, dsize, fx, fy, interpolation); + resize(mat1_roi, dst_roi, dsize, fx, fy, interpolation); + ocl::resize(gmat1, gdst, dsize, fx, fy, interpolation); - cv::Mat cpu_dst; + Mat cpu_dst; gdst_whole.download(cpu_dst); EXPECT_MAT_NEAR(dst, cpu_dst, 1.0); } @@ -1041,8 +1041,8 @@ PARAM_TEST_CASE(Threshold, MatType, ThreshOp) int threshOp; //src mat - cv::Mat mat1; - cv::Mat dst; + Mat mat1; + Mat dst; // set up roi int roicols; @@ -1053,22 +1053,22 @@ PARAM_TEST_CASE(Threshold, MatType, ThreshOp) int dsty; //src mat with roi - cv::Mat mat1_roi; - cv::Mat dst_roi; + Mat mat1_roi; + Mat dst_roi; //ocl dst mat for testing - cv::ocl::oclMat gdst_whole; + ocl::oclMat gdst_whole; //ocl mat with roi - cv::ocl::oclMat gmat1; - cv::ocl::oclMat gdst; + ocl::oclMat gmat1; + ocl::oclMat gdst; virtual void SetUp() { type = GET_PARAM(0); threshOp = GET_PARAM(1); - cv::Size size(MWIDTH, MHEIGHT); + Size size(MWIDTH, MHEIGHT); mat1 = randomMat(size, type, 5, 16, false); dst = randomMat(size, type, 5, 16, false); @@ -1113,25 +1113,25 @@ OCL_TEST_P(Threshold, Mat) double maxVal = randomDouble(20.0, 127.0); double thresh = randomDouble(0.0, maxVal); - cv::threshold(mat1_roi, dst_roi, thresh, maxVal, threshOp); - cv::ocl::threshold(gmat1, gdst, thresh, maxVal, threshOp); + threshold(mat1_roi, dst_roi, thresh, maxVal, threshOp); + ocl::threshold(gmat1, gdst, thresh, maxVal, threshOp); - cv::Mat cpu_dst; + Mat cpu_dst; gdst_whole.download(cpu_dst); EXPECT_MAT_NEAR(dst, cpu_dst, 1); } } -PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria) +PARAM_TEST_CASE(MeanShiftTestBase, MatType, MatType, int, int, TermCriteria) { int type, typeCoor; int sp, sr; - cv::TermCriteria crit; + TermCriteria crit; //src mat - cv::Mat src; - cv::Mat dst; - cv::Mat dstCoor; + Mat src; + Mat dst; + Mat dstCoor; //set up roi int roicols; @@ -1142,18 +1142,18 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria) int dsty; //src mat with roi - cv::Mat src_roi; - cv::Mat dst_roi; - cv::Mat dstCoor_roi; + Mat src_roi; + Mat dst_roi; + Mat dstCoor_roi; //ocl dst mat - cv::ocl::oclMat gdst; - cv::ocl::oclMat gdstCoor; + ocl::oclMat gdst; + ocl::oclMat gdstCoor; //ocl mat with roi - cv::ocl::oclMat gsrc_roi; - cv::ocl::oclMat gdst_roi; - cv::ocl::oclMat gdstCoor_roi; + ocl::oclMat gsrc_roi; + ocl::oclMat gdst_roi; + ocl::oclMat gdstCoor_roi; virtual void SetUp() { @@ -1164,7 +1164,7 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria) crit = GET_PARAM(4); // MWIDTH=256, MHEIGHT=256. defined in utility.hpp - cv::Size size = cv::Size(MWIDTH, MHEIGHT); + Size size = Size(MWIDTH, MHEIGHT); src = randomMat(size, type, 5, 16, false); dst = randomMat(size, type, 5, 16, false); @@ -1204,20 +1204,21 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria) }; /////////////////////////meanShiftFiltering///////////////////////////// -struct meanShiftFiltering : meanShiftTestBase {}; -OCL_TEST_P(meanShiftFiltering, Mat) +typedef MeanShiftTestBase MeanShiftFiltering; + +OCL_TEST_P(MeanShiftFiltering, Mat) { for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::Mat cpu_gdst; + Mat cpu_gdst; gdst.download(cpu_gdst); - meanShiftFiltering_(src_roi, dst_roi, sp, sr, crit); - cv::ocl::meanShiftFiltering(gsrc_roi, gdst_roi, sp, sr, crit); + ::meanShiftFiltering_(src_roi, dst_roi, sp, sr, crit); + ocl::meanShiftFiltering(gsrc_roi, gdst_roi, sp, sr, crit); gdst.download(cpu_gdst); EXPECT_MAT_NEAR(dst, cpu_gdst, 0.0); @@ -1225,20 +1226,21 @@ OCL_TEST_P(meanShiftFiltering, Mat) } ///////////////////////////meanShiftProc////////////////////////////////// -struct meanShiftProc : meanShiftTestBase {}; -OCL_TEST_P(meanShiftProc, Mat) +typedef MeanShiftTestBase MeanShiftProc; + +OCL_TEST_P(MeanShiftProc, Mat) { for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::Mat cpu_gdst; - cv::Mat cpu_gdstCoor; + Mat cpu_gdst; + Mat cpu_gdstCoor; meanShiftProc_(src_roi, dst_roi, dstCoor_roi, sp, sr, crit); - cv::ocl::meanShiftProc(gsrc_roi, gdst_roi, gdstCoor_roi, sp, sr, crit); + ocl::meanShiftProc(gsrc_roi, gdst_roi, gdstCoor_roi, sp, sr, crit); gdst.download(cpu_gdst); gdstCoor.download(cpu_gdstCoor); @@ -1249,10 +1251,11 @@ OCL_TEST_P(meanShiftProc, Mat) /////////////////////////////////////////////////////////////////////////////////////// //hist -void calcHistGold(const cv::Mat &src, cv::Mat &hist) + +void calcHistGold(const Mat &src, Mat &hist) { hist.create(1, 256, CV_32SC1); - hist.setTo(cv::Scalar::all(0)); + hist.setTo(Scalar::all(0)); int *hist_row = hist.ptr(); for (int y = 0; y < src.rows; ++y) @@ -1264,30 +1267,30 @@ void calcHistGold(const cv::Mat &src, cv::Mat &hist) } } -PARAM_TEST_CASE(histTestBase, MatType, MatType) +PARAM_TEST_CASE(HistTestBase, MatType, MatType) { int type_src; //src mat - cv::Mat src; - cv::Mat dst_hist; + Mat src; + Mat dst_hist; //set up roi int roicols; int roirows; int srcx; int srcy; //src mat with roi - cv::Mat src_roi; + Mat src_roi; //ocl dst mat, dst_hist and gdst_hist don't have roi - cv::ocl::oclMat gdst_hist; + ocl::oclMat gdst_hist; //ocl mat with roi - cv::ocl::oclMat gsrc_roi; + ocl::oclMat gsrc_roi; virtual void SetUp() { type_src = GET_PARAM(0); - cv::Size size = cv::Size(MWIDTH, MHEIGHT); + Size size = Size(MWIDTH, MHEIGHT); src = randomMat(size, type_src, 0, 256, false); @@ -1312,69 +1315,73 @@ PARAM_TEST_CASE(histTestBase, MatType, MatType) gsrc_roi = src_roi; } }; + ///////////////////////////calcHist/////////////////////////////////////// -struct calcHist : histTestBase {}; -OCL_TEST_P(calcHist, Mat) +typedef HistTestBase CalcHist; + +OCL_TEST_P(CalcHist, Mat) { for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::Mat cpu_hist; + Mat cpu_hist; calcHistGold(src_roi, dst_hist); - cv::ocl::calcHist(gsrc_roi, gdst_hist); + ocl::calcHist(gsrc_roi, gdst_hist); gdst_hist.download(cpu_hist); EXPECT_MAT_NEAR(dst_hist, cpu_hist, 0.0); } } + /////////////////////////////////////////////////////////////////////////////////////////////////////// // CLAHE -PARAM_TEST_CASE(CLAHE, cv::Size, double) +PARAM_TEST_CASE(CLAHE_Test, Size, double) { - cv::Size gridSize; + Size gridSize; double clipLimit; - cv::Mat src; - cv::Mat dst_gold; + Mat src; + Mat dst_gold; - cv::ocl::oclMat g_src; - cv::ocl::oclMat g_dst; + ocl::oclMat g_src; + ocl::oclMat g_dst; virtual void SetUp() { gridSize = GET_PARAM(0); clipLimit = GET_PARAM(1); - src = randomMat(cv::Size(MWIDTH, MHEIGHT), CV_8UC1, 0, 256, false); + src = randomMat(Size(MWIDTH, MHEIGHT), CV_8UC1, 0, 256, false); g_src.upload(src); } }; -OCL_TEST_P(CLAHE, Accuracy) +OCL_TEST_P(CLAHE_Test, Accuracy) { - cv::Ptr clahe = cv::ocl::createCLAHE(clipLimit, gridSize); + Ptr clahe = ocl::createCLAHE(clipLimit, gridSize); clahe->apply(g_src, g_dst); - cv::Mat dst(g_dst); + Mat dst(g_dst); - cv::Ptr clahe_gold = cv::createCLAHE(clipLimit, gridSize); + Ptr clahe_gold = createCLAHE(clipLimit, gridSize); clahe_gold->apply(src, dst_gold); EXPECT_MAT_NEAR(dst_gold, dst, 1.0); } ///////////////////////////Convolve////////////////////////////////// + PARAM_TEST_CASE(ConvolveTestBase, MatType, bool) { int type; //src mat - cv::Mat mat1; - cv::Mat mat2; - cv::Mat dst; - cv::Mat dst1; //bak, for two outputs + Mat mat1; + Mat mat2; + Mat dst; + Mat dst1; //bak, for two outputs // set up roi int roicols; int roirows; @@ -1385,23 +1392,23 @@ PARAM_TEST_CASE(ConvolveTestBase, MatType, bool) int dstx; int dsty; //src mat with roi - cv::Mat mat1_roi; - cv::Mat mat2_roi; - cv::Mat dst_roi; - cv::Mat dst1_roi; //bak + Mat mat1_roi; + Mat mat2_roi; + Mat dst_roi; + Mat dst1_roi; //bak //ocl dst mat for testing - cv::ocl::oclMat gdst_whole; - cv::ocl::oclMat gdst1_whole; //bak + ocl::oclMat gdst_whole; + ocl::oclMat gdst1_whole; //bak //ocl mat with roi - cv::ocl::oclMat gmat1; - cv::ocl::oclMat gmat2; - cv::ocl::oclMat gdst; - cv::ocl::oclMat gdst1; //bak + ocl::oclMat gmat1; + ocl::oclMat gmat2; + ocl::oclMat gdst; + ocl::oclMat gdst1; //bak virtual void SetUp() { type = GET_PARAM(0); - cv::Size size(MWIDTH, MHEIGHT); + Size size(MWIDTH, MHEIGHT); mat1 = randomMat(size, type, 5, 16, false); mat2 = randomMat(size, type, 5, 16, false); @@ -1445,9 +1452,10 @@ PARAM_TEST_CASE(ConvolveTestBase, MatType, bool) } }; -struct Convolve : ConvolveTestBase {}; -void conv2( cv::Mat x, cv::Mat y, cv::Mat z) +typedef ConvolveTestBase Convolve; + +void conv2( Mat x, Mat y, Mat z) { int N1 = x.rows; int M1 = x.cols; @@ -1477,6 +1485,7 @@ void conv2( cv::Mat x, cv::Mat y, cv::Mat z) dstdata[i * (z.step >> 2) + j] = temp; } } + OCL_TEST_P(Convolve, Mat) { if(mat1.type() != CV_32FC1) @@ -1486,14 +1495,14 @@ OCL_TEST_P(Convolve, Mat) for(int j = 0; j < LOOP_TIMES; j++) { random_roi(); - cv::ocl::oclMat temp1; - cv::Mat kernel_cpu = mat2(Rect(0, 0, 7, 7)); + ocl::oclMat temp1; + Mat kernel_cpu = mat2(Rect(0, 0, 7, 7)); temp1 = kernel_cpu; conv2(kernel_cpu, mat1_roi, dst_roi); - cv::ocl::convolve(gmat1, temp1, gdst); + ocl::convolve(gmat1, temp1, gdst); - cv::Mat cpu_dst; + Mat cpu_dst; gdst_whole.download(cpu_dst); EXPECT_MAT_NEAR(dst, cpu_dst, .1); @@ -1501,10 +1510,11 @@ OCL_TEST_P(Convolve, Mat) } //////////////////////////////// ColumnSum ////////////////////////////////////// -PARAM_TEST_CASE(ColumnSum, cv::Size) + +PARAM_TEST_CASE(ColumnSum, Size) { - cv::Size size; - cv::Mat src; + Size size; + Mat src; virtual void SetUp() { @@ -1514,13 +1524,13 @@ PARAM_TEST_CASE(ColumnSum, cv::Size) OCL_TEST_P(ColumnSum, Accuracy) { - cv::Mat src = randomMat(size, CV_32FC1, 0, 255); - cv::ocl::oclMat d_dst; - cv::ocl::oclMat d_src(src); + Mat src = randomMat(size, CV_32FC1, 0, 255); + ocl::oclMat d_dst; + ocl::oclMat d_src(src); - cv::ocl::columnSum(d_src, d_dst); + ocl::columnSum(d_src, d_dst); - cv::Mat dst(d_dst); + Mat dst(d_dst); for (int j = 0; j < src.cols; ++j) { @@ -1539,9 +1549,10 @@ OCL_TEST_P(ColumnSum, Accuracy) } } } + ///////////////////////////////////////////////////////////////////////////////////// -INSTANTIATE_TEST_CASE_P(ImgprocTestBase, equalizeHist, Combine( +INSTANTIATE_TEST_CASE_P(ImgprocTestBase, EqualizeHist, Combine( ONE_TYPE(CV_8UC1), NULL_TYPE, ONE_TYPE(CV_8UC1), @@ -1558,7 +1569,7 @@ INSTANTIATE_TEST_CASE_P(ImgprocTestBase, CopyMakeBorder, Combine( NULL_TYPE, Values(false))); // Values(false) is the reserved parameter -INSTANTIATE_TEST_CASE_P(ImgprocTestBase, cornerMinEigenVal, Combine( +INSTANTIATE_TEST_CASE_P(ImgprocTestBase, CornerMinEigenVal, Combine( Values(CV_8UC1, CV_32FC1), NULL_TYPE, ONE_TYPE(CV_32FC1), @@ -1566,7 +1577,7 @@ INSTANTIATE_TEST_CASE_P(ImgprocTestBase, cornerMinEigenVal, Combine( NULL_TYPE, Values(false))); // Values(false) is the reserved parameter -INSTANTIATE_TEST_CASE_P(ImgprocTestBase, cornerHarris, Combine( +INSTANTIATE_TEST_CASE_P(ImgprocTestBase, CornerHarris, Combine( Values(CV_8UC1, CV_32FC1), NULL_TYPE, ONE_TYPE(CV_32FC1), @@ -1575,7 +1586,7 @@ INSTANTIATE_TEST_CASE_P(ImgprocTestBase, cornerHarris, Combine( Values(false))); // Values(false) is the reserved parameter -INSTANTIATE_TEST_CASE_P(ImgprocTestBase, integral, Combine( +INSTANTIATE_TEST_CASE_P(ImgprocTestBase, Integral, Combine( ONE_TYPE(CV_8UC1), NULL_TYPE, ONE_TYPE(CV_32SC1), @@ -1585,60 +1596,60 @@ INSTANTIATE_TEST_CASE_P(ImgprocTestBase, integral, Combine( INSTANTIATE_TEST_CASE_P(Imgproc, WarpAffine, Combine( Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4), - Values((MatType)cv::INTER_NEAREST, (MatType)cv::INTER_LINEAR, - (MatType)cv::INTER_CUBIC, (MatType)(cv::INTER_NEAREST | cv::WARP_INVERSE_MAP), - (MatType)(cv::INTER_LINEAR | cv::WARP_INVERSE_MAP), (MatType)(cv::INTER_CUBIC | cv::WARP_INVERSE_MAP)))); + Values((MatType)INTER_NEAREST, (MatType)INTER_LINEAR, + (MatType)INTER_CUBIC, (MatType)(INTER_NEAREST | WARP_INVERSE_MAP), + (MatType)(INTER_LINEAR | WARP_INVERSE_MAP), (MatType)(INTER_CUBIC | WARP_INVERSE_MAP)))); INSTANTIATE_TEST_CASE_P(Imgproc, WarpPerspective, Combine (Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4), - Values((MatType)cv::INTER_NEAREST, (MatType)cv::INTER_LINEAR, - (MatType)cv::INTER_CUBIC, (MatType)(cv::INTER_NEAREST | cv::WARP_INVERSE_MAP), - (MatType)(cv::INTER_LINEAR | cv::WARP_INVERSE_MAP), (MatType)(cv::INTER_CUBIC | cv::WARP_INVERSE_MAP)))); + Values((MatType)INTER_NEAREST, (MatType)INTER_LINEAR, + (MatType)INTER_CUBIC, (MatType)(INTER_NEAREST | WARP_INVERSE_MAP), + (MatType)(INTER_LINEAR | WARP_INVERSE_MAP), (MatType)(INTER_CUBIC | WARP_INVERSE_MAP)))); INSTANTIATE_TEST_CASE_P(Imgproc, Resize, Combine( - Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4), Values(cv::Size()), - Values(0.5, 1.5, 2), Values(0.5, 1.5, 2), Values((MatType)cv::INTER_NEAREST, (MatType)cv::INTER_LINEAR))); + Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4), Values(Size()), + Values(0.5, 1.5, 2), Values(0.5, 1.5, 2), Values((MatType)INTER_NEAREST, (MatType)INTER_LINEAR))); INSTANTIATE_TEST_CASE_P(Imgproc, Threshold, Combine( - Values(CV_8UC1, CV_32FC1), Values(ThreshOp(cv::THRESH_BINARY), - ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), - ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV)))); + Values(CV_8UC1, CV_32FC1), Values(ThreshOp(THRESH_BINARY), + ThreshOp(THRESH_BINARY_INV), ThreshOp(THRESH_TRUNC), + ThreshOp(THRESH_TOZERO), ThreshOp(THRESH_TOZERO_INV)))); -INSTANTIATE_TEST_CASE_P(Imgproc, meanShiftFiltering, Combine( +INSTANTIATE_TEST_CASE_P(Imgproc, MeanShiftFiltering, Combine( ONE_TYPE(CV_8UC4), ONE_TYPE(CV_16SC2), Values(5), Values(6), - Values(cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1)) + Values(TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 5, 1)) )); -INSTANTIATE_TEST_CASE_P(Imgproc, meanShiftProc, Combine( +INSTANTIATE_TEST_CASE_P(Imgproc, MeanShiftProc, Combine( ONE_TYPE(CV_8UC4), ONE_TYPE(CV_16SC2), Values(5), Values(6), - Values(cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1)) + Values(TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 5, 1)) )); INSTANTIATE_TEST_CASE_P(Imgproc, Remap, Combine( Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4), Values(CV_32FC1, CV_16SC2, CV_32FC2), Values(-1, CV_32FC1), - Values((int)cv::INTER_NEAREST, (int)cv::INTER_LINEAR), - Values((int)cv::BORDER_CONSTANT))); + Values((int)INTER_NEAREST, (int)INTER_LINEAR), + Values((int)BORDER_CONSTANT))); -INSTANTIATE_TEST_CASE_P(histTestBase, calcHist, Combine( +INSTANTIATE_TEST_CASE_P(histTestBase, CalcHist, Combine( ONE_TYPE(CV_8UC1), ONE_TYPE(CV_32SC1) //no use )); -INSTANTIATE_TEST_CASE_P(Imgproc, CLAHE, Combine( - Values(cv::Size(4, 4), cv::Size(32, 8), cv::Size(8, 64)), +INSTANTIATE_TEST_CASE_P(Imgproc, CLAHE_Test, Combine( + Values(Size(4, 4), Size(32, 8), Size(8, 64)), Values(0.0, 10.0, 62.0, 300.0))); INSTANTIATE_TEST_CASE_P(Imgproc, ColumnSum, DIFFERENT_SIZES); -- 2.7.4