Skip to content
Snippets Groups Projects

Ongoing #133 improvements

Merged Nicolas Pope requested to merge feature/133/ilw into master
3 files
+ 41
20
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -8,10 +8,10 @@ using ftl::rgbd::Camera;
#define T_PER_BLOCK 8
#define FULL_MASK 0xffffffff
__device__ inline float warpMax(float e) {
__device__ inline float warpMin(float e) {
for (int i = WARP_SIZE/2; i > 0; i /= 2) {
const float other = __shfl_xor_sync(FULL_MASK, e, i, WARP_SIZE);
e = max(e, other);
e = min(e, other);
}
return e;
}
@@ -39,8 +39,8 @@ __global__ void correspondence_energy_vector_kernel(
const float3 camPos2 = pose2 * world1;
const uint2 screen2 = cam2.camToScreen<uint2>(camPos2);
float bestconf = 0.0f;
float nextbest = 0.0f;
float bestcost = 1.1f;
float nextbest = 1.0f;
float3 bestpoint;
// Project to p2 using cam2
@@ -54,29 +54,28 @@ __global__ void correspondence_energy_vector_kernel(
if (world2.x == MINF) continue;
// Determine degree of correspondence
const float l = length(world1 - world2);
const float confidence = ftl::cuda::spatialWeighting(l, 0.04f);
const float cost = 1.0f - ftl::cuda::spatialWeighting(world1, world2, 0.04f);
if (confidence > bestconf) {
if (cost < bestcost) {
bestpoint = world2;
nextbest = bestconf;
bestconf = confidence;
nextbest = bestcost;
bestcost = cost;
}
}
const float maxconf = warpMax(bestconf);
bool best = maxconf == bestconf;
bestconf = (best) ? 0.0f : bestconf;
const float conf = maxconf - warpMax(bestconf);
const float mincost = warpMin(bestcost);
bool best = mincost == bestcost;
bestcost = (best) ? nextbest : bestcost;
const float confidence = mincost / warpMin(bestcost);
if (best && maxconf > 0.0f) {
if (best && mincost < 1.0f) {
vout(x,y) = vout.tex2D(x, y) + make_float4(
(bestpoint.x - world1.x),
(bestpoint.y - world1.y),
(bestpoint.z - world1.z),
maxconf);
eout(x,y) = conf * 5.0f; //maxconf * 5.0f; //(maxconf - warpMax(nextbest));
} else if (maxconf == 0.0f && lane == 0) {
mincost);
eout(x,y) = mincost * 5.0f; //confidence * 5.0f;
} else if (mincost >= 1.0f && lane == 0) {
vout(x,y) = make_float4(0.0f);
eout(x,y) = 0.0f;
}
Loading