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

Hack faster colour distance

parent cd9eb9b5
No related branches found
No related tags found
1 merge request!71Implements #130 for optional MLS merging
Pipeline #12349 passed
...@@ -38,14 +38,19 @@ extern __device__ float spatialWeighting(float r); ...@@ -38,14 +38,19 @@ extern __device__ float spatialWeighting(float r);
* Real-time foreground-background segmentation using codebook model. * Real-time foreground-background segmentation using codebook model.
* Real-Time Imaging. https://doi.org/10.1016/j.rti.2004.12.004 * Real-Time Imaging. https://doi.org/10.1016/j.rti.2004.12.004
*/ */
__device__ float colordiffFloat(const uchar4 &pa, const uchar4 &pb) { __device__ inline float colordiffFloat(const uchar4 &pa, const uchar4 &pb) {
float x_2 = pb.x * pb.x + pb.y * pb.y + pb.z * pb.z; const float x_2 = pb.x * pb.x + pb.y * pb.y + pb.z * pb.z;
float v_2 = pa.x * pa.x + pa.y * pa.y + pa.z * pa.z; const float v_2 = pa.x * pa.x + pa.y * pa.y + pa.z * pa.z;
float xv_2 = pow(pb.x * pa.x + pb.y * pa.y + pb.z * pa.z, 2); const float xv_2 = pow(pb.x * pa.x + pb.y * pa.y + pb.z * pa.z, 2);
float p_2 = xv_2 / v_2; const float p_2 = xv_2 / v_2;
return sqrt(x_2 - p_2); return sqrt(x_2 - p_2);
} }
__device__ float colordiffFloat2(const uchar4 &pa, const uchar4 &pb) {
float3 delta = make_float3((float)pa.x - (float)pb.x, (float)pa.y - (float)pb.y, (float)pa.z - (float)pb.z);
return length(delta);
}
/* /*
* Colour weighting as suggested in: * Colour weighting as suggested in:
* C. Kuster et al. Spatio-Temporal Geometry Fusion for Multiple Hybrid Cameras using Moving Least Squares Surfaces. 2014. * C. Kuster et al. Spatio-Temporal Geometry Fusion for Multiple Hybrid Cameras using Moving Least Squares Surfaces. 2014.
...@@ -98,7 +103,7 @@ __global__ void mls_smooth_kernel(ftl::cuda::TextureObject<float> output, HashDa ...@@ -98,7 +103,7 @@ __global__ void mls_smooth_kernel(ftl::cuda::TextureObject<float> output, HashDa
uchar4 c2 = tex2D<uchar4>(camera.colour, screenPos.x+u, screenPos.y+v); uchar4 c2 = tex2D<uchar4>(camera.colour, screenPos.x+u, screenPos.y+v);
//float4 normal = tex2D<float4>(camera.normal, screenPos.x+u, screenPos.y+v); //float4 normal = tex2D<float4>(camera.normal, screenPos.x+u, screenPos.y+v);
const float3 worldPos = camera.pose * camera.params.kinectDepthToSkeleton(screenPos.x+u, screenPos.y+v, depth); const float3 worldPos = camera.pose * camera.params.kinectDepthToSkeleton(screenPos.x+u, screenPos.y+v, depth);
const float weight = spatialWeighting(length(mPos - worldPos))*colourWeighting(colordiffFloat(c1,c2)); const float weight = spatialWeighting(length(mPos - worldPos))*colourWeighting(colordiffFloat2(c1,c2));
wpos += weight*worldPos; wpos += weight*worldPos;
//wnorm += weight*make_float3(normal); //wnorm += weight*make_float3(normal);
......
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