From a854f96fd4a05db495d7ec068e6fbaa532387e9a Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Thu, 12 Dec 2019 13:02:31 +0200 Subject: [PATCH] Add highres channel --- applications/reconstruct/src/reconstruction.cpp | 4 ++-- components/operators/src/colours.cpp | 13 +++++++++++-- components/renderers/cpp/src/tri_render.cpp | 6 +++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/applications/reconstruct/src/reconstruction.cpp b/applications/reconstruct/src/reconstruction.cpp index be1f6cd8b..8a868e56e 100644 --- a/applications/reconstruct/src/reconstruction.cpp +++ b/applications/reconstruct/src/reconstruction.cpp @@ -61,7 +61,7 @@ Reconstruction::Reconstruction(nlohmann::json &config, const std::string name) : ftl::pool.push([this](int id) { UNIQUE_LOCK(fs_align_.mtx, lk); - rgb_.resize(fs_align_.frames.size()); + /*rgb_.resize(fs_align_.frames.size()); for (size_t i = 0; i < rgb_.size(); i++) { auto &depth = fs_align_.frames[i].get<cv::cuda::GpuMat>(ftl::codecs::Channel::Depth); auto &color = fs_align_.frames[i].get<cv::cuda::GpuMat>(ftl::codecs::Channel::Colour); @@ -70,7 +70,7 @@ Reconstruction::Reconstruction(nlohmann::json &config, const std::string name) : std::swap(rgb_[i], color); cv::cuda::resize(rgb_[i], color, depth.size(), 0.0, 0.0, cv::INTER_LINEAR); } - } + }*/ pipeline_->apply(fs_align_, fs_align_, 0); diff --git a/components/operators/src/colours.cpp b/components/operators/src/colours.cpp index 9c6fff8b8..6a49f6ede 100644 --- a/components/operators/src/colours.cpp +++ b/components/operators/src/colours.cpp @@ -14,11 +14,12 @@ ColourChannels::~ColourChannels() { bool ColourChannels::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd::Source *s, cudaStream_t stream) { auto cvstream = cv::cuda::StreamAccessor::wrapStream(stream); + auto &col = in.get<cv::cuda::GpuMat>(Channel::Colour); + // Convert colour from BGR to BGRA if needed - if (in.get<cv::cuda::GpuMat>(Channel::Colour).type() == CV_8UC3) { + if (col.type() == CV_8UC3) { //cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream); // Convert to 4 channel colour - auto &col = in.get<cv::cuda::GpuMat>(Channel::Colour); temp_.create(col.size(), CV_8UC4); cv::cuda::swap(col, temp_); cv::cuda::cvtColor(temp_,col, cv::COLOR_BGR2BGRA, 0, cvstream); @@ -27,5 +28,13 @@ bool ColourChannels::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgb //in.resetTexture(Channel::Colour); in.createTexture<uchar4>(Channel::Colour, true); + auto &depth = in.get<cv::cuda::GpuMat>(Channel::Depth); + if (depth.size() != col.size()) { + auto &col2 = in.create<cv::cuda::GpuMat>(Channel::ColourHighRes); + cv::cuda::resize(col, col2, depth.size(), 0.0, 0.0, cv::INTER_LINEAR, cvstream); + in.createTexture<uchar4>(Channel::ColourHighRes, true); + in.swapChannels(Channel::Colour, Channel::ColourHighRes); + } + return true; } diff --git a/components/renderers/cpp/src/tri_render.cpp b/components/renderers/cpp/src/tri_render.cpp index 06d4fe262..42693dd3f 100644 --- a/components/renderers/cpp/src/tri_render.cpp +++ b/components/renderers/cpp/src/tri_render.cpp @@ -607,7 +607,11 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, co } // Reprojection of colours onto surface - _renderChannel(out, Channel::Colour, Channel::Colour, t, stream_); + auto main_channel = (scene_->frames[0].hasChannel(Channel::ColourHighRes)) ? Channel::ColourHighRes : Channel::Colour; + //if (scene_->frames[0].hasChannel(Channel::ColourHighRes)) { + // LOG(INFO) << "HAVE HIGH RES: " << scene_->frames[0].get<GpuMat>(Channel::ColourHighRes).rows; + //} + _renderChannel(out, main_channel, Channel::Colour, t, stream_); if (value("cool_effect", false)) { auto pose = params.m_viewMatrixInverse.getFloat3x3(); -- GitLab