From 37cccf17c044e50c94039300f9bdd5a0e3676445 Mon Sep 17 00:00:00 2001 From: matze Date: Thu, 21 Jul 2016 19:59:26 +0200 Subject: [PATCH 1/3] imgproc: Prefer OCL calculation before IPP in GaussianBlur. --- modules/imgproc/src/smooth.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index b5a037ec2d..f12036dad3 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -1850,7 +1850,7 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, return; #endif - CV_IPP_RUN(true, ipp_GaussianBlur( _src, _dst, ksize, sigma1, sigma2, borderType)); + CV_IPP_RUN(!(ocl::useOpenCL() && _dst.isUMat()), ipp_GaussianBlur( _src, _dst, ksize, sigma1, sigma2, borderType)); Mat kx, ky; createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2); From 2812762d6b59b46eb9c48f7f989010b6b12d5b96 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 4 Aug 2016 17:50:23 +0300 Subject: [PATCH 2/3] imgproc: disable IPP for GaussianBlur in case of ROI --- modules/imgproc/src/smooth.cpp | 3 +++ modules/imgproc/test/ocl/test_filters.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index f12036dad3..8245a62057 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -1734,6 +1734,9 @@ static bool ipp_GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, int borderType ) { #if IPP_VERSION_X100 >= 810 + if ((borderType & BORDER_ISOLATED) == 0 && _src.isSubmatrix()) + return false; + int type = _src.type(); Size size = _src.size(); diff --git a/modules/imgproc/test/ocl/test_filters.cpp b/modules/imgproc/test/ocl/test_filters.cpp index 0c4564e5ac..f92cc785a1 100644 --- a/modules/imgproc/test/ocl/test_filters.cpp +++ b/modules/imgproc/test/ocl/test_filters.cpp @@ -225,7 +225,7 @@ OCL_TEST_P(GaussianBlurTest, Mat) OCL_OFF(cv::GaussianBlur(src_roi, dst_roi, Size(ksize, ksize), sigma1, sigma2, borderType)); OCL_ON(cv::GaussianBlur(usrc_roi, udst_roi, Size(ksize, ksize), sigma1, sigma2, borderType)); - Near(CV_MAT_DEPTH(type) >= CV_32F ? 7e-5 : 1, false); + Near(CV_MAT_DEPTH(type) >= CV_32F ? 1e-3 : 4, CV_MAT_DEPTH(type) >= CV_32F); } } From b12286329fdc8b5c840a6c310f44271240a62aca Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 4 Aug 2016 18:05:39 +0300 Subject: [PATCH 3/3] imgproc: sepFilter: update OpenCL condition Problem is observed with test_loop_times=100 in corner cases like 93x1 or similar --- modules/imgproc/src/filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index 50b38094a9..1a7f27af3b 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -5019,7 +5019,7 @@ void cv::sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, InputArray _kernelX, InputArray _kernelY, Point anchor, double delta, int borderType ) { - CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2, + CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2 && (size_t)_src.rows() > _kernelY.total() && (size_t)_src.cols() > _kernelX.total(), ocl_sepFilter2D(_src, _dst, ddepth, _kernelX, _kernelY, anchor, delta, borderType)) Mat src = _src.getMat(), kernelX = _kernelX.getMat(), kernelY = _kernelY.getMat();