From: Ilya Lavrenov Date: Tue, 24 Sep 2013 09:43:12 +0000 (+0400) Subject: removed comments from filtering.cpp and imgproc.cpp in ocl module X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~982^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=311a7233c2b66822ab5c8367d4a4c258eb782cd7;p=platform%2Fupstream%2Fopencv.git removed comments from filtering.cpp and imgproc.cpp in ocl module --- diff --git a/modules/ocl/src/filtering.cpp b/modules/ocl/src/filtering.cpp index e252d85..284dc61 100644 --- a/modules/ocl/src/filtering.cpp +++ b/modules/ocl/src/filtering.cpp @@ -130,7 +130,7 @@ public: { Size src_size = src.size(); - // Delete those two clause below which exist before, However, the result is alos correct + // Delete those two clause below which exist before, However, the result is also correct // dst.create(src_size, src.type()); // dst = Scalar(0.0); @@ -394,23 +394,8 @@ public: { Filter2DEngine_GPU::apply(src, dst); - //if (iters > 1) - //{ - // Size wholesize; - // Point ofs; - // dst.locateROI(wholesize,ofs); - // int rows = dst.rows, cols = dst.cols; - // dst.adjustROI(ofs.y,-ofs.y-rows+dst.wholerows,ofs.x,-ofs.x-cols+dst.wholecols); - // dst.copyTo(morfBuf); - // dst.adjustROI(-ofs.y,ofs.y+rows-dst.wholerows,-ofs.x,ofs.x+cols-dst.wholecols); - // morfBuf.adjustROI(-ofs.y,ofs.y+rows-dst.wholerows,-ofs.x,ofs.x+cols-dst.wholecols); - // //morfBuf.create(src.size(),src.type()); - // //Filter2DEngine_GPU::apply(dst, morfBuf); - // //morfBuf.copyTo(dst); - //} for (int i = 1; i < iters; ++i) { - //dst.swap(morfBuf); Size wholesize; Point ofs; dst.locateROI(wholesize, ofs); @@ -720,24 +705,16 @@ public: virtual void apply(const oclMat &src, oclMat &dst, Rect roi = Rect(0, 0, -1, -1)) { Size src_size = src.size(); - //int src_type = src.type(); int cn = src.oclchannels(); - //dst.create(src_size, src_type); - //dst = Scalar(0.0); - //dstBuf.create(src_size, src_type); dstBuf.create(src_size.height + ksize.height - 1, src_size.width, CV_MAKETYPE(CV_32F, cn)); - //dstBuf = Scalar(0.0); normalizeROI(roi, ksize, anchor, src_size); srcROI = src(roi); dstROI = dst(roi); - //dstBufROI = dstBuf(roi); (*rowFilter)(srcROI, dstBuf); - //Mat rm(dstBufROI); - //std::cout << "rm " << rm << endl; (*columnFilter)(dstBuf, dstROI); } @@ -1324,11 +1301,8 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker CV_Assert(src.oclchannels() == dst.oclchannels()); CV_Assert(ksize == (anchor << 1) + 1); int src_pix_per_row, dst_pix_per_row; - //int src_offset_x, src_offset_y; int dst_offset_in_pixel; src_pix_per_row = src.step / src.elemSize(); - //src_offset_x = (src.offset % src.step) / src.elemSize(); - //src_offset_y = src.offset / src.step; dst_pix_per_row = dst.step / dst.elemSize(); dst_offset_in_pixel = dst.offset / dst.elemSize(); @@ -1340,8 +1314,6 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker 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 *)&src_pix_per_row)); - //args.push_back(make_pair(sizeof(cl_int),(void*)&src_offset_x)); - //args.push_back(make_pair(sizeof(cl_int),(void*)&src_offset_y)); args.push_back(make_pair(sizeof(cl_int), (void *)&dst_pix_per_row)); args.push_back(make_pair(sizeof(cl_int), (void *)&dst_offset_in_pixel)); args.push_back(make_pair(sizeof(cl_mem), (void *)&mat_kernel.data)); @@ -1360,23 +1332,11 @@ Ptr cv::ocl::getLinearColumnFilter_GPU(int /*bufType*/, in linearColumnFilter_gpu, linearColumnFilter_gpu }; - /* - CV_Assert(dstType == CV_8UC4 || dstType == CV_8SC4 || dstType == CV_16UC2 || - dstType == CV_16SC2 || dstType == CV_32SC1 || dstType == CV_32FC1); - CV_Assert(bufType == CV_8UC4 || bufType == CV_8SC4 || bufType == CV_16UC2 || - bufType == CV_16SC2 || bufType == CV_32SC1 || bufType == CV_32FC1); - - Mat temp(columnKernel.size(), CV_32SC1); - columnKernel.convertTo(temp, CV_32SC1); - Mat cont_krnl = temp.reshape(1, 1); - */ + Mat temp = columnKernel.reshape(1, 1); oclMat mat_kernel(temp); int ksize = temp.cols; - - //CV_Assert(ksize < 16); - normalizeAnchor(anchor, ksize); return Ptr(new GpuLinearColumnFilter(ksize, anchor, mat_kernel, @@ -1414,11 +1374,8 @@ void cv::ocl::sepFilter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat } if (ddepth < 0) - { ddepth = src.depth(); - } - //CV_Assert(ddepth == src.depth()); dst.create(src.size(), CV_MAKETYPE(ddepth, src.channels())); Ptr f = createSeparableLinearFilter_GPU(src.type(), dst.type(), kernelX, kernelY, anchor, delta, bordertype); @@ -1445,19 +1402,11 @@ void cv::ocl::Sobel(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, // usually the smoothing part is the slowest to compute, // so try to scale it instead of the faster differenciating part if (dx == 0) - { kx *= scale; - } else - { ky *= scale; - } } - // Mat kx_, ky_; - //ky.convertTo(ky_,CV_32S,1<<8); - //kx.convertTo(kx_,CV_32S,1<<8); - sepFilter2D(src, dst, ddepth, kx, ky, Point(-1, -1), delta, borderType); } @@ -1471,19 +1420,11 @@ void cv::ocl::Scharr(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, // usually the smoothing part is the slowest to compute, // so try to scale it instead of the faster differenciating part if (dx == 0) - { kx *= scale; - } else - { ky *= scale; - } } - // Mat kx_, ky_; - //ky.convertTo(ky_,CV_32S,1<<8); - //kx.convertTo(kx_,CV_32S,1<<8); - sepFilter2D(src, dst, ddepth, kx, ky, Point(-1, -1), delta, bordertype); } @@ -1505,9 +1446,7 @@ void cv::ocl::Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize, d Mat kernel(3, 3, CV_32S, (void *)K[ksize == 3]); if (scale != 1) - { kernel *= scale; - } filter2D(src, dst, ddepth, kernel, Point(-1, -1)); } @@ -1526,14 +1465,10 @@ Ptr cv::ocl::createGaussianFilter_GPU(int type, Size ksize, do // automatic detection of kernel size from sigma if (ksize.width <= 0 && sigma1 > 0) - { ksize.width = cvRound(sigma1 * (depth == CV_8U ? 3 : 4) * 2 + 1) | 1; - } if (ksize.height <= 0 && sigma2 > 0) - { ksize.height = cvRound(sigma2 * (depth == CV_8U ? 3 : 4) * 2 + 1) | 1; - } CV_Assert(ksize.width > 0 && ksize.width % 2 == 1 && ksize.height > 0 && ksize.height % 2 == 1); @@ -1544,17 +1479,10 @@ Ptr cv::ocl::createGaussianFilter_GPU(int type, Size ksize, do Mat ky; if (ksize.height == ksize.width && std::abs(sigma1 - sigma2) < DBL_EPSILON) - { ky = kx; - } else - { ky = getGaussianKernel(ksize.height, sigma2, std::max(depth, CV_32F)); - } - //Mat kx_, ky_; - //kx.convertTo(kx_,CV_32S,1<<8); - //ky.convertTo(ky_,CV_32S,1<<8); return createSeparableLinearFilter_GPU(type, type, kx, ky, Point(-1, -1), 0.0, bordertype); } @@ -1585,14 +1513,10 @@ void cv::ocl::GaussianBlur(const oclMat &src, oclMat &dst, Size ksize, double si if (bordertype != BORDER_CONSTANT) { if (src.rows == 1) - { ksize.height = 1; - } if (src.cols == 1) - { ksize.width = 1; - } } Ptr f = createGaussianFilter_GPU(src.type(), ksize, sigma1, sigma2, bordertype); @@ -1618,6 +1542,7 @@ void cv::ocl::adaptiveBilateralFilter(const oclMat& src, oclMat& dst, Size ksize { lut.at(idx++) = sigma2 / (sigma2 + x * x + y * y); } + oclMat dlut(lut); int depth = src.depth(); int cn = src.oclchannels(); diff --git a/modules/ocl/src/imgproc.cpp b/modules/ocl/src/imgproc.cpp index 2ed786f..7d0d941 100644 --- a/modules/ocl/src/imgproc.cpp +++ b/modules/ocl/src/imgproc.cpp @@ -244,9 +244,6 @@ namespace cv kernelName = "remapNNF1Constant"; } - //int channels = dst.oclchannels(); - //int depth = dst.depth(); - //int type = src.type(); size_t blkSizeX = 16, blkSizeY = 16; size_t glbSizeX; int cols = dst.cols; @@ -499,21 +496,13 @@ namespace cv openCLExecuteKernel(clCxt, &imgproc_median, kernelName, globalThreads, localThreads, args, src.oclchannels(), src.depth()); } else - { CV_Error(CV_StsUnsupportedFormat, "Non-supported filter length"); - //string kernelName = "medianFilter"; - //args.push_back( make_pair( sizeof(cl_int),(void*)&m)); - - //openCLExecuteKernel(clCxt,&imgproc_median,kernelName,globalThreads,localThreads,args,src.oclchannels(),-1); - } - } //////////////////////////////////////////////////////////////////////// // copyMakeBorder void copyMakeBorder(const oclMat &src, oclMat &dst, int top, int bottom, int left, int right, int bordertype, const Scalar &scalar) { - //CV_Assert(src.oclchannels() != 2); CV_Assert(top >= 0 && bottom >= 0 && left >= 0 && right >= 0); if((dst.cols != dst.wholecols) || (dst.rows != dst.wholerows)) //has roi { @@ -529,10 +518,12 @@ namespace cv { CV_Assert((src.cols >= left) && (src.cols >= right) && (src.rows >= top) && (src.rows >= bottom)); } + if(bordertype == cv::BORDER_REFLECT_101) { CV_Assert((src.cols > left) && (src.cols > right) && (src.rows > top) && (src.rows > bottom)); } + dst.create(src.rows + top + bottom, src.cols + left + right, src.type()); int srcStep = src.step1() / src.oclchannels(); int dstStep = dst.step1() / dst.oclchannels(); @@ -732,19 +723,6 @@ namespace cv } openCLExecuteKernel(src.clCxt, &imgproc_copymakeboder, kernelName, globalThreads, localThreads, args, -1, -1, compile_option); - //uchar* cputemp=new uchar[32*dst.wholerows]; - ////int* cpudata=new int[this->step*this->wholerows/sizeof(int)]; - //openCLSafeCall(clEnqueueReadBuffer(src.clCxt->impl->clCmdQueue, (cl_mem)dst.data, CL_TRUE, - // 0, 32*dst.wholerows, cputemp, 0, NULL, NULL)); - //for(int i=0;isupportsFeature(Context::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"); - // } - dst.create( src.size(), CV_8UC4 ); if( !(criteria.type & TermCriteria::MAX_ITER) )