From c26b00537187df450884e7970364da3e8d9a781d Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Mon, 5 Sep 2011 07:51:00 +0000 Subject: [PATCH] optimized gpu::remap (use texture memory if possible), added stream support to gpu::remap --- modules/gpu/include/opencv2/gpu/gpu.hpp | 3 +- modules/gpu/src/cuda/imgproc.cu | 212 +++++++++++++++--------- modules/gpu/src/imgproc.cpp | 13 +- 3 files changed, 146 insertions(+), 82 deletions(-) diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp index e3c7efee2f..a5243a4ff6 100644 --- a/modules/gpu/include/opencv2/gpu/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu/gpu.hpp @@ -599,7 +599,8 @@ namespace cv //! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation. //! supports CV_32FC1 map type CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, - int interpolation, int borderMode = BORDER_CONSTANT, const Scalar& borderValue = Scalar()); + int interpolation, int borderMode = BORDER_CONSTANT, const Scalar& borderValue = Scalar(), + Stream& stream = Stream::Null()); //! Does mean shift filtering on GPU. CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr, diff --git a/modules/gpu/src/cuda/imgproc.cu b/modules/gpu/src/cuda/imgproc.cu index 40f0d9937c..032cffb44f 100644 --- a/modules/gpu/src/cuda/imgproc.cu +++ b/modules/gpu/src/cuda/imgproc.cu @@ -53,23 +53,6 @@ using namespace cv::gpu::device; /////////////////////////////////// Remap /////////////////////////////////////////////// namespace cv { namespace gpu { namespace imgproc { - // cudaAddressModeClamp == BrdReplicate - /*texture tex_remap_uchar_LinearFilter(0, cudaFilterModeLinear, cudaAddressModeClamp); - - __global__ void remap_uchar_LinearFilter(const PtrStepf mapx, const PtrStepf mapy, DevMem2D dst) - { - const int x = blockDim.x * blockIdx.x + threadIdx.x; - const int y = blockDim.y * blockIdx.y + threadIdx.y; - - if (x < dst.cols && y < dst.rows) - { - const float xcoo = mapx.ptr(y)[x]; - const float ycoo = mapy.ptr(y)[x]; - - dst.ptr(y)[x] = 255.0f * tex2D(tex_remap_uchar_LinearFilter, xcoo, ycoo); - } - }*/ - template __global__ void remap(const Ptr2D src, const PtrStepf mapx, const PtrStepf mapy, DevMem2D_ dst) { const int x = blockDim.x * blockIdx.x + threadIdx.x; @@ -83,88 +66,164 @@ namespace cv { namespace gpu { namespace imgproc dst.ptr(y)[x] = saturate_cast(src(ycoo, xcoo)); } } - - template