Skip to content
Snippets Groups Projects
Commit 5fdd060b authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Refactor master merge

parent 9b2497ee
No related branches found
No related tags found
1 merge request!106Refactor channels and frame class
Pipeline #13634 passed
...@@ -120,7 +120,6 @@ template <> cv::Mat &Frame::create(ftl::rgbd::Channel c, const ftl::rgbd::Format ...@@ -120,7 +120,6 @@ template <> cv::Mat &Frame::create(ftl::rgbd::Channel c, const ftl::rgbd::Format
auto &m = _get(c).host; auto &m = _get(c).host;
if (!f.empty()) { if (!f.empty()) {
LOG(INFO) << "Creating mat: " << f.width << "," << f.height << "," << f.cvType;
m.create(f.size(), 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 ...@@ -143,3 +142,25 @@ template <> cv::cuda::GpuMat &Frame::create(ftl::rgbd::Channel c, const ftl::rgb
return m; 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;
}
...@@ -28,12 +28,13 @@ OFDisparityFilter::OFDisparityFilter(Size size, int n_frames, float threshold) : ...@@ -28,12 +28,13 @@ OFDisparityFilter::OFDisparityFilter(Size size, int n_frames, float threshold) :
void OFDisparityFilter::filter(ftl::rgbd::Frame &frame, cv::cuda::Stream &stream) void OFDisparityFilter::filter(ftl::rgbd::Frame &frame, cv::cuda::Stream &stream)
{ {
const cv::cuda::GpuMat &optflow = frame.getChannel<cv::cuda::GpuMat>(kChanFlow, stream); frame.upload(Channel::Flow, stream);
frame.getChannel<cv::cuda::GpuMat>(kChanDisparity, stream); const cv::cuda::GpuMat &optflow = frame.get<cv::cuda::GpuMat>(Channel::Flow);
//frame.get<cv::cuda::GpuMat>(Channel::Disparity);
stream.waitForCompletion(); stream.waitForCompletion();
if (optflow.empty()) { return; } 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); ftl::cuda::optflow_filter(disp, optflow, disp_old_, n_max_, threshold_, stream);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment