From b4770451c745470b813dd2f0be5876d2b51ec7d5 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Fri, 27 Sep 2019 08:15:32 +0300 Subject: [PATCH] Allow non colour channels to be displayed --- components/codecs/src/nvpipe_encoder.cpp | 4 ++++ components/renderers/cpp/src/splat_render.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/codecs/src/nvpipe_encoder.cpp b/components/codecs/src/nvpipe_encoder.cpp index 42374bede..f1b068d74 100644 --- a/components/codecs/src/nvpipe_encoder.cpp +++ b/components/codecs/src/nvpipe_encoder.cpp @@ -47,6 +47,10 @@ bool NvPipeEncoder::encode(const cv::Mat &in, definition_t odefinition, bitrate_ //LOG(INFO) << "Definition: " << ftl::codecs::getWidth(definition) << "x" << ftl::codecs::getHeight(definition); + if (in.empty()) { + LOG(ERROR) << "Missing data for Nvidia encoder"; + return false; + } if (!_createEncoder(in, definition, bitrate)) return false; //LOG(INFO) << "NvPipe Encode: " << int(definition) << " " << in.cols; diff --git a/components/renderers/cpp/src/splat_render.cpp b/components/renderers/cpp/src/splat_render.cpp index 1b39ccebf..0064aba5f 100644 --- a/components/renderers/cpp/src/splat_render.cpp +++ b/components/renderers/cpp/src/splat_render.cpp @@ -69,7 +69,7 @@ void Splatter::renderChannel( // Accumulate attribute contributions for each pixel for (auto &f : scene_->frames) { // Convert colour from BGR to BGRA if needed - if (f.get<GpuMat>(Channel::Colour).type() == CV_8UC3) { + if (f.get<GpuMat>(channel).type() == CV_8UC3) { // Convert to 4 channel colour auto &col = f.get<GpuMat>(Channel::Colour); GpuMat tmp(col.size(), CV_8UC4); @@ -211,6 +211,13 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda out.create<GpuMat>(Channel::Right, Format<uchar4>(camera.width, camera.height)); out.get<GpuMat>(Channel::Right).setTo(cv::Scalar(76,76,76), cvstream); renderChannel(params, out, Channel::Right, stream); + } else { + if (ftl::rgbd::isFloatChannel(chan)) { + out.create<GpuMat>(chan, Format<float>(camera.width, camera.height)); + } else { + out.create<GpuMat>(chan, Format<uchar4>(camera.width, camera.height)); + } + renderChannel(params, out, chan, stream); } return true; -- GitLab