diff --git a/applications/reconstruct/src/dibr.cu b/applications/reconstruct/src/dibr.cu index a91ae7b87fbc17b88d3aa30721107ef7174ac37f..52dd31965059b423f1fec261ae1d9b6fa1d0c130 100644 --- a/applications/reconstruct/src/dibr.cu +++ b/applications/reconstruct/src/dibr.cu @@ -13,7 +13,7 @@ #define WARP_SIZE 32 #define DEPTH_THRESHOLD 0.05f #define UPSAMPLE_MAX 60 -#define MAX_ITERATIONS 32 +#define MAX_ITERATIONS 64 // Note: Must be multiple of 32 #define SPATIAL_SMOOTHING 0.005f using ftl::cuda::TextureObject; @@ -476,15 +476,16 @@ __device__ inline float warpMin(float e) { //if (y == 200) printf("interval: %f\n", maxDepth); - float maxenergy = 0.0f; + float maxenergy = -1.0f; float bestdepth = 0.0f; // Search for best or threshold energy for (int k=lane; k<MAX_ITERATIONS; k+=WARP_SIZE) { const float3 nearest = params.camera.kinectDepthToSkeleton(x,y,minDepth+float(k)*interval); const float myenergy = ftl::cuda::mls_point_energy<MAX_NEIGHBORS_2>(neighborhood_cache[warp], nearest, nidx[warp], SPATIAL_SMOOTHING); - maxenergy = warpMax(max(myenergy, maxenergy)); - bestdepth = (myenergy == maxenergy) ? nearest.z : 0.0f; + const float newenergy = warpMax(max(myenergy, maxenergy)); + bestdepth = (myenergy == newenergy) ? nearest.z : (newenergy > maxenergy) ? 0.0f : bestdepth; + maxenergy = newenergy; } // Search for first energy maximum above a threshold @@ -494,8 +495,8 @@ __device__ inline float warpMin(float e) { const unsigned int cy = y; if (bestdepth > params.camera.m_sensorDepthWorldMin && bestdepth < params.camera.m_sensorDepthWorldMax && cx < depth.width() && cy < depth.height()) { // Transform estimated point to virtual cam space and output z - //atomicMin(&depth(cx,cy), bestdepth * 1000.0f); - depth(cx,cy) = bestdepth * 1000.0f; + atomicMin(&depth(cx,cy), bestdepth * 1000.0f); + //depth(cx,cy) = bestdepth * 1000.0f; } } }