diff --git a/modules/gpu/src/cuda/remap.cu b/modules/gpu/src/cuda/remap.cu index f40ada030..77bf97614 100644 --- a/modules/gpu/src/cuda/remap.cu +++ b/modules/gpu/src/cuda/remap.cu @@ -209,6 +209,7 @@ namespace cv { namespace gpu { namespace device typedef void (*caller_t)(PtrStepSz src, PtrStepSz srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSz dst, const float* borderValue, cudaStream_t stream, bool cc20); +#ifdef OPENCV_TINY_GPU_MODULE static const caller_t callers[3][5] = { { @@ -216,25 +217,55 @@ namespace cv { namespace gpu { namespace device RemapDispatcher::call, RemapDispatcher::call, RemapDispatcher::call, - RemapDispatcher::call + 0/*RemapDispatcher::call*/, }, { RemapDispatcher::call, RemapDispatcher::call, RemapDispatcher::call, RemapDispatcher::call, - RemapDispatcher::call + 0/*RemapDispatcher::call*/, + }, + { + 0/*RemapDispatcher::call*/, + 0/*RemapDispatcher::call*/, + 0/*RemapDispatcher::call*/, + 0/*RemapDispatcher::call*/, + 0/*RemapDispatcher::call*/, + } + }; +#else + static const caller_t callers[3][5] = + { + { + RemapDispatcher::call, + RemapDispatcher::call, + RemapDispatcher::call, + RemapDispatcher::call, + RemapDispatcher::call, + }, + { + RemapDispatcher::call, + RemapDispatcher::call, + RemapDispatcher::call, + RemapDispatcher::call, + RemapDispatcher::call, }, { RemapDispatcher::call, RemapDispatcher::call, RemapDispatcher::call, RemapDispatcher::call, - RemapDispatcher::call + RemapDispatcher::call, } }; +#endif - callers[interpolation][borderMode](static_cast< PtrStepSz >(src), static_cast< PtrStepSz >(srcWhole), xoff, yoff, xmap, ymap, + const caller_t caller = callers[interpolation][borderMode]; + if (!caller) + cv::gpu::error("Unsupported input parameters for remap", __FILE__, __LINE__, ""); + + caller(static_cast< PtrStepSz >(src), static_cast< PtrStepSz >(srcWhole), xoff, yoff, xmap, ymap, static_cast< PtrStepSz >(dst), borderValue, stream, cc20); } @@ -243,6 +274,7 @@ namespace cv { namespace gpu { namespace device template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); +#ifndef OPENCV_TINY_GPU_MODULE //template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); @@ -262,6 +294,7 @@ namespace cv { namespace gpu { namespace device //template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); +#endif template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void remap_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); diff --git a/modules/gpu/src/remap.cpp b/modules/gpu/src/remap.cpp index 4b8728633..3e13c7285 100644 --- a/modules/gpu/src/remap.cpp +++ b/modules/gpu/src/remap.cpp @@ -65,6 +65,17 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp typedef void (*func_t)(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); +#ifdef OPENCV_TINY_GPU_MODULE + static const func_t funcs[6][4] = + { + {remap_gpu , 0 /*remap_gpu*/ , remap_gpu , remap_gpu }, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {remap_gpu , 0 /*remap_gpu*/ , remap_gpu , remap_gpu } + }; +#else static const func_t funcs[6][4] = { {remap_gpu , 0 /*remap_gpu*/ , remap_gpu , remap_gpu }, @@ -74,6 +85,7 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp {0 /*remap_gpu*/ , 0 /*remap_gpu*/ , 0 /*remap_gpu*/ , 0 /*remap_gpu*/ }, {remap_gpu , 0 /*remap_gpu*/ , remap_gpu , remap_gpu } }; +#endif CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); CV_Assert(xmap.type() == CV_32F && ymap.type() == CV_32F && xmap.size() == ymap.size());