diff --git a/modules/gpu/src/cuda/warp.cu b/modules/gpu/src/cuda/warp.cu index 49130d9405..ad867601ed 100644 --- a/modules/gpu/src/cuda/warp.cu +++ b/modules/gpu/src/cuda/warp.cu @@ -278,6 +278,7 @@ namespace cv { namespace gpu { namespace device { typedef void (*func_t)(PtrStepSz src, PtrStepSz srcWhole, int xoff, int yoff, PtrStepSz dst, const float* borderValue, cudaStream_t stream, bool cc20); +#ifdef OPENCV_TINY_GPU_MODULE static const func_t funcs[3][5] = { { @@ -285,25 +286,55 @@ namespace cv { namespace gpu { namespace device WarpDispatcher::call, WarpDispatcher::call, WarpDispatcher::call, - WarpDispatcher::call + 0/*WarpDispatcher::call*/, }, { WarpDispatcher::call, WarpDispatcher::call, WarpDispatcher::call, WarpDispatcher::call, - WarpDispatcher::call + 0/*WarpDispatcher::call*/, + }, + { + 0/*WarpDispatcher::call*/, + 0/*WarpDispatcher::call*/, + 0/*WarpDispatcher::call*/, + 0/*WarpDispatcher::call*/, + 0/*WarpDispatcher::call*/, + } + }; +#else + static const func_t funcs[3][5] = + { + { + WarpDispatcher::call, + WarpDispatcher::call, + WarpDispatcher::call, + WarpDispatcher::call, + WarpDispatcher::call, + }, + { + WarpDispatcher::call, + WarpDispatcher::call, + WarpDispatcher::call, + WarpDispatcher::call, + WarpDispatcher::call, }, { WarpDispatcher::call, WarpDispatcher::call, WarpDispatcher::call, WarpDispatcher::call, - WarpDispatcher::call + WarpDispatcher::call, } }; +#endif - funcs[interpolation][borderMode](static_cast< PtrStepSz >(src), static_cast< PtrStepSz >(srcWhole), xoff, yoff, + const func_t func = funcs[interpolation][borderMode]; + if (!func) + cv::gpu::error("Unsupported input parameters for warp_caller", __FILE__, __LINE__, ""); + + func(static_cast< PtrStepSz >(src), static_cast< PtrStepSz >(srcWhole), xoff, yoff, static_cast< PtrStepSz >(dst), borderValue, stream, cc20); } @@ -320,6 +351,7 @@ namespace cv { namespace gpu { namespace device template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); +#ifndef OPENCV_TINY_GPU_MODULE //template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); @@ -339,6 +371,7 @@ namespace cv { namespace gpu { namespace device //template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); +#endif template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpAffine_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); @@ -358,6 +391,7 @@ namespace cv { namespace gpu { namespace device template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); +#ifndef OPENCV_TINY_GPU_MODULE //template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); @@ -377,6 +411,7 @@ namespace cv { namespace gpu { namespace device //template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); +#endif template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); //template void warpPerspective_gpu(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[3 * 3], PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); diff --git a/modules/gpu/src/warp.cpp b/modules/gpu/src/warp.cpp index 827d5219f1..c963235b72 100644 --- a/modules/gpu/src/warp.cpp +++ b/modules/gpu/src/warp.cpp @@ -277,6 +277,17 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz typedef void (*func_t)(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], 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] = + { + {warpAffine_gpu , 0 /*warpAffine_gpu*/ , warpAffine_gpu , warpAffine_gpu }, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {warpAffine_gpu , 0 /*warpAffine_gpu*/ , warpAffine_gpu , warpAffine_gpu } + }; +#else static const func_t funcs[6][4] = { {warpAffine_gpu , 0 /*warpAffine_gpu*/ , warpAffine_gpu , warpAffine_gpu }, @@ -286,6 +297,7 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz {0 /*warpAffine_gpu*/ , 0 /*warpAffine_gpu*/ , 0 /*warpAffine_gpu*/ , 0 /*warpAffine_gpu*/ }, {warpAffine_gpu , 0 /*warpAffine_gpu*/ , warpAffine_gpu , warpAffine_gpu } }; +#endif const func_t func = funcs[src.depth()][src.channels() - 1]; CV_Assert(func != 0); @@ -415,6 +427,17 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size typedef void (*func_t)(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, float coeffs[2 * 3], 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] = + { + {warpPerspective_gpu , 0 /*warpPerspective_gpu*/ , warpPerspective_gpu , warpPerspective_gpu }, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {warpPerspective_gpu , 0 /*warpPerspective_gpu*/ , warpPerspective_gpu , warpPerspective_gpu } + }; +#else static const func_t funcs[6][4] = { {warpPerspective_gpu , 0 /*warpPerspective_gpu*/ , warpPerspective_gpu , warpPerspective_gpu }, @@ -424,6 +447,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size {0 /*warpPerspective_gpu*/ , 0 /*warpPerspective_gpu*/ , 0 /*warpPerspective_gpu*/ , 0 /*warpPerspective_gpu*/ }, {warpPerspective_gpu , 0 /*warpPerspective_gpu*/ , warpPerspective_gpu , warpPerspective_gpu } }; +#endif const func_t func = funcs[src.depth()][src.channels() - 1]; CV_Assert(func != 0);