diff --git a/applications/reconstruct/src/ilw/ilw.cpp b/applications/reconstruct/src/ilw/ilw.cpp index 23ba44f8e9d45a1b8d705fe8e4bd37289df0823b..a1828a472c3978e55d0b485bde8b65535c443ea9 100644 --- a/applications/reconstruct/src/ilw/ilw.cpp +++ b/applications/reconstruct/src/ilw/ilw.cpp @@ -18,6 +18,7 @@ ILW::ILW(nlohmann::json &config) : ftl::Configurable(config) { iterations_ = value("iterations", 1); motion_rate_ = value("motion_rate", 0.4f); motion_window_ = value("motion_window", 3); + use_lab_ = value("use_Lab", false); on("ilw_align", [this](const ftl::config::Event &e) { enabled_ = value("ilw_align", true); @@ -35,6 +36,10 @@ ILW::ILW(nlohmann::json &config) : ftl::Configurable(config) { motion_window_ = value("motion_window", 3); }); + on("use_Lab", [this](const ftl::config::Event &e) { + use_lab_ = value("use_Lab", false); + }); + flags_ = 0; if (value("ignore_bad", false)) flags_ |= ftl::cuda::kILWFlag_IgnoreBad; if (value("restrict_z", true)) flags_ |= ftl::cuda::kILWFlag_RestrictZ; @@ -97,11 +102,13 @@ bool ILW::_phase0(ftl::rgbd::FrameSet &fs, cudaStream_t stream) { // Convert colour from BGR to BGRA if needed if (f.get<GpuMat>(Channel::Colour).type() == CV_8UC3) { + cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream); // Convert to 4 channel colour auto &col = f.get<GpuMat>(Channel::Colour); GpuMat tmp(col.size(), CV_8UC4); cv::cuda::swap(col, tmp); - cv::cuda::cvtColor(tmp,col, cv::COLOR_BGR2BGRA); + if (use_lab_) cv::cuda::cvtColor(tmp,tmp, cv::COLOR_BGR2Lab, 0, cvstream); + cv::cuda::cvtColor(tmp,col, cv::COLOR_BGR2BGRA, 0, cvstream); } f.createTexture<float4>(Channel::EnergyVector, Format<float4>(f.get<GpuMat>(Channel::Colour).size())); diff --git a/applications/reconstruct/src/ilw/ilw.hpp b/applications/reconstruct/src/ilw/ilw.hpp index 068e18cc1e15dc4ae79cfe30172e985e2fbb92a0..c6602586b4c10c05ef8574bcd8c564d108843aa7 100644 --- a/applications/reconstruct/src/ilw/ilw.hpp +++ b/applications/reconstruct/src/ilw/ilw.hpp @@ -42,6 +42,8 @@ class ILW : public ftl::Configurable { */ bool process(ftl::rgbd::FrameSet &fs, cudaStream_t stream=0); + inline bool isLabColour() const { return use_lab_; } + private: /* * Initialise data. @@ -64,6 +66,7 @@ class ILW : public ftl::Configurable { int iterations_; float motion_rate_; int motion_window_; + bool use_lab_; }; } diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp index d5fcad5943e9a3bb6153b6bc7451ecba17c2f4ca..92a65ea44c3598fd257d53ac6c10c22dafdba0e6 100644 --- a/applications/reconstruct/src/main.cpp +++ b/applications/reconstruct/src/main.cpp @@ -137,8 +137,15 @@ static void run(ftl::Configurable *root) { ftl::ILW *align = ftl::create<ftl::ILW>(root, "merge"); // Generate virtual camera render when requested by streamer - virt->onRender([splat,virt,&scene_B](ftl::rgbd::Frame &out) { + virt->onRender([splat,virt,&scene_B,align](ftl::rgbd::Frame &out) { virt->setTimestamp(scene_B.timestamp); + // Do we need to convert Lab to BGR? + if (align->isLabColour()) { + for (auto &f : scene_B.frames) { + auto &col = f.get<cv::cuda::GpuMat>(Channel::Colour); + cv::cuda::cvtColor(col,col, cv::COLOR_Lab2BGR); + } + } splat->render(virt, out); }); stream->add(virt);