Skip to content
Snippets Groups Projects
Commit d5a7d1d9 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

WIP Dynamic smoothing

parent a7113d09
No related branches found
No related tags found
1 merge request!90Implement #150 splat resizing
...@@ -400,6 +400,8 @@ __device__ inline float warpMin(float e) { ...@@ -400,6 +400,8 @@ __device__ inline float warpMin(float e) {
} }
#define ENERGY_THRESHOLD 0.1f #define ENERGY_THRESHOLD 0.1f
#define SMOOTHING_MULTIPLIER_A 10.0f
#define SMOOTHING_MULTIPLIER_B 5.0f
/* /*
...@@ -449,7 +451,7 @@ __device__ inline float warpMin(float e) { ...@@ -449,7 +451,7 @@ __device__ inline float warpMin(float e) {
// 1) Depth from original source // 1) Depth from original source
// 2) Colour contrast in underlying RGB // 2) Colour contrast in underlying RGB
// 3) Estimated noise levels in depth values // 3) Estimated noise levels in depth values
if (point.z > clusterBase && point.z < params.camera.m_sensorDepthWorldMax && length(point - camPos) <= 0.04f) { if (point.z > clusterBase && point.z < params.camera.m_sensorDepthWorldMax && length(point - camPos) <= SMOOTHING_MULTIPLIER_A*(point.z / params.camera.fx)) {
atomicMin(&minimum[warp], point.z*1000.0f); atomicMin(&minimum[warp], point.z*1000.0f);
} }
} }
...@@ -471,7 +473,7 @@ __device__ inline float warpMin(float e) { ...@@ -471,7 +473,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); 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 it is close enough...
if (point.z > params.camera.m_sensorDepthWorldMin && point.z < params.camera.m_sensorDepthWorldMax && length(point - minPos) <= 0.04f) { if (point.z > params.camera.m_sensorDepthWorldMin && point.z < params.camera.m_sensorDepthWorldMax && length(point - minPos) <= SMOOTHING_MULTIPLIER_A*(point.z / params.camera.fx)) {
// Append to neighbour list // Append to neighbour list
//unsigned int idx = atomicInc(&nidx[warp], MAX_NEIGHBORS_2-1); //unsigned int idx = atomicInc(&nidx[warp], MAX_NEIGHBORS_2-1);
unsigned int idx = atomicAdd(&nidx[warp], 1); unsigned int idx = atomicAdd(&nidx[warp], 1);
...@@ -511,7 +513,7 @@ __device__ inline float warpMin(float e) { ...@@ -511,7 +513,7 @@ __device__ inline float warpMin(float e) {
// Search for best or threshold energy // Search for best or threshold energy
for (int k=lane; k<MAX_ITERATIONS; k+=WARP_SIZE) { for (int k=lane; k<MAX_ITERATIONS; k+=WARP_SIZE) {
const float3 nearest = params.camera.kinectDepthToSkeleton(x,y,minDepth+float(k)*interval); 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, min(nidx[warp], MAX_NEIGHBORS_2), SPATIAL_SMOOTHING); const float myenergy = ftl::cuda::mls_point_energy<MAX_NEIGHBORS_2>(neighborhood_cache[warp], nearest, min(nidx[warp], MAX_NEIGHBORS_2), SMOOTHING_MULTIPLIER_B*(nearest.z/params.camera.fx));
const float newenergy = warpMax(max(myenergy, maxenergy)); const float newenergy = warpMax(max(myenergy, maxenergy));
bestdepth = (myenergy == newenergy) ? nearest.z : (newenergy > maxenergy) ? 0.0f : bestdepth; bestdepth = (myenergy == newenergy) ? nearest.z : (newenergy > maxenergy) ? 0.0f : bestdepth;
maxenergy = newenergy; maxenergy = newenergy;
...@@ -548,7 +550,7 @@ __device__ inline float warpMin(float e) { ...@@ -548,7 +550,7 @@ __device__ inline float warpMin(float e) {
if (maxenergy >= ENERGY_THRESHOLD) return; if (maxenergy >= ENERGY_THRESHOLD) return;
// Move to next possible surface... // Move to next possible surface...
clusterBase = minDepth + 0.04f; clusterBase = minDepth + 0.01f;
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment