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

Add flags and ignore bad points

parent 1a1b4359
No related branches found
No related tags found
2 merge requests!116Implements #133 point alignment,!114Ongoing #133 improvements
This commit is part of merge request !114. Comments created here will be created in the context of that merge request.
...@@ -19,6 +19,14 @@ ILW::ILW(nlohmann::json &config) : ftl::Configurable(config) { ...@@ -19,6 +19,14 @@ ILW::ILW(nlohmann::json &config) : ftl::Configurable(config) {
on("ilw_align", [this](const ftl::config::Event &e) { on("ilw_align", [this](const ftl::config::Event &e) {
enabled_ = value("ilw_align", true); enabled_ = value("ilw_align", true);
}); });
flags_ = 0;
if (value("ignore_bad", false)) flags_ |= ftl::cuda::kILWFlag_IgnoreBad;
on("ignore_bad", [this](const ftl::config::Event &e) {
if (value("ignore_bad", false)) flags_ |= ftl::cuda::kILWFlag_IgnoreBad;
else flags_ &= ~ftl::cuda::kILWFlag_IgnoreBad;
});
} }
ILW::~ILW() { ILW::~ILW() {
...@@ -120,6 +128,7 @@ bool ILW::_phase1(ftl::rgbd::FrameSet &fs, cudaStream_t stream) { ...@@ -120,6 +128,7 @@ bool ILW::_phase1(ftl::rgbd::FrameSet &fs, cudaStream_t stream) {
f1.getTexture<float>(Channel::Energy), f1.getTexture<float>(Channel::Energy),
pose, pose,
s2->parameters(), s2->parameters(),
flags_,
stream stream
); );
} catch (ftl::exception &e) { } catch (ftl::exception &e) {
......
...@@ -35,7 +35,7 @@ __global__ void correspondence_energy_vector_kernel( ...@@ -35,7 +35,7 @@ __global__ void correspondence_energy_vector_kernel(
TextureObject<float4> vout, TextureObject<float4> vout,
TextureObject<float> eout, TextureObject<float> eout,
float4x4 pose2, // Inverse float4x4 pose2, // Inverse
Camera cam2) { Camera cam2, uint flags) {
// Each warp picks point in p1 // Each warp picks point in p1
const int tid = (threadIdx.x + threadIdx.y * blockDim.x); const int tid = (threadIdx.x + threadIdx.y * blockDim.x);
...@@ -61,13 +61,13 @@ __global__ void correspondence_energy_vector_kernel( ...@@ -61,13 +61,13 @@ __global__ void correspondence_energy_vector_kernel(
const float v = (i / COR_WIN_RADIUS) - (COR_WIN_RADIUS / 2); const float v = (i / COR_WIN_RADIUS) - (COR_WIN_RADIUS / 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 (flags & ftl::cuda::kILWFlag_IgnoreBad && world2.x == MINF) continue;
const uchar4 colour2 = c2.tex2D(screen2.x+u, screen2.y+v); const uchar4 colour2 = c2.tex2D(screen2.x+u, screen2.y+v);
if (world2.x == MINF) continue;
// Determine degree of correspondence // Determine degree of correspondence
float cost = 1.0f - ftl::cuda::spatialWeighting(world1, world2, 0.04f); float cost = 1.0f - ftl::cuda::spatialWeighting(world1, world2, 0.04f);
// Point is too far away to even count // Point is too far away to even count
if (cost == 1.0f) continue; if (world2.x != MINF && cost == 1.0f) continue;
// Mix ratio of colour and distance costs // Mix ratio of colour and distance costs
cost = 0.75f * (1.0f - ftl::cuda::colourWeighting(colour1, colour2, 50.0f)) + 0.25 * cost; cost = 0.75f * (1.0f - ftl::cuda::colourWeighting(colour1, colour2, 50.0f)) + 0.25 * cost;
...@@ -75,7 +75,7 @@ __global__ void correspondence_energy_vector_kernel( ...@@ -75,7 +75,7 @@ __global__ void correspondence_energy_vector_kernel(
++count; ++count;
avgcost += cost; avgcost += cost;
if (cost < bestcost) { if (world2.x != MINF && cost < bestcost) {
bestpoint = world2; bestpoint = world2;
bestcost = cost; bestcost = cost;
} }
...@@ -113,7 +113,7 @@ void ftl::cuda::correspondence_energy_vector( ...@@ -113,7 +113,7 @@ void ftl::cuda::correspondence_energy_vector(
TextureObject<float4> &vout, TextureObject<float4> &vout,
TextureObject<float> &eout, TextureObject<float> &eout,
float4x4 &pose2, float4x4 &pose2,
const Camera &cam2, const Camera &cam2, uint flags,
cudaStream_t stream) { cudaStream_t stream) {
const dim3 gridSize((p1.width() + 2 - 1)/2, (p1.height() + T_PER_BLOCK - 1)/T_PER_BLOCK); const dim3 gridSize((p1.width() + 2 - 1)/2, (p1.height() + T_PER_BLOCK - 1)/T_PER_BLOCK);
...@@ -122,7 +122,7 @@ void ftl::cuda::correspondence_energy_vector( ...@@ -122,7 +122,7 @@ void ftl::cuda::correspondence_energy_vector(
//printf("COR SIZE %d,%d\n", p1.width(), p1.height()); //printf("COR SIZE %d,%d\n", p1.width(), p1.height());
correspondence_energy_vector_kernel<<<gridSize, blockSize, 0, stream>>>( correspondence_energy_vector_kernel<<<gridSize, blockSize, 0, stream>>>(
p1, p2, c1, c2, vout, eout, pose2, cam2 p1, p2, c1, c2, vout, eout, pose2, cam2, flags
); );
cudaSafeCall( cudaGetLastError() ); cudaSafeCall( cudaGetLastError() );
} }
......
...@@ -60,6 +60,7 @@ class ILW : public ftl::Configurable { ...@@ -60,6 +60,7 @@ class ILW : public ftl::Configurable {
std::vector<detail::ILWData> data_; std::vector<detail::ILWData> data_;
bool enabled_; bool enabled_;
unsigned int flags_;
}; };
} }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
namespace ftl { namespace ftl {
namespace cuda { namespace cuda {
static const uint kILWFlag_IgnoreBad = 0x0001;
void correspondence_energy_vector( void correspondence_energy_vector(
ftl::cuda::TextureObject<float4> &p1, ftl::cuda::TextureObject<float4> &p1,
ftl::cuda::TextureObject<float4> &p2, ftl::cuda::TextureObject<float4> &p2,
...@@ -17,6 +19,7 @@ void correspondence_energy_vector( ...@@ -17,6 +19,7 @@ void correspondence_energy_vector(
ftl::cuda::TextureObject<float> &eout, ftl::cuda::TextureObject<float> &eout,
float4x4 &pose2, float4x4 &pose2,
const ftl::rgbd::Camera &cam2, const ftl::rgbd::Camera &cam2,
uint flags,
cudaStream_t stream cudaStream_t stream
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment