From 5fdd060ba9ac446c5e96bc32f2f5a6562cf9d053 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Mon, 16 Sep 2019 13:04:42 +0300 Subject: [PATCH] Refactor master merge --- components/rgbd-sources/src/frame.cpp | 23 ++++++++++++++++++++++- components/rgbd-sources/src/offilter.cpp | 7 ++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/components/rgbd-sources/src/frame.cpp b/components/rgbd-sources/src/frame.cpp index 6288f9b49..4886ff3cb 100644 --- a/components/rgbd-sources/src/frame.cpp +++ b/components/rgbd-sources/src/frame.cpp @@ -120,7 +120,6 @@ template <> cv::Mat &Frame::create(ftl::rgbd::Channel c, const ftl::rgbd::Format auto &m = _get(c).host; if (!f.empty()) { - LOG(INFO) << "Creating mat: " << f.width << "," << f.height << "," << f.cvType; m.create(f.size(), f.cvType); } @@ -143,3 +142,25 @@ template <> cv::cuda::GpuMat &Frame::create(ftl::rgbd::Channel c, const ftl::rgb return m; } +template <> cv::Mat &Frame::create(ftl::rgbd::Channel c) { + if (c == Channel::None) { + throw ftl::exception("Cannot create a None channel"); + } + channels_ += c; + gpu_ -= c; + + auto &m = _get(c).host; + return m; +} + +template <> cv::cuda::GpuMat &Frame::create(ftl::rgbd::Channel c) { + if (c == Channel::None) { + throw ftl::exception("Cannot create a None channel"); + } + channels_ += c; + gpu_ += c; + + auto &m = _get(c).gpu; + return m; +} + diff --git a/components/rgbd-sources/src/offilter.cpp b/components/rgbd-sources/src/offilter.cpp index 8344540b9..466aa9249 100644 --- a/components/rgbd-sources/src/offilter.cpp +++ b/components/rgbd-sources/src/offilter.cpp @@ -28,12 +28,13 @@ OFDisparityFilter::OFDisparityFilter(Size size, int n_frames, float threshold) : void OFDisparityFilter::filter(ftl::rgbd::Frame &frame, cv::cuda::Stream &stream) { - const cv::cuda::GpuMat &optflow = frame.getChannel<cv::cuda::GpuMat>(kChanFlow, stream); - frame.getChannel<cv::cuda::GpuMat>(kChanDisparity, stream); + frame.upload(Channel::Flow, stream); + const cv::cuda::GpuMat &optflow = frame.get<cv::cuda::GpuMat>(Channel::Flow); + //frame.get<cv::cuda::GpuMat>(Channel::Disparity); stream.waitForCompletion(); if (optflow.empty()) { return; } - cv::cuda::GpuMat &disp = frame.setChannel<cv::cuda::GpuMat>(kChanDisparity); + cv::cuda::GpuMat &disp = frame.create<cv::cuda::GpuMat>(Channel::Disparity); ftl::cuda::optflow_filter(disp, optflow, disp_old_, n_max_, threshold_, stream); } -- GitLab