From c0d3adef256bbdfe3685b172635db6e3ccbf8ca3 Mon Sep 17 00:00:00 2001 From: "marina.kolpakova" Date: Mon, 6 Aug 2012 18:43:25 +0400 Subject: [PATCH] intervales for vector type support --- modules/gpu/src/cuda/ccomponetns.cu | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/modules/gpu/src/cuda/ccomponetns.cu b/modules/gpu/src/cuda/ccomponetns.cu index 9b8d4c9..3a54c49 100644 --- a/modules/gpu/src/cuda/ccomponetns.cu +++ b/modules/gpu/src/cuda/ccomponetns.cu @@ -39,7 +39,9 @@ // the use of this software, even if advised of the possibility of such damage. //M*/ -#include "opencv2/gpu/device/common.hpp" +#include +#include +#include #include #include @@ -84,7 +86,7 @@ namespace cv { namespace gpu { namespace device template<> struct IntervalsTraits { - typedef int3 dist_type; + typedef int4 dist_type; enum {ch = 4}; }; @@ -130,30 +132,39 @@ namespace cv { namespace gpu { namespace device template __device__ __forceinline__ bool operator() (const I& a, const I& b) const { - T d = a - b; + I d = a - b; return lo <= d && d <= hi; } }; template struct InInterval { - __host__ __device__ __forceinline__ InInterval(const float4& _lo, const float4& _hi){}; + __host__ __device__ __forceinline__ InInterval(const float4& _lo, const float4& _hi) + : lo (VecTraits::make(-_lo.x, -_lo.y, -_lo.z)), hi (VecTraits::make(_hi.x, _hi.y, _hi.z)){}; T lo, hi; template __device__ __forceinline__ bool operator() (const I& a, const I& b) const { - return true; + I d = a - b; + return lo.x <= d.x && d.x <= hi.x && + lo.y <= d.y && d.y <= hi.y && + lo.z <= d.z && d.z <= hi.z; } }; template struct InInterval { - __host__ __device__ __forceinline__ InInterval(const float4& _lo, const float4& _hi){}; + __host__ __device__ __forceinline__ InInterval(const float4& _lo, const float4& _hi) + : lo (VecTraits::make(-_lo.x, -_lo.y, -_lo.z, -_lo.w)), hi (VecTraits::make(_hi.x, _hi.y, _hi.z, -_hi.w)){}; T lo, hi; template __device__ __forceinline__ bool operator() (const I& a, const I& b) const { - return true; + I d = a - b; + return lo.x <= d.x && d.x <= hi.x && + lo.y <= d.y && d.y <= hi.y && + lo.z <= d.z && d.z <= hi.z && + lo.w <= d.w && d.w <= hi.w; } }; @@ -275,16 +286,16 @@ namespace cv { namespace gpu { namespace device int label = new_labels[i][j]; if (c & UP) - label = min(label, labelsTile[yloc - 1][xloc]); + label = ::min(label, labelsTile[yloc - 1][xloc]); if (c & DOWN) - label = min(label, labelsTile[yloc + 1][xloc]); + label = ::min(label, labelsTile[yloc + 1][xloc]); if (c & LEFT) - label = min(label, labelsTile[yloc][xloc - 1]); + label = ::min(label, labelsTile[yloc][xloc - 1]); if (c & RIGHT) - label = min(label, labelsTile[yloc][xloc + 1]); + label = ::min(label, labelsTile[yloc][xloc + 1]); new_labels[i][j] = label; } @@ -366,8 +377,8 @@ namespace cv { namespace gpu { namespace device if (r1 == r2) return; - int mi = min(r1, r2); - int ma = max(r1, r2); + int mi = ::min(r1, r2); + int ma = ::max(r1, r2); int y = ma / comps.cols; int x = ma - y * comps.cols; -- 2.7.4