From 1615b0c40fd95ed981bd1b42cca67b6ec9318553 Mon Sep 17 00:00:00 2001 From: Sebastian Hahta <joseha@utu.fi> Date: Wed, 4 Sep 2019 13:51:22 +0300 Subject: [PATCH] disable optical flow (rescaling on CUDA missing) --- .../rgbd-sources/include/ftl/rgbd/frame.hpp | 18 ++++++++++-------- components/rgbd-sources/src/stereovideo.cpp | 7 ++++++- components/rgbd-sources/src/stereovideo.hpp | 3 +++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/components/rgbd-sources/include/ftl/rgbd/frame.hpp b/components/rgbd-sources/include/ftl/rgbd/frame.hpp index e17b05702..17205d4c6 100644 --- a/components/rgbd-sources/include/ftl/rgbd/frame.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/frame.hpp @@ -12,22 +12,22 @@ namespace rgbd { typedef unsigned int channel_t; static const channel_t kChanNone = 0; -static const channel_t kChanLeft = 0x0001; -static const channel_t kChanDepth = 0x0002; -static const channel_t kChanRight = 0x0004; -static const channel_t kChanDisparity = 0x0008; +static const channel_t kChanLeft = 0x0001; // CV_8UC3 +static const channel_t kChanDepth = 0x0002; // CV_32FC1 +static const channel_t kChanRight = 0x0004; // CV_8UC3 +static const channel_t kChanDisparity = 0x0008; // CV_32FC1 static const channel_t kChanDeviation = 0x0010; static const channel_t kChanNormals = 0x0020; static const channel_t kChanConfidence = 0x0040; -static const channel_t kChanFlow = 0x0080; +static const channel_t kChanFlow = 0x0080; // CV_32FC2 or CV_16FC2 (fix) static const channel_t kChanEnergy = 0x0100; -static const channel_t kChanLeftGray = 0x0200; -static const channel_t kChanRightGray = 0x0400; +//static const channel_t kChanLeftGray = 0x0200; // not used // CV_8UC1 +//static const channel_t kChanRightGray = 0x0400; // not used // CV_8UC1 static const channel_t kChanOverlay1 = 0x1000; // maximum number of available channels -static const unsigned int n_channels = 13; +static const unsigned int n_channels = 11; inline bool isFloatChannel(ftl::rgbd::channel_t chan) { return (chan == ftl::rgbd::kChanDepth || chan == ftl::rgbd::kChanEnergy); @@ -100,6 +100,8 @@ private: case kChanConfidence: return 7; case kChanFlow: return 8; case kChanEnergy: return 9; +// case kChanLeftGray: return 11; +// case kChanRightGray: return 12; // should not happen (error); returned index is kChanNone default: return 0; } diff --git a/components/rgbd-sources/src/stereovideo.cpp b/components/rgbd-sources/src/stereovideo.cpp index 0935e238a..05f0f6765 100644 --- a/components/rgbd-sources/src/stereovideo.cpp +++ b/components/rgbd-sources/src/stereovideo.cpp @@ -61,13 +61,14 @@ void StereoVideoSource::init(const string &file) frames_ = std::vector<Frame>(2); #ifdef HAVE_OPTFLOW - // TODO could be calculated at later step too if have access to old frames +/* use_optflow_ = host_->value("use_optflow", false); LOG(INFO) << "Using optical flow: " << (use_optflow_ ? "true" : "false"); nvof_ = cv::cuda::NvidiaOpticalFlow_1_0::create(size.width, size.height, cv::cuda::NvidiaOpticalFlow_1_0::NV_OF_PERF_LEVEL_SLOW, true, false, false, 0); +*/ #endif calib_ = ftl::create<Calibrate>(host_, "calibration", size, stream_); @@ -180,6 +181,9 @@ bool StereoVideoSource::retrieve() { lsrc_->get(left, right, calib_, stream2_); #ifdef HAVE_OPTFLOW +/* + // see comments in https://gitlab.utu.fi/nicolas.pope/ftl/issues/155 + if (use_optflow_) { auto &left_gray = frame.setChannel<cv::cuda::GpuMat>(kChanLeftGray); @@ -197,6 +201,7 @@ bool StereoVideoSource::retrieve() { cv::cuda::resize(optflow_, optflow, left.size(), 0.0, 0.0, cv::INTER_NEAREST, stream2_); } } +*/ #endif stream2_.waitForCompletion(); diff --git a/components/rgbd-sources/src/stereovideo.hpp b/components/rgbd-sources/src/stereovideo.hpp index 934aeaf56..226f1c548 100644 --- a/components/rgbd-sources/src/stereovideo.hpp +++ b/components/rgbd-sources/src/stereovideo.hpp @@ -51,8 +51,11 @@ class StereoVideoSource : public detail::Source { cv::Mat mask_l_; #ifdef HAVE_OPTFLOW +/* + // see comments in https://gitlab.utu.fi/nicolas.pope/ftl/issues/155 cv::Ptr<cv::cuda::NvidiaOpticalFlow_1_0> nvof_; cv::cuda::GpuMat optflow_; +*/ #endif void init(const std::string &); -- GitLab