From 0f12351a41d291a649bb81923c6f06e6cb886282 Mon Sep 17 00:00:00 2001 From: elenagvo Date: Tue, 14 Nov 2017 12:57:02 +0300 Subject: [PATCH] fix accelerators order --- modules/imgproc/src/filter.cpp | 2 +- modules/imgproc/src/filter.hpp | 6 +++++ modules/imgproc/src/smooth.cpp | 50 +++++++++++++++++++----------------------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index e732ce5..1302407 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -4333,7 +4333,7 @@ static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst, return k.run(2, gt2, lt2, false); } -static bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, +bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, InputArray _kernelX, InputArray _kernelY, Point anchor, double delta, int borderType ) { diff --git a/modules/imgproc/src/filter.hpp b/modules/imgproc/src/filter.hpp index c878fea..93f3f17 100644 --- a/modules/imgproc/src/filter.hpp +++ b/modules/imgproc/src/filter.hpp @@ -50,6 +50,12 @@ namespace cv int SymmColumnVec_32f_Symm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2); int SymmColumnVec_32f_Unsymm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2); #endif + +#ifdef HAVE_OPENCL + bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, + InputArray _kernelX, InputArray _kernelY, Point anchor, + double delta, int borderType ); +#endif } #endif diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 2791051..0ca087c 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -47,6 +47,8 @@ #include "opencv2/core/openvx/ovx_defs.hpp" +#include "filter.hpp" + /* * This file includes the code, contributed by Simon Perreault * (the function icvMedianBlur_8u_O1) @@ -1536,9 +1538,6 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, CV_OCL_RUN(_dst.isUMat(), ocl_boxFilter(_src, _dst, ddepth, ksize, anchor, borderType, normalize)) - CV_OVX_RUN(true, - openvx_boxfilter(_src, _dst, ddepth, ksize, anchor, normalize, borderType)) - Mat src = _src.getMat(); int stype = src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); if( ddepth < 0 ) @@ -1557,19 +1556,18 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, Size wsz(src.cols, src.rows); if(!(borderType&BORDER_ISOLATED)) src.locateROI( wsz, ofs ); - borderType = (borderType&~BORDER_ISOLATED); CALL_HAL(boxFilter, cv_hal_boxFilter, sdepth, ddepth, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, cn, ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, ksize.width, ksize.height, - anchor.x, anchor.y, normalize, borderType); + anchor.x, anchor.y, normalize, borderType&~BORDER_ISOLATED); -#ifdef HAVE_TEGRA_OPTIMIZATION - if ( tegra::useTegra() && tegra::box(src, dst, ksize, anchor, normalize, borderType) ) - return; -#endif + CV_OVX_RUN(true, + openvx_boxfilter(_src, _dst, ddepth, ksize, anchor, normalize, borderType)) CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType)); + borderType = (borderType&~BORDER_ISOLATED); + Ptr f = createBoxFilter( src.type(), dst.type(), ksize, anchor, normalize, borderType ); @@ -2098,16 +2096,6 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, return; } - CV_OVX_RUN(true, - openvx_gaussianBlur(_src, _dst, ksize, sigma1, sigma2, borderType)) - - Mat src = _src.getMat(); - Mat dst = _dst.getMat(); - -#ifdef HAVE_TEGRA_OPTIMIZATION - if(sigma1 == 0 && sigma2 == 0 && tegra::useTegra() && tegra::gaussian(src, dst, ksize, borderType)) - return; -#endif bool useOpenCL = (ocl::isOpenCLActivated() && _dst.isUMat() && _src.dims() <= 2 && ((ksize.width == 3 && ksize.height == 3) || (ksize.width == 5 && ksize.height == 5)) && @@ -2116,27 +2104,35 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, int sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + Mat kx, ky; + createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2); + + CV_OCL_RUN(useOpenCL, ocl_GaussianBlur_8UC1(_src, _dst, ksize, CV_MAT_DEPTH(type), kx, ky, borderType)); + + CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2 && (size_t)_src.rows() > kx.total() && (size_t)_src.cols() > kx.total(), + ocl_sepFilter2D(_src, _dst, sdepth, kx, ky, Point(-1, -1), 0, borderType)) + + Mat src = _src.getMat(); + Mat dst = _dst.getMat(); + Point ofs; Size wsz(src.cols, src.rows); if(!(borderType & BORDER_ISOLATED)) src.locateROI( wsz, ofs ); - borderType = (borderType&~BORDER_ISOLATED); CALL_HAL(gaussianBlur, cv_hal_gaussianBlur, sdepth, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, cn, ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, ksize.width, ksize.height, - sigma1, sigma2, borderType); + sigma1, sigma2, borderType&~BORDER_ISOLATED); src.release(); dst.release(); - CV_IPP_RUN(!useOpenCL, ipp_GaussianBlur( _src, _dst, ksize, sigma1, sigma2, borderType)); - - Mat kx, ky; - createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2); + CV_OVX_RUN(true, + openvx_gaussianBlur(_src, _dst, ksize, sigma1, sigma2, borderType)) - CV_OCL_RUN(useOpenCL, ocl_GaussianBlur_8UC1(_src, _dst, ksize, CV_MAT_DEPTH(type), kx, ky, borderType)); + CV_IPP_RUN_FAST(ipp_GaussianBlur(_src, _dst, ksize, sigma1, sigma2, borderType)); - sepFilter2D(_src, _dst, CV_MAT_DEPTH(type), kx, ky, Point(-1,-1), 0, borderType ); + sepFilter2D(_src, _dst, sdepth, kx, ky, Point(-1, -1), 0, borderType); } /****************************************************************************************\ -- 2.7.4