From 2a2590bae2f70022bfbdef931bc65a839e9abc48 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Fri, 3 Dec 2010 10:14:01 +0000 Subject: [PATCH] replaced filter (from the nearest to linear) mode when resizing image in gpu::HOGDescriptor --- modules/gpu/src/cuda/hog.cu | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/gpu/src/cuda/hog.cu b/modules/gpu/src/cuda/hog.cu index 8c8144e..d79e076 100644 --- a/modules/gpu/src/cuda/hog.cu +++ b/modules/gpu/src/cuda/hog.cu @@ -696,8 +696,8 @@ void compute_gradients_8UC1(int nbins, int height, int width, const DevMem2D& im //------------------------------------------------------------------- // Resize -texture resize8UC4_tex; -texture resize8UC1_tex; +texture resize8UC4_tex; +texture resize8UC1_tex; extern "C" __global__ void resize_8UC4_kernel(float sx, float sy, DevMem2D dst) @@ -706,7 +706,10 @@ extern "C" __global__ void resize_8UC4_kernel(float sx, float sy, DevMem2D dst) unsigned int y = blockIdx.y * blockDim.y + threadIdx.y; if (x < dst.cols && y < dst.rows) - ((uchar4*)dst.ptr(y))[x] = tex2D(resize8UC4_tex, x * sx, y * sy); + { + float4 val = tex2D(resize8UC4_tex, x * sx, y * sy); + ((uchar4*)dst.ptr(y))[x] = make_uchar4(val.x * 255, val.y * 255, val.z * 255, val.w * 255); + } } @@ -714,6 +717,7 @@ void resize_8UC4(const DevMem2D& src, DevMem2D dst) { cudaChannelFormatDesc desc = cudaCreateChannelDesc(); cudaBindTexture2D(0, resize8UC4_tex, src.data, desc, src.cols, src.rows, src.step); + resize8UC4_tex.filterMode = cudaFilterModeLinear; dim3 threads(32, 8); dim3 grid(div_up(dst.cols, threads.x), div_up(dst.rows, threads.y)); @@ -732,7 +736,7 @@ extern "C" __global__ void resize_8UC1_kernel(float sx, float sy, DevMem2D dst) unsigned int y = blockIdx.y * blockDim.y + threadIdx.y; if (x < dst.cols && y < dst.rows) - ((unsigned char*)dst.ptr(y))[x] = tex2D(resize8UC1_tex, x * sx, y * sy); + ((unsigned char*)dst.ptr(y))[x] = tex2D(resize8UC1_tex, x * sx, y * sy) * 255; } @@ -740,6 +744,7 @@ void resize_8UC1(const DevMem2D& src, DevMem2D dst) { cudaChannelFormatDesc desc = cudaCreateChannelDesc(); cudaBindTexture2D(0, resize8UC1_tex, src.data, desc, src.cols, src.rows, src.step); + resize8UC1_tex.filterMode = cudaFilterModeLinear; dim3 threads(32, 8); dim3 grid(div_up(dst.cols, threads.x), div_up(dst.rows, threads.y)); -- 2.7.4