Skip to content
Snippets Groups Projects
fixstars_sgm.hpp 1.05 KiB
Newer Older
Nicolas Pope's avatar
Nicolas Pope committed
/*
 * Copyright 2019 Nicolas Pope
 */

#ifndef _FTL_ALGORITHMS_FIXSTARS_SGM_HPP_
#define _FTL_ALGORITHMS_FIXSTARS_SGM_HPP_

#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <libsgm.h>
Nicolas Pope's avatar
Nicolas Pope committed
#include "../disparity.hpp"
Nicolas Pope's avatar
Nicolas Pope committed
#include <ftl/configuration.hpp>

namespace ftl {
namespace algorithms {
Nicolas Pope's avatar
Nicolas Pope committed

/**
 * Fixstars libSGM stereo matcher. 
 * @see https://github.com/fixstars/libSGM
 *
 * NOTE: We are using a modified version that supports disparity of 256.
 * @see https://github.com/knicos/libSGM
 */
class FixstarsSGM : public ftl::Disparity {
	public:
Nicolas Pope's avatar
Nicolas Pope committed
	explicit FixstarsSGM(nlohmann::json &config);

	void compute(const cv::Mat &l, const cv::Mat &r, cv::Mat &disp) override;
Sebastian Hahta's avatar
Sebastian Hahta committed
	void setMask(cv::Mat &mask) override;
Nicolas Pope's avatar
Nicolas Pope committed
	/* Factory creator */
Nicolas Pope's avatar
Nicolas Pope committed
	static inline Disparity *create(ftl::Configurable *p, const std::string &name) {
		return ftl::create<FixstarsSGM>(p, name);
	private:
	bool use_filter_;
	cv::Ptr<cv::cuda::DisparityBilateralFilter> filter_;
	sgm::StereoSGM *ssgm_;
};
};
};

Nicolas Pope's avatar
Nicolas Pope committed
#endif  // _FTL_ALGORITHMS_FIXSTARS_SGM_HPP_