From 2a385be0effa979804584558d8c4a5be01d4cac4 Mon Sep 17 00:00:00 2001 From: Anatoly Baksheev Date: Tue, 10 Aug 2010 12:18:47 +0000 Subject: [PATCH] meanShiftFilteringGPU: performance and bug with type conversions --- modules/gpu/include/opencv2/gpu/gpu.hpp | 2 +- modules/gpu/src/cuda/imgproc.cu | 14 +++++++------- modules/gpu/src/imgproc_gpu.cpp | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp index f389f8fd50..23a2b3dc47 100644 --- a/modules/gpu/include/opencv2/gpu/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu/gpu.hpp @@ -333,7 +333,7 @@ namespace cv CV_EXPORTS void remap(const GpuMat& src, const GpuMat& xmap, const GpuMat& ymap, GpuMat& dst); - CV_EXPORTS void meanShiftFiltering_GPU(const GpuMat& src, GpuMat& dst, float sp, float sr, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1)); + CV_EXPORTS void meanShiftFiltering_GPU(const GpuMat& src, GpuMat& dst, int sp, int sr, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1)); //////////////////////////////// StereoBM_GPU //////////////////////////////// diff --git a/modules/gpu/src/cuda/imgproc.cu b/modules/gpu/src/cuda/imgproc.cu index a3ec30208c..3ce7f32fca 100644 --- a/modules/gpu/src/cuda/imgproc.cu +++ b/modules/gpu/src/cuda/imgproc.cu @@ -138,12 +138,12 @@ namespace imgproc if( count == 0 ) break; - icount = 1./count; - int x1 = floor(sx*icount); - int y1 = floor(sy*icount); - s0 = floor(s0*icount); - s1 = floor(s1*icount); - s2 = floor(s2*icount); + icount = 1.f/count; + int x1 = __float2int_rz(sx*icount); + int y1 = __float2int_rz(sy*icount); + s0 = __float2int_rz(s0*icount); + s1 = __float2int_rz(s1*icount); + s2 = __float2int_rz(s2*icount); int norm2 = (s0 - c.x) * (s0 - c.x) + (s1 - c.y) * (s1 - c.y) + (s2 - c.z) * (s2 - c.z); @@ -166,7 +166,7 @@ namespace imgproc namespace cv { namespace gpu { namespace impl { - extern "C" void meanShiftFiltering_gpu(const DevMem2D& src, DevMem2D dst, float sp, float sr, int maxIter, float eps) + extern "C" void meanShiftFiltering_gpu(const DevMem2D& src, DevMem2D dst, int sp, int sr, int maxIter, float eps) { dim3 grid(1, 1, 1); dim3 threads(32, 16, 1); diff --git a/modules/gpu/src/imgproc_gpu.cpp b/modules/gpu/src/imgproc_gpu.cpp index d89947b3cc..2166ad012d 100644 --- a/modules/gpu/src/imgproc_gpu.cpp +++ b/modules/gpu/src/imgproc_gpu.cpp @@ -48,7 +48,7 @@ using namespace cv::gpu; #if !defined (HAVE_CUDA) void cv::gpu::remap(const GpuMat& /*src*/, const GpuMat& /*xmap*/, const GpuMat& /*ymap*/, GpuMat& /*dst*/) { throw_nogpu(); } -void cv::gpu::meanShiftFiltering_GPU(const GpuMat&, GpuMat&, float, float, TermCriteria ) { throw_nogpu(); } +void cv::gpu::meanShiftFiltering_GPU(const GpuMat&, GpuMat&, int, int, TermCriteria ) { throw_nogpu(); } #else /* !defined (HAVE_CUDA) */ @@ -58,7 +58,7 @@ namespace cv { namespace gpu { extern "C" void remap_gpu(const DevMem2D& src, const DevMem2D_& xmap, const DevMem2D_& ymap, DevMem2D dst); - extern "C" void meanShiftFiltering_gpu(const DevMem2D& src, DevMem2D dst, float sp, float sr, int maxIter, float eps); + extern "C" void meanShiftFiltering_gpu(const DevMem2D& src, DevMem2D dst, int sp, int sr, int maxIter, float eps); } }} @@ -75,7 +75,7 @@ void cv::gpu::remap(const GpuMat& src, const GpuMat& xmap, const GpuMat& ymap, G -void cv::gpu::meanShiftFiltering_GPU(const GpuMat& src, GpuMat& dst, float sp, float sr, TermCriteria criteria) +void cv::gpu::meanShiftFiltering_GPU(const GpuMat& src, GpuMat& dst, int sp, int sr, TermCriteria criteria) { if( src.empty() ) CV_Error( CV_StsBadArg, "The input image is empty" );