diff --git a/applications/reconstruct/src/ilw/ilw.cpp b/applications/reconstruct/src/ilw/ilw.cpp index c09b8d5b07e778c38ef114056696871b299b3999..741e457aac1eaed70e40ea2de9fa4848c57e9736 100644 --- a/applications/reconstruct/src/ilw/ilw.cpp +++ b/applications/reconstruct/src/ilw/ilw.cpp @@ -23,8 +23,13 @@ ILW::ILW(nlohmann::json &config) : ftl::Configurable(config) { params_.spatial_smooth = value("spatial_smooth", 0.04f); params_.cost_ratio = value("cost_ratio", 0.2f); discon_mask_ = value("discontinuity_mask",2); + fill_depth_ = value("fill_depth", true); - on("ilw_align", [this](const ftl::config::Event &e) { + on("fill_depth", [this](const ftl::config::Event &e) { + fill_depth_ = value("fill_depth", true); + }); + + on("ilw_align", [this](const ftl::config::Event &e) { enabled_ = value("ilw_align", true); }); @@ -160,19 +165,6 @@ bool ILW::_phase0(ftl::rgbd::FrameSet &fs, cudaStream_t stream) { f.createTexture<int>(Channel::Mask, Format<int>(f.get<GpuMat>(Channel::Colour).size())); f.createTexture<uchar4>(Channel::Colour); f.createTexture<float>(Channel::Depth); - - ftl::cuda::preprocess_depth( - f.getTexture<float>(Channel::Depth), - f.getTexture<float>(Channel::Depth2), - f.getTexture<uchar4>(Channel::Colour), - f.getTexture<int>(Channel::Mask), - s->parameters(), - params_, - stream - ); - - //cv::cuda::swap(f.get<GpuMat>(Channel::Depth),f.get<GpuMat>(Channel::Depth2)); - f.swapChannels(Channel::Depth, Channel::Depth2); } return true; @@ -182,6 +174,27 @@ bool ILW::_phase1(ftl::rgbd::FrameSet &fs, int win, cudaStream_t stream) { // Run correspondence kernel to create an energy vector cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream); + // First do any preprocessing + if (fill_depth_) { + for (size_t i=0; i<fs.frames.size(); ++i) { + auto &f = fs.frames[i]; + auto s = fs.sources[i]; + + ftl::cuda::preprocess_depth( + f.getTexture<float>(Channel::Depth), + f.getTexture<float>(Channel::Depth2), + f.getTexture<uchar4>(Channel::Colour), + f.getTexture<int>(Channel::Mask), + s->parameters(), + params_, + stream + ); + + //cv::cuda::swap(f.get<GpuMat>(Channel::Depth),f.get<GpuMat>(Channel::Depth2)); + f.swapChannels(Channel::Depth, Channel::Depth2); + } + } + // For each camera combination for (size_t i=0; i<fs.frames.size(); ++i) { auto &f1 = fs.frames[i]; diff --git a/applications/reconstruct/src/ilw/ilw.hpp b/applications/reconstruct/src/ilw/ilw.hpp index 96a5341544471ed4fbe6f6269f6531177a26b9ef..98357ba731ceb4c84ef71d7b27bc81f1e08ffc9b 100644 --- a/applications/reconstruct/src/ilw/ilw.hpp +++ b/applications/reconstruct/src/ilw/ilw.hpp @@ -70,6 +70,7 @@ class ILW : public ftl::Configurable { int motion_window_; bool use_lab_; int discon_mask_; + bool fill_depth_; }; }