Skip to content
Snippets Groups Projects

Implements #151 alternate minimums

Merged Nicolas Pope requested to merge feature/151/altmin into master
1 file
+ 14
2
Compare changes
  • Side-by-side
  • Inline
@@ -418,6 +418,10 @@ __device__ inline float warpMin(float e) {
const int x = (blockIdx.x*blockDim.x + threadIdx.x) / WARP_SIZE;
const int y = blockIdx.y*blockDim.y + threadIdx.y;
float clusterBase = params.camera.m_sensorDepthWorldMin;
while (clusterBase < params.camera.m_sensorDepthWorldMax) {
const int lane = tid % WARP_SIZE;
if (lane == 0) {
minimum[warp] = 100000000;
@@ -428,6 +432,8 @@ __device__ inline float warpMin(float e) {
__syncwarp();
// Search for a valid minimum neighbour
// TODO: Should this really be minimum or the median of a depth cluster?
// cluster median seems very hard to calculate...
for (int i=lane; i<NEIGHBOR_WINDOW; i+=WARP_SIZE) {
const int u = (i % (2*NEIGHBOR_RADIUS_2+1)) - NEIGHBOR_RADIUS_2;
const int v = (i / (2*NEIGHBOR_RADIUS_2+1)) - NEIGHBOR_RADIUS_2;
@@ -435,7 +441,7 @@ __device__ inline float warpMin(float e) {
const float3 camPos = params.camera.kinectDepthToSkeleton(x, y, point.z);
// If it is close enough...
if (point.z > params.camera.m_sensorDepthWorldMin && point.z < params.camera.m_sensorDepthWorldMax && length(point - camPos) <= 0.02f) {
if (point.z > clusterBase && point.z < params.camera.m_sensorDepthWorldMax && length(point - camPos) <= SPATIAL_SMOOTHING) {
atomicMin(&minimum[warp], point.z*1000.0f);
}
}
@@ -457,7 +463,7 @@ __device__ inline float warpMin(float e) {
const float3 point = params.camera.kinectDepthToSkeleton(x+u, y+v, float(point_in.tex2D(x+u, y+v)) / 1000.0f);
// If it is close enough...
if (point.z > params.camera.m_sensorDepthWorldMin && point.z < params.camera.m_sensorDepthWorldMax && length(point - minPos) <= 0.02f) {
if (point.z > params.camera.m_sensorDepthWorldMin && point.z < params.camera.m_sensorDepthWorldMax && length(point - minPos) <= SPATIAL_SMOOTHING) {
// Append to neighbour list
//unsigned int idx = atomicInc(&nidx[warp], MAX_NEIGHBORS_2-1);
unsigned int idx = atomicAdd(&nidx[warp], 1);
@@ -517,6 +523,12 @@ __device__ inline float warpMin(float e) {
//depth(cx,cy) = bestdepth * 1000.0f;
}
}
if (maxenergy >= 0.1f) return;
clusterBase = minDepth + SPATIAL_SMOOTHING;
};
}
// ===== Pass 2 and 3 : Attribute contributions ================================
Loading