From 2a7a44a23553681d83c117c529a043ca1938ae1d Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Sat, 28 Sep 2019 10:19:15 +0300 Subject: [PATCH] Add cost ratio --- applications/reconstruct/src/ilw/ilw.cu | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/applications/reconstruct/src/ilw/ilw.cu b/applications/reconstruct/src/ilw/ilw.cu index c8fceaca5..65fa54763 100644 --- a/applications/reconstruct/src/ilw/ilw.cu +++ b/applications/reconstruct/src/ilw/ilw.cu @@ -64,16 +64,19 @@ __global__ void correspondence_energy_vector_kernel( const uchar4 colour2 = c2.tex2D(screen2.x+u, screen2.y+v); if (world2.x == MINF) continue; - ++count; - // Determine degree of correspondence - float cost = 1.0f - ftl::cuda::spatialWeighting(world1, world2, 0.04f); - cost *= 1.0f - ftl::cuda::colourWeighting(colour1, colour2, 50.0f); + float cost = 1.0f - ftl::cuda::spatialWeighting(world1, world2, 0.04f); + // Point is too far away to even count + if (cost == 1.0f) continue; + + // Mix ratio of colour and distance costs + cost = 0.75f * (1.0f - ftl::cuda::colourWeighting(colour1, colour2, 50.0f)) + 0.25 * cost; //cost /= 2.0f; + ++count; + avgcost += cost; if (cost < bestcost) { bestpoint = world2; - avgcost += cost; bestcost = cost; } } @@ -91,9 +94,11 @@ __global__ void correspondence_energy_vector_kernel( (bestpoint.z - world1.z), mincost); - //eout(x,y) = max(eout(x,y), length(bestpoint-world1) * 10.0f); + //eout(x,y) = max(eout(x,y), (length(bestpoint-world1) / 0.04f) * 7.0f); //eout(x,y) = max(eout(x,y), (1.0f - mincost) * 7.0f); - eout(x,y) = max(eout(x, y), confidence * 7.0f); + //eout(x,y) = max(eout(x, y), (1.0f - mincost) * confidence * (length(bestpoint-world1) / 0.04f) * 12.0f); + //eout(x,y) = max(eout(x, y), (1.0f - mincost) * confidence * 12.0f); + eout(x,y) = max(eout(x, y), confidence * 12.0f); } else if (mincost >= 1.0f && lane == 0) { //vout(x,y) = make_float4(0.0f); //eout(x,y) = 0.0f; -- GitLab