diff --git a/components/rgbd-sources/include/ftl/offilter.hpp b/components/rgbd-sources/include/ftl/offilter.hpp index 6aece39aab241dfc7605dfb208d7d30ba6135509..0e273d80d0382dd1a805bb50f658e8180ded567e 100644 --- a/components/rgbd-sources/include/ftl/offilter.hpp +++ b/components/rgbd-sources/include/ftl/offilter.hpp @@ -17,6 +17,7 @@ public: OFDisparityFilter() : n_max_(0), threshold_(0.0) {} OFDisparityFilter(cv::Size size, int n_frames, float threshold); void filter(ftl::rgbd::Frame &frame, cv::cuda::Stream &stream); + void filter(cv::cuda::GpuMat &disp, cv::cuda::GpuMat &optflow, cv::cuda::Stream &stream); private: int n_max_; diff --git a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp index a8a4982c7432ea73e706d75b5d7bd9f97cfb9daf..9052f3540e55b4d2c48786f6155b05275f388ffd 100644 --- a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp +++ b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp @@ -154,6 +154,7 @@ bool FixstarsSGM::updateOFDisparityFilter() { } if (enable) { + LOG(INFO) << "Optical flow filter, size: " << off_size << ", threshold: " << off_threshold; off_ = ftl::rgbd::OFDisparityFilter(size_, off_size, off_threshold); use_off_ = true; } @@ -206,7 +207,11 @@ void FixstarsSGM::compute(ftl::rgbd::Frame &frame, cv::cuda::Stream &stream) cv::cuda::threshold(dispt_, dispt_, 4096.0f, 0.0f, cv::THRESH_TOZERO_INV, stream); #ifdef HAVE_OPTFLOW - if (use_off_) { off_.filter(frame, stream); } + if (use_off_) { + frame.upload(Channel::Flow, stream); + stream.waitForCompletion(); + off_.filter(dispt_, frame.get<GpuMat>(Channel::Flow), stream); + } #endif // TODO: filter could be applied after upscaling (to the upscaled disparity image) diff --git a/components/rgbd-sources/src/offilter.cpp b/components/rgbd-sources/src/offilter.cpp index 34c01c1feb73b8171b0890f8d94405ee22a0433b..832ed467ac84b4526c838fd01bc88a83d841c571 100644 --- a/components/rgbd-sources/src/offilter.cpp +++ b/components/rgbd-sources/src/offilter.cpp @@ -39,4 +39,9 @@ void OFDisparityFilter::filter(ftl::rgbd::Frame &frame, cv::cuda::Stream &stream ftl::cuda::optflow_filter(disp, optflow, disp_old_, n_max_, threshold_, stream); } +void OFDisparityFilter::filter(cv::cuda::GpuMat &disp, cv::cuda::GpuMat &optflow, cv::cuda::Stream &stream) +{ + ftl::cuda::optflow_filter(disp, optflow, disp_old_, n_max_, threshold_, stream); +} + #endif // HAVE_OPTFLOW