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

Work arbitrary neighbours

parent c86b420d
No related branches found
No related tags found
1 merge request!88Implements #146 upsampling option
...@@ -345,7 +345,7 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp ...@@ -345,7 +345,7 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp
} }
} }
#define NEIGHBOR_RADIUS_2 5 #define NEIGHBOR_RADIUS_2 10
#define NEIGHBOR_WINDOW ((NEIGHBOR_RADIUS_2*2+1)*(NEIGHBOR_RADIUS_2*2+1)) #define NEIGHBOR_WINDOW ((NEIGHBOR_RADIUS_2*2+1)*(NEIGHBOR_RADIUS_2*2+1))
#define MAX_NEIGHBORS_2 20 #define MAX_NEIGHBORS_2 20
...@@ -361,7 +361,7 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp ...@@ -361,7 +361,7 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp
__shared__ float3 neighborhood_cache[2*T_PER_BLOCK][MAX_NEIGHBORS_2]; __shared__ float3 neighborhood_cache[2*T_PER_BLOCK][MAX_NEIGHBORS_2];
__shared__ int minimum[2*T_PER_BLOCK]; __shared__ int minimum[2*T_PER_BLOCK];
__shared__ int maximum[2*T_PER_BLOCK]; __shared__ int maximum[2*T_PER_BLOCK];
__shared__ int nidx[2*T_PER_BLOCK]; __shared__ unsigned int nidx[2*T_PER_BLOCK];
const int warp = threadIdx.x / WARP_SIZE + threadIdx.y*2; const int warp = threadIdx.x / WARP_SIZE + threadIdx.y*2;
const int x = (blockIdx.x*blockDim.x + threadIdx.x) / WARP_SIZE; const int x = (blockIdx.x*blockDim.x + threadIdx.x) / WARP_SIZE;
...@@ -405,8 +405,8 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp ...@@ -405,8 +405,8 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp
const int v = (i / (2*NEIGHBOR_RADIUS_2+1)) - NEIGHBOR_RADIUS_2; const int v = (i / (2*NEIGHBOR_RADIUS_2+1)) - NEIGHBOR_RADIUS_2;
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 (length(point - camPos) <= 0.04f) { if (length(point - camPos) <= SPATIAL_SMOOTHING) {
int idx = atomicInc(&nidx[warp], MAX_NEIGHBORS_2-1); unsigned int idx = atomicInc(&nidx[warp], MAX_NEIGHBORS_2-1);
neighborhood_cache[warp][idx] = point; neighborhood_cache[warp][idx] = point;
atomicMin(&minimum[warp], point.z*1000.0f); atomicMin(&minimum[warp], point.z*1000.0f);
atomicMax(&maximum[warp], point.z*1000.0f); atomicMax(&maximum[warp], point.z*1000.0f);
...@@ -451,7 +451,7 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp ...@@ -451,7 +451,7 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp
// TODO:(Nick) Should perhaps use points from all cameras? // TODO:(Nick) Should perhaps use points from all cameras?
// Instead of doing each camera separately... // Instead of doing each camera separately...
// If the depth already is close then it has already been done and can skip this point // If the depth already is close then it has already been done and can skip this point
const float energy = ftl::cuda::mls_point_energy<MAX_NEIGHBORS_2>(neighborhood_cache[warp], nearest, SPATIAL_SMOOTHING); const float energy = ftl::cuda::mls_point_energy<MAX_NEIGHBORS_2>(neighborhood_cache[warp], nearest, nidx[warp], SPATIAL_SMOOTHING);
if (energy <= 0.0f) break; if (energy <= 0.0f) break;
......
...@@ -275,6 +275,28 @@ __device__ float mls_point_energy( ...@@ -275,6 +275,28 @@ __device__ float mls_point_energy(
return weights; return weights;
} }
/**
* Calculate the point sample energy.
*/
template <int M>
__device__ float mls_point_energy(
const float3 (&pointset)[M],
const float3 &nearPoint,
unsigned int N,
float smoothing) {
float weights = 0.0f;
//#pragma unroll
for (int i=0; i<N; ++i) {
const float3 samplePoint = pointset[i];
const float weight = ftl::cuda::spatialWeighting(length(nearPoint - samplePoint), smoothing);
weights += weight;
}
return weights;
}
/** /**
* Estimate a point set surface location near an existing and return also * Estimate a point set surface location near an existing and return also
* an estimate of the normal and colour of that point. * an estimate of the normal and colour of that point.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment