Skip to content
Snippets Groups Projects

Implements #228 adaptive MLS and smoothing channel

Merged Nicolas Pope requested to merge feature/mlssmooth into master
6 files
+ 58
45
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -31,6 +31,7 @@
#include <ftl/net/universe.hpp>
#include <ftl/filters/smoothing.hpp>
#include <ftl/filters/colours.hpp>
#include <ftl/cuda/normals.hpp>
#include <ftl/registration.hpp>
@@ -248,6 +249,7 @@ static void run(ftl::Configurable *root) {
// Create the source depth map filters
auto *filters = ftl::config::create<ftl::Filters>(root, "filters");
filters->create<ftl::filters::ColourChannels>("colour");
filters->create<ftl::filters::DepthSmoother>("hfnoise");
filters->create<ftl::filters::MLSSmoother>("mls");
@@ -275,51 +277,12 @@ static void run(ftl::Configurable *root) {
UNIQUE_LOCK(scene_A.mtx, lk);
cv::cuda::GpuMat tmp;
/*float factor = filter->value("smooth_factor", 0.4f);
float colour_limit = filter->value("colour_limit", 30.0f);
bool do_smooth = filter->value("pre_smooth", false);
int iters = filter->value("iterations", 3);
int radius = filter->value("radius", 5);
float var_thesh = filter->value("variance_threshold", 0.02f);*/
//if (do_smooth) {
// Presmooth...
for (int i=0; i<scene_A.frames.size(); ++i) {
auto &f = scene_A.frames[i];
auto s = scene_A.sources[i];
// Convert colour from BGR to BGRA if needed
if (f.get<cv::cuda::GpuMat>(Channel::Colour).type() == CV_8UC3) {
//cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream);
// Convert to 4 channel colour
auto &col = f.get<cv::cuda::GpuMat>(Channel::Colour);
tmp.create(col.size(), CV_8UC4);
cv::cuda::swap(col, tmp);
cv::cuda::cvtColor(tmp,col, cv::COLOR_BGR2BGRA, 0);
}
filters->filter(f, s, 0);
/*ftl::cuda::smoothing_factor(
f.createTexture<float>(Channel::Depth),
f.createTexture<float>(Channel::Depth2, ftl::rgbd::Format<float>(f.get<cv::cuda::GpuMat>(Channel::Depth).size())),
f.createTexture<float>(Channel::Energy, ftl::rgbd::Format<float>(f.get<cv::cuda::GpuMat>(Channel::Depth).size())),
//f.createTexture<uchar4>(Channel::Colour),
f.createTexture<float>(Channel::Smoothing, ftl::rgbd::Format<float>(f.get<cv::cuda::GpuMat>(Channel::Depth).size())),
var_thesh,
s->parameters(), 0
);*/
/*ftl::cuda::depth_smooth(
f.createTexture<float>(Channel::Depth),
f.createTexture<uchar4>(Channel::Colour),
f.createTexture<float>(Channel::Depth2, ftl::rgbd::Format<float>(f.get<cv::cuda::GpuMat>(Channel::Depth).size())),
s->parameters(),
radius, factor, colour_limit, iters, 0
);*/
}
//}
// Apply pre-filters to all frames
for (int i=0; i<scene_A.frames.size(); ++i) {
auto &f = scene_A.frames[i];
auto s = scene_A.sources[i];
filters->filter(f, s, 0);
}
// Send all frames to GPU, block until done?
//scene_A.upload(Channel::Colour + Channel::Depth); // TODO: (Nick) Add scene stream.
Loading