diff --git a/modules/gpu/src/cuda/bilateral_filter.cu b/modules/gpu/src/cuda/bilateral_filter.cu index 15e72a8b75..69f58aabd9 100644 --- a/modules/gpu/src/cuda/bilateral_filter.cu +++ b/modules/gpu/src/cuda/bilateral_filter.cu @@ -149,6 +149,16 @@ namespace cv { namespace gpu { namespace device { typedef void (*caller_t)(const PtrStepSzb& src, PtrStepSzb dst, int kernel_size, float sigma_spatial, float sigma_color, cudaStream_t stream); +#ifdef OPENCV_TINY_GPU_MODULE + static caller_t funcs[] = + { + bilateral_caller, + bilateral_caller, + 0, + 0, + 0, + }; +#else static caller_t funcs[] = { bilateral_caller, @@ -157,7 +167,13 @@ namespace cv { namespace gpu { namespace device bilateral_caller, bilateral_caller, }; - funcs[borderMode](src, dst, kernel_size, gauss_spatial_coeff, gauss_color_coeff, stream); +#endif + + const caller_t caller = funcs[borderMode]; + if (!caller) + cv::gpu::error("Unsupported input parameters for bilateral_filter", __FILE__, __LINE__, ""); + + caller(src, dst, kernel_size, gauss_spatial_coeff, gauss_color_coeff, stream); } } }}} @@ -171,6 +187,7 @@ OCV_INSTANTIATE_BILATERAL_FILTER(uchar) OCV_INSTANTIATE_BILATERAL_FILTER(uchar3) OCV_INSTANTIATE_BILATERAL_FILTER(uchar4) +#ifndef OPENCV_TINY_GPU_MODULE //OCV_INSTANTIATE_BILATERAL_FILTER(schar) //OCV_INSTANTIATE_BILATERAL_FILTER(schar2) //OCV_INSTANTIATE_BILATERAL_FILTER(schar3) @@ -190,6 +207,7 @@ OCV_INSTANTIATE_BILATERAL_FILTER(ushort4) //OCV_INSTANTIATE_BILATERAL_FILTER(int2) //OCV_INSTANTIATE_BILATERAL_FILTER(int3) //OCV_INSTANTIATE_BILATERAL_FILTER(int4) +#endif OCV_INSTANTIATE_BILATERAL_FILTER(float) //OCV_INSTANTIATE_BILATERAL_FILTER(float2) diff --git a/modules/gpu/src/denoising.cpp b/modules/gpu/src/denoising.cpp index 50fab0cc2e..3eb74a92e6 100644 --- a/modules/gpu/src/denoising.cpp +++ b/modules/gpu/src/denoising.cpp @@ -77,6 +77,17 @@ void cv::gpu::bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, f typedef void (*func_t)(const PtrStepSzb& src, PtrStepSzb dst, int kernel_size, float sigma_spatial, float sigma_color, int borderMode, cudaStream_t s); +#ifdef OPENCV_TINY_GPU_MODULE + static const func_t funcs[6][4] = + { + {bilateral_filter_gpu , 0 /*bilateral_filter_gpu*/ , bilateral_filter_gpu , bilateral_filter_gpu }, + {0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ }, + {0 /*bilateral_filter_gpu*/, 0 /*bilateral_filter_gpu*/, 0 /*bilateral_filter_gpu*/, 0 /*bilateral_filter_gpu*/}, + {0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ }, + {0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ }, + {bilateral_filter_gpu , 0 /*bilateral_filter_gpu*/ , bilateral_filter_gpu , bilateral_filter_gpu } + }; +#else static const func_t funcs[6][4] = { {bilateral_filter_gpu , 0 /*bilateral_filter_gpu*/ , bilateral_filter_gpu , bilateral_filter_gpu }, @@ -86,6 +97,7 @@ void cv::gpu::bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, f {0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ , 0 /*bilateral_filter_gpu*/ }, {bilateral_filter_gpu , 0 /*bilateral_filter_gpu*/ , bilateral_filter_gpu , bilateral_filter_gpu } }; +#endif sigma_color = (sigma_color <= 0 ) ? 1 : sigma_color; sigma_spatial = (sigma_spatial <= 0 ) ? 1 : sigma_spatial;