diff --git a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp index daa1a335bfe1611b8870f643ed38b17672e1332d..73d853e9c2fb2fce7728a59c7956136b972c0ec6 100644 --- a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp +++ b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp @@ -12,9 +12,8 @@ using cv::cuda::GpuMat; FixstarsSGM::FixstarsSGM(nlohmann::json &config) : Disparity(config) { ssgm_ = nullptr; + uniqueness_ = value("uniqueness", 0.95f); use_filter_ = value("use_filter", false); - // note: (max_disp_ << 4) libsgm subpixel accuracy. - // What is the impact in the filter? (possible artifacts) filter_ = cv::cuda::createDisparityBilateralFilter(max_disp_ << 4, value("filter_radius", 25), value("filter_iter", 1)); } @@ -26,7 +25,7 @@ void FixstarsSGM::compute(const cv::cuda::GpuMat &l, const cv::cuda::GpuMat &r, if (!ssgm_) { // todo: move to constructor dispt_ = GpuMat(l.rows, l.cols, CV_16SC1); ssgm_ = new sgm::StereoSGM(l.cols, l.rows, max_disp_, 8, 16, lbw_.step, dispt_.step / sizeof(short), - sgm::EXECUTE_INOUT_CUDA2CUDA, sgm::StereoSGM::Parameters(10,120,0.95f,true)); + sgm::EXECUTE_INOUT_CUDA2CUDA, sgm::StereoSGM::Parameters(10, 120, uniqueness_, true)); } //auto start = std::chrono::high_resolution_clock::now(); @@ -62,7 +61,7 @@ void FixstarsSGM::setMask(Mat &mask) { if (!ssgm_) { // todo: move to constructor ssgm_ = new sgm::StereoSGM(mask.cols, mask.rows, max_disp_, 8, 16, sgm::EXECUTE_INOUT_HOST2HOST, - sgm::StereoSGM::Parameters(10,120,0.95f,true)); + sgm::StereoSGM::Parameters(10, 120, uniqueness_, true)); } mask_l_ = mask; diff --git a/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp b/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp index dfbae841150ca0443c9f67acb7e871dacc08cf2e..200775cf3f91c26cdd459935fdf171842118752a 100644 --- a/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp +++ b/components/rgbd-sources/src/algorithms/fixstars_sgm.hpp @@ -35,6 +35,7 @@ class FixstarsSGM : public ftl::rgbd::detail::Disparity { } private: + float uniqueness_; bool use_filter_; cv::Ptr<cv::cuda::DisparityBilateralFilter> filter_; sgm::StereoSGM *ssgm_; diff --git a/components/rgbd-sources/src/streamer.cpp b/components/rgbd-sources/src/streamer.cpp index 9a6e20b5bf41902895aa8e280fc908c4e9a4526d..cd658f33e190aab9d97da963a655771f40c702a3 100644 --- a/components/rgbd-sources/src/streamer.cpp +++ b/components/rgbd-sources/src/streamer.cpp @@ -282,9 +282,14 @@ void Streamer::_schedule() { auto start = std::chrono::high_resolution_clock::now(); try { src->src->grab(); - } catch (...) { + } catch (std::exception &ex) { LOG(ERROR) << "Exception when grabbing frame"; + LOG(ERROR) << ex.what(); } + catch (...) { + LOG(ERROR) << "Unknown exception when grabbing frame"; + } + std::chrono::duration<double> elapsed = std::chrono::high_resolution_clock::now() - start; LOG(INFO) << "Grab in " << elapsed.count() << "s";