diff --git a/components/rgbd-sources/include/ftl/offilter.hpp b/components/rgbd-sources/include/ftl/offilter.hpp index 7775de411b952e83d431843c829d56cf8c868fce..4c4fbbb9837ef39e80f9aad68c62ae5d82d4671e 100644 --- a/components/rgbd-sources/include/ftl/offilter.hpp +++ b/components/rgbd-sources/include/ftl/offilter.hpp @@ -1,4 +1,8 @@ #pragma once + +#include <ftl/config.h> + +#ifdef HAVE_OPTFLOW #include <opencv2/core.hpp> #include <opencv2/core/cuda.hpp> #include <opencv2/cudaoptflow.hpp> @@ -28,4 +32,6 @@ private: }; } -} \ No newline at end of file +} + +#endif // HAVE_OPTFLOW diff --git a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp index 33bc92a177eee1370b6fd228a7f509ce38ca3b51..347d66184c3c32186594f2fd962046adcfb87883 100644 --- a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp +++ b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp @@ -37,6 +37,7 @@ FixstarsSGM::FixstarsSGM(nlohmann::json &config) : Disparity(config) { filter_ = cv::cuda::createDisparityBilateralFilter(max_disp_ << 4, radius, iter); } +#ifdef HAVE_OPTFLOW bool use_off_ = value("use_off", false); if (use_off_) @@ -45,6 +46,7 @@ FixstarsSGM::FixstarsSGM(nlohmann::json &config) : Disparity(config) { double off_threshold = value("off_threshold", 0.9); off_ = ftl::rgbd::OFDisparityFilter(size_, off_size, off_threshold); } +#endif init(size_); } @@ -105,11 +107,13 @@ void FixstarsSGM::compute(const cv::cuda::GpuMat &l, const cv::cuda::GpuMat &r, dispt_full_res_.convertTo(disp, CV_32F, 1.0f / 16.0f, stream); +#ifdef HAVE_OPTFLOW if (use_off_) { Mat disp_host(disp); off_.filter(disp_host, Mat(lbw_)); disp.upload(disp_host); } +#endif } void FixstarsSGM::setMask(Mat &mask) { diff --git a/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp b/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp index 521241a70843a8e5668e223f5be7b0e7050e4311..8102444f4a192f9bccb80c373adce52aa57347f6 100644 --- a/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp +++ b/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp @@ -53,7 +53,10 @@ namespace ftl { cv::cuda::GpuMat l_downscaled_; cv::cuda::GpuMat dispt_full_res_; + + #ifdef HAVE_OPTFLOW ftl::rgbd::OFDisparityFilter off_; + #endif }; }; }; diff --git a/components/rgbd-sources/src/offilter.cpp b/components/rgbd-sources/src/offilter.cpp index b74ff3ce32d8e5400692f73c09b906fb048d4920..2ed77845d2b42bd859afabc56914e3e89266a6d9 100644 --- a/components/rgbd-sources/src/offilter.cpp +++ b/components/rgbd-sources/src/offilter.cpp @@ -1,3 +1,5 @@ +#ifdef HAVE_OPTFLOW + #include <loguru.hpp> #include "ftl/offilter.hpp" @@ -107,3 +109,5 @@ void OFDisparityFilter::filter(Mat &disp, const Mat &gray) } } } + +#endif // HAVE_OPTFLOW