From ce2a30dd1f14f0a449101e884d1d358484c095a6 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Thu, 19 Sep 2019 16:36:57 +0300 Subject: [PATCH] Clear the energy vectors --- applications/reconstruct/src/ilw.cpp | 5 +++++ applications/reconstruct/src/ilw.cu | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/applications/reconstruct/src/ilw.cpp b/applications/reconstruct/src/ilw.cpp index 86a4cca5e..c1bf8499a 100644 --- a/applications/reconstruct/src/ilw.cpp +++ b/applications/reconstruct/src/ilw.cpp @@ -66,6 +66,11 @@ bool ILW::_phase0(ftl::rgbd::FrameSet &fs, cudaStream_t stream) { f.createTexture<float4>(Channel::EnergyVector, Format<float4>(f.get<GpuMat>(Channel::Colour).size())); f.createTexture<float>(Channel::Energy, Format<float>(f.get<GpuMat>(Channel::Colour).size())); f.createTexture<uchar4>(Channel::Colour); + + cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream); + + f.get<GpuMat>(Channel::EnergyVector).setTo(cv::Scalar(0.0f,0.0f,0.0f,0.0f), cvstream); + f.get<GpuMat>(Channel::Energy).setTo(cv::Scalar(0.0f), cvstream); } return true; diff --git a/applications/reconstruct/src/ilw.cu b/applications/reconstruct/src/ilw.cu index 90133a3a5..b97c49964 100644 --- a/applications/reconstruct/src/ilw.cu +++ b/applications/reconstruct/src/ilw.cu @@ -30,9 +30,10 @@ __global__ void correspondence_energy_vector_kernel( const int x = (blockIdx.x*blockDim.x + threadIdx.x) / WARP_SIZE; const int y = blockIdx.y*blockDim.y + threadIdx.y; - const float3 world1 = make_float3(p1.tex2D(x, y)); + const float3 world1 = make_float3(p1.tex2D(x, y)); + if (world1.x == MINF) return; const float3 camPos2 = pose2 * world1; - const uint2 screen2 = cam2.camToScreen<uint2>(camPos2); + const uint2 screen2 = cam2.camToScreen<uint2>(camPos2); const int upsample = 8; @@ -43,12 +44,11 @@ __global__ void correspondence_energy_vector_kernel( const float u = (i % upsample) - (upsample / 2); const float v = (i / upsample) - (upsample / 2); - const float3 world2 = make_float3(p2.tex2D(screen2.x+u, screen2.y+v)); + const float3 world2 = make_float3(p2.tex2D(screen2.x+u, screen2.y+v)); + if (world2.x == MINF) continue; // Determine degree of correspondence const float confidence = 1.0f / length(world1 - world2); - - printf("conf %f\n", confidence); const float maxconf = warpMax(confidence); // This thread has best confidence value -- GitLab