Skip to content

Commit 0f12351

Browse files
author
elenagvo
committed
fix accelerators order
1 parent 7aadbc9 commit 0f12351

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

modules/imgproc/src/filter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4333,7 +4333,7 @@ static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst,
43334333
return k.run(2, gt2, lt2, false);
43344334
}
43354335

4336-
static bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
4336+
bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
43374337
InputArray _kernelX, InputArray _kernelY, Point anchor,
43384338
double delta, int borderType )
43394339
{

modules/imgproc/src/filter.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ namespace cv
5050
int SymmColumnVec_32f_Symm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2);
5151
int SymmColumnVec_32f_Unsymm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2);
5252
#endif
53+
54+
#ifdef HAVE_OPENCL
55+
bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
56+
InputArray _kernelX, InputArray _kernelY, Point anchor,
57+
double delta, int borderType );
58+
#endif
5359
}
5460

5561
#endif

modules/imgproc/src/smooth.cpp

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
#include "opencv2/core/openvx/ovx_defs.hpp"
4949

50+
#include "filter.hpp"
51+
5052
/*
5153
* This file includes the code, contributed by Simon Perreault
5254
* (the function icvMedianBlur_8u_O1)
@@ -1536,9 +1538,6 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
15361538

15371539
CV_OCL_RUN(_dst.isUMat(), ocl_boxFilter(_src, _dst, ddepth, ksize, anchor, borderType, normalize))
15381540

1539-
CV_OVX_RUN(true,
1540-
openvx_boxfilter(_src, _dst, ddepth, ksize, anchor, normalize, borderType))
1541-
15421541
Mat src = _src.getMat();
15431542
int stype = src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
15441543
if( ddepth < 0 )
@@ -1557,19 +1556,18 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
15571556
Size wsz(src.cols, src.rows);
15581557
if(!(borderType&BORDER_ISOLATED))
15591558
src.locateROI( wsz, ofs );
1560-
borderType = (borderType&~BORDER_ISOLATED);
15611559

15621560
CALL_HAL(boxFilter, cv_hal_boxFilter, sdepth, ddepth, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, cn,
15631561
ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, ksize.width, ksize.height,
1564-
anchor.x, anchor.y, normalize, borderType);
1562+
anchor.x, anchor.y, normalize, borderType&~BORDER_ISOLATED);
15651563

1566-
#ifdef HAVE_TEGRA_OPTIMIZATION
1567-
if ( tegra::useTegra() && tegra::box(src, dst, ksize, anchor, normalize, borderType) )
1568-
return;
1569-
#endif
1564+
CV_OVX_RUN(true,
1565+
openvx_boxfilter(_src, _dst, ddepth, ksize, anchor, normalize, borderType))
15701566

15711567
CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType));
15721568

1569+
borderType = (borderType&~BORDER_ISOLATED);
1570+
15731571
Ptr<FilterEngine> f = createBoxFilter( src.type(), dst.type(),
15741572
ksize, anchor, normalize, borderType );
15751573

@@ -2098,16 +2096,6 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
20982096
return;
20992097
}
21002098

2101-
CV_OVX_RUN(true,
2102-
openvx_gaussianBlur(_src, _dst, ksize, sigma1, sigma2, borderType))
2103-
2104-
Mat src = _src.getMat();
2105-
Mat dst = _dst.getMat();
2106-
2107-
#ifdef HAVE_TEGRA_OPTIMIZATION
2108-
if(sigma1 == 0 && sigma2 == 0 && tegra::useTegra() && tegra::gaussian(src, dst, ksize, borderType))
2109-
return;
2110-
#endif
21112099
bool useOpenCL = (ocl::isOpenCLActivated() && _dst.isUMat() && _src.dims() <= 2 &&
21122100
((ksize.width == 3 && ksize.height == 3) ||
21132101
(ksize.width == 5 && ksize.height == 5)) &&
@@ -2116,27 +2104,35 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
21162104

21172105
int sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
21182106

2107+
Mat kx, ky;
2108+
createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2);
2109+
2110+
CV_OCL_RUN(useOpenCL, ocl_GaussianBlur_8UC1(_src, _dst, ksize, CV_MAT_DEPTH(type), kx, ky, borderType));
2111+
2112+
CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2 && (size_t)_src.rows() > kx.total() && (size_t)_src.cols() > kx.total(),
2113+
ocl_sepFilter2D(_src, _dst, sdepth, kx, ky, Point(-1, -1), 0, borderType))
2114+
2115+
Mat src = _src.getMat();
2116+
Mat dst = _dst.getMat();
2117+
21192118
Point ofs;
21202119
Size wsz(src.cols, src.rows);
21212120
if(!(borderType & BORDER_ISOLATED))
21222121
src.locateROI( wsz, ofs );
2123-
borderType = (borderType&~BORDER_ISOLATED);
21242122

21252123
CALL_HAL(gaussianBlur, cv_hal_gaussianBlur, sdepth, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, cn,
21262124
ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, ksize.width, ksize.height,
2127-
sigma1, sigma2, borderType);
2125+
sigma1, sigma2, borderType&~BORDER_ISOLATED);
21282126

21292127
src.release();
21302128
dst.release();
21312129

2132-
CV_IPP_RUN(!useOpenCL, ipp_GaussianBlur( _src, _dst, ksize, sigma1, sigma2, borderType));
2133-
2134-
Mat kx, ky;
2135-
createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2);
2130+
CV_OVX_RUN(true,
2131+
openvx_gaussianBlur(_src, _dst, ksize, sigma1, sigma2, borderType))
21362132

2137-
CV_OCL_RUN(useOpenCL, ocl_GaussianBlur_8UC1(_src, _dst, ksize, CV_MAT_DEPTH(type), kx, ky, borderType));
2133+
CV_IPP_RUN_FAST(ipp_GaussianBlur(_src, _dst, ksize, sigma1, sigma2, borderType));
21382134

2139-
sepFilter2D(_src, _dst, CV_MAT_DEPTH(type), kx, ky, Point(-1,-1), 0, borderType );
2135+
sepFilter2D(_src, _dst, sdepth, kx, ky, Point(-1, -1), 0, borderType);
21402136
}
21412137

21422138
/****************************************************************************************\

0 commit comments

Comments
 (0)