diff --git a/components/operators/include/ftl/operators/disparity.hpp b/components/operators/include/ftl/operators/disparity.hpp index 4aba9bbd8e179c86ddc0d6305fb14b3579a6fb23..17993f24c5e1778957cc7f3f29762ccaa611b0cc 100644 --- a/components/operators/include/ftl/operators/disparity.hpp +++ b/components/operators/include/ftl/operators/disparity.hpp @@ -12,6 +12,7 @@ #ifdef HAVE_LIBSGM #include <libsgm.h> +#include <libsgm_parameters.hpp> #include <opencv2/cudaimgproc.hpp> #endif @@ -85,6 +86,7 @@ class FixstarsSGM : public ftl::operators::Operator { int max_disp_; float uniqueness_; bool use_P2_map_; + sgm::CensusShape ct_shape_; }; #endif diff --git a/components/operators/src/disparity/fixstars_sgm.cpp b/components/operators/src/disparity/fixstars_sgm.cpp index acd468f249afbed33b83ab36422dd8bede9ea8b2..60f4332dc5bc59d6e5cd0b0084542e9b1b66adda 100644 --- a/components/operators/src/disparity/fixstars_sgm.cpp +++ b/components/operators/src/disparity/fixstars_sgm.cpp @@ -64,6 +64,7 @@ FixstarsSGM::FixstarsSGM(ftl::operators::Graph *g, ftl::Configurable* cfg) : P1_ = cfg->value("P1", 10); P2_ = cfg->value("P2", 120); max_disp_ = cfg->value("num_disp", 256); + ct_shape_ = static_cast<sgm::CensusShape>(cfg->value("ct_shape", 2)); if (uniqueness_ < 0.0 || uniqueness_ > 1.0) { uniqueness_ = 1.0; @@ -118,6 +119,11 @@ FixstarsSGM::FixstarsSGM(ftl::operators::Graph *g, ftl::Configurable* cfg) : } }); + cfg->on("ct_shape", [this, cfg]() { + ct_shape_ = static_cast<sgm::CensusShape>(cfg->value("ct_shape", 2)); + updateParameters(); + }); + updateP2Parameters(); cfg->on("canny_low", [this, cfg]() { @@ -159,7 +165,7 @@ bool FixstarsSGM::init() { bool FixstarsSGM::updateParameters() { if (ssgm_ == nullptr) { return false; } return this->ssgm_->updateParameters( - sgm::StereoSGM::Parameters(P1_, P2_, uniqueness_, true)); + sgm::StereoSGM::Parameters(P1_, P2_, uniqueness_, true, ct_shape_)); } bool FixstarsSGM::updateP2Parameters() { diff --git a/lib/libsgm/include/libsgm_parameters.hpp b/lib/libsgm/include/libsgm_parameters.hpp index 60c0032477c5b364e81f8f534456ab7d66f157c7..23113a213fc1663cf83777db611bfbb07afc308a 100644 --- a/lib/libsgm/include/libsgm_parameters.hpp +++ b/lib/libsgm/include/libsgm_parameters.hpp @@ -2,7 +2,7 @@ namespace sgm { enum class CensusShape { - CT_5X5, + CT_5X5=0, CS_CT_9X7, CIRCLE_3 };