Skip to content
Snippets Groups Projects
Commit 7f846c2f authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

paramter updates

parent e1a74c20
No related branches found
No related tags found
1 merge request!161feature/vision operator
Pipeline #16273 failed
......@@ -24,6 +24,7 @@ class FixstarsSGM : public ftl::operators::Operator {
private:
bool init();
bool updateParameters();
sgm::StereoSGM *ssgm_;
cv::Size size_;
......@@ -72,10 +73,10 @@ class DisparityToDepth : public ftl::operators::Operator {
/*
* Optical flow smoothing for depth
*/
class DisparitySmoothingOF : public ftl::operators::Operator {
class OpticalFlowTemporalSmoothing : public ftl::operators::Operator {
public:
explicit DisparitySmoothingOF(ftl::Configurable*);
~DisparitySmoothingOF();
explicit OpticalFlowTemporalSmoothing(ftl::Configurable*);
~OpticalFlowTemporalSmoothing();
inline Operator::Type type() const override { return Operator::Type::OneToOne; }
......@@ -84,7 +85,7 @@ class DisparitySmoothingOF : public ftl::operators::Operator {
private:
bool init();
const ftl::codecs::Channel channel_ = ftl::codecs::Channel::Depth;
const ftl::codecs::Channel channel_ = ftl::codecs::Channel::Disparity;
cv::cuda::GpuMat history_;
cv::Size size_;
int n_max_;
......
......@@ -41,6 +41,39 @@ FixstarsSGM::FixstarsSGM(ftl::Configurable* cfg) :
max_disp_ = 256;
LOG(WARNING) << "Invalid value for max_disp, using default value (256)";
}
cfg->on("P1", [this, cfg](const ftl::config::Event&) {
int P1 = cfg->value("P1", 0);
if (P1 <= 0) {
LOG(WARNING) << "Invalid value for P1 (" << P1 << ")";
}
else {
P1_ = P1;
updateParameters();
}
});
cfg->on("P2", [this, cfg](const ftl::config::Event&) {
int P2 = cfg->value("P2", 0);
if (P2 < P1_) {
LOG(WARNING) << "Invalid value for P2 (" << P2 << ")";
}
else {
P2_ = P2;
updateParameters();
}
});
cfg->on("uniqueness", [this, cfg](const ftl::config::Event&) {
double uniqueness = cfg->value("uniqueness", 0.0);
if (uniqueness < 0.0 || uniqueness > 1.0) {
LOG(WARNING) << "Invalid value for uniqueness (" << uniqueness << ")";
}
else {
uniqueness_ = uniqueness;
updateParameters();
}
});
}
FixstarsSGM::~FixstarsSGM() {
......@@ -65,6 +98,12 @@ bool FixstarsSGM::init() {
return true;
}
bool FixstarsSGM::updateParameters() {
if (ssgm_ == nullptr) { return false; }
return this->ssgm_->updateParameters(
sgm::StereoSGM::Parameters(P1_, P2_, uniqueness_, true));
}
bool FixstarsSGM::apply(Frame &in, Frame &out, Source *src, cudaStream_t stream) {
if (!in.hasChannel(Channel::Left) || !in.hasChannel(Channel::Right)) {
return false;
......
......@@ -6,7 +6,7 @@
#ifdef HAVE_OPTFLOW
using ftl::operators::DisparitySmoothingOF;
using ftl::operators::OpticalFlowTemporalSmoothing;
using ftl::codecs::Channel;
using ftl::rgbd::Frame;
......@@ -19,14 +19,14 @@ using std::vector;
template<typename T> static bool inline isValidDisparity(T d) { return (0.0 < d) && (d < 256.0); } // TODO
DisparitySmoothingOF::DisparitySmoothingOF(ftl::Configurable* cfg) :
OpticalFlowTemporalSmoothing::OpticalFlowTemporalSmoothing(ftl::Configurable* cfg) :
ftl::operators::Operator(cfg) {
size_ = Size(0, 0);
n_max_ = cfg->value("history_size", 7);
if (n_max_ < 1) {
LOG(WARNING) << "History length must be larger than 0";
LOG(WARNING) << "History length must be larger than 0, using default (0)";
n_max_ = 7;
}
......@@ -66,7 +66,7 @@ DisparitySmoothingOF::DisparitySmoothingOF(ftl::Configurable* cfg) :
});
}
DisparitySmoothingOF::~DisparitySmoothingOF() {}
OpticalFlowTemporalSmoothing::~OpticalFlowTemporalSmoothing() {}
bool DisparitySmoothingOF::init() {
if (size_ == Size(0, 0)) { return false; }
......
......@@ -126,8 +126,8 @@ void StereoVideoSource::init(const string &file) {
pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity");
pipeline_depth_->append<ftl::operators::FixstarsSGM>("algorithm");
pipeline_depth_->append<ftl::operators::OpticalFlowTemporalSmoothing>("optflow_filter");
pipeline_depth_->append<ftl::operators::DisparityBilateralFilter>("bilateral_filter");
pipeline_depth_->append<ftl::operators::DisparitySmoothingOF>("optflow_filter");
pipeline_depth_->append<ftl::operators::DisparityToDepth>("calculate_depth");
LOG(INFO) << "StereoVideo source ready...";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment