40 #include <pcl/io/openni_camera/openni_image.h>
41 #include <thrust/tuple.h>
42 #include <pcl/pcl_exports.h>
51 DisparityBoundSmoothing (
int width,
int height,
int window_size,
float focal_length,
float baseline,
float disparity_threshold,
float *data,
float *raw_data)
66 inline __host__ __device__
73 inline __host__ __device__
80 inline __host__ __device__
88 if (avg_disparity > max_disparity)
90 if (avg_disparity < min_disparity)
97 inline __host__ __device__
100 float depth =
data_ [idx];
102 if (depth == 0 | isnan(depth) | isinf(depth))
105 if (depth == 0 | std::isnan(depth) | std::isinf(depth))
112 int4 bounds = make_int4 (
120 bounds.x = clamp (bounds.x, 0,
width_-1);
121 bounds.y = clamp (bounds.y, 0,
width_-1);
122 bounds.z = clamp (bounds.z, 0,
height_-1);
123 bounds.w = clamp (bounds.w, 0,
height_-1);
125 float average_depth = depth;
128 for (
int y = bounds.z; y <= bounds.w; ++y)
130 for (
int x = bounds.x; x <= bounds.y; ++x)
133 int otherIdx = ((int)y) *
width_ + ((int)x);
134 float otherDepth =
data_[otherIdx];
139 if (std::abs(otherDepth - depth) > 200)
143 average_depth += otherDepth;
165 template <
typename Tuple>
166 inline __host__ __device__
169 float depth = thrust::get<0> (t);
170 int idx = thrust::get<1> (t);
172 int nr = (int) dhel.x;
173 float min_d = dhel.y;
174 float max_d = dhel.z;
176 if (depth == 0 | isnan(depth) | isinf(depth))
179 if (depth == 0 | std::isnan(depth) | std::isinf(depth))
186 int4 bounds = make_int4 (
194 bounds.x = clamp (bounds.x, 0,
width_-1);
195 bounds.y = clamp (bounds.y, 0,
width_-1);
196 bounds.z = clamp (bounds.z, 0,
height_-1);
197 bounds.w = clamp (bounds.w, 0,
height_-1);
200 for (
int y = bounds.z; y <= bounds.w; ++y)
202 for (
int x = bounds.x; x <= bounds.y; ++x)
205 int otherIdx = ((int)y) *
width_ + ((int)x);
206 depth +=
data_[otherIdx];
210 return clamp (depth / nr, min_d, max_d);
216 DisparityHelperMap (
float* data,
int width,
int height,
int window_size,
float baseline,
float focal_length,
float disp_thresh)
229 inline __host__ __device__
236 inline __host__ __device__
242 inline __host__ __device__
247 if (disparity == 0 | isnan(disparity) | isinf(disparity))
248 return make_float3 (0,0,0);
250 if (disparity == 0 | std::isnan(disparity) | std::isinf(disparity))
251 return make_float3 (0,0,0);
257 int4 bounds = make_int4 (
265 bounds.x = clamp (bounds.x, 0,
width_-1);
266 bounds.y = clamp (bounds.y, 0,
width_-1);
267 bounds.z = clamp (bounds.z, 0,
height_-1);
268 bounds.w = clamp (bounds.w, 0,
height_-1);
272 for (
int y = bounds.z; y <= bounds.w; ++y)
274 for (
int x = bounds.x; x <= bounds.y; ++x)
277 int otherIdx = ((int)y) *
width_ + ((int)x);
278 float otherDepth =
data_[otherIdx];
286 return make_float3 ((
float) counter,
float disparity_threshold_
DisparityBoundSmoothing(int width, int height, int window_size, float focal_length, float baseline, float disparity_threshold, float *data, float *raw_data)
__host__ __device__ float disparity2depth(float disparity)
__host__ __device__ float depth2disparity(float depth)
__host__ __device__ float operator()(int idx)
__host__ __device__ float clampToDisparityBounds(float avg_depth, float depth)
float3 * disparity_helper_map_
__host__ __device__ float operator()(Tuple t)
DisparityClampedSmoothing(float *data, float3 *disparity_helper_map, int width, int height, int window_size)
__host__ __device__ float disparity2depth(float disparity)
DisparityHelperMap(float *data, int width, int height, int window_size, float baseline, float focal_length, float disp_thresh)
__host__ __device__ float3 operator()(int idx)
__host__ __device__ float depth2disparity(float depth)