optimized pointscloud
This commit is contained in:
parent
45b4fdeedf
commit
f92ecd4371
|
@ -26,38 +26,26 @@ const char DisparityProcessor::NAME[] = "DisparityProcessor";
|
||||||
DisparityProcessor::DisparityProcessor(std::int32_t proc_period)
|
DisparityProcessor::DisparityProcessor(std::int32_t proc_period)
|
||||||
: Processor(std::move(proc_period)) {
|
: Processor(std::move(proc_period)) {
|
||||||
VLOG(2) << __func__ << ": proc_period=" << proc_period;
|
VLOG(2) << __func__ << ": proc_period=" << proc_period;
|
||||||
int sgbmWinSize = 3;
|
int blockSize_ = 15; // 15
|
||||||
int numberOfDisparities = 64;
|
int minDisparity_ = 0; // 0
|
||||||
|
int numDisparities_ = 64; // 64
|
||||||
|
int preFilterSize_ = 9; // 9
|
||||||
|
int preFilterCap_ = 31; // 31
|
||||||
|
int uniquenessRatio_ = 15; // 15
|
||||||
|
int textureThreshold_ = 10; // 10
|
||||||
|
int speckleWindowSize_ = 100; // 100
|
||||||
|
int speckleRange_ = 4; // 4
|
||||||
|
|
||||||
#ifdef USE_OPENCV2
|
bm_ = cv::StereoBM::create();
|
||||||
// StereoSGBM
|
bm_->setBlockSize(blockSize_);
|
||||||
// http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?#stereosgbm
|
bm_->setMinDisparity(minDisparity_);
|
||||||
sgbm_ = cv::Ptr<cv::StereoSGBM>(
|
bm_->setNumDisparities(numDisparities_);
|
||||||
new cv::StereoSGBM(
|
bm_->setPreFilterSize(preFilterSize_);
|
||||||
0, // minDisparity
|
bm_->setPreFilterCap(preFilterCap_);
|
||||||
numberOfDisparities, // numDisparities
|
bm_->setUniquenessRatio(uniquenessRatio_);
|
||||||
sgbmWinSize, // SADWindowSize
|
bm_->setTextureThreshold(textureThreshold_);
|
||||||
8 * sgbmWinSize * sgbmWinSize, // P1
|
bm_->setSpeckleWindowSize(speckleWindowSize_);
|
||||||
32 * sgbmWinSize * sgbmWinSize, // P2
|
bm_->setSpeckleRange(speckleRange_);
|
||||||
1, // disp12MaxDiff
|
|
||||||
63, // preFilterCap
|
|
||||||
10, // uniquenessRatio
|
|
||||||
100, // speckleWindowSize
|
|
||||||
32, // speckleRange
|
|
||||||
false)); // fullDP
|
|
||||||
#else
|
|
||||||
sgbm_ = cv::StereoSGBM::create(0, 16, 3);
|
|
||||||
sgbm_->setPreFilterCap(63);
|
|
||||||
sgbm_->setBlockSize(sgbmWinSize);
|
|
||||||
sgbm_->setP1(8 * sgbmWinSize * sgbmWinSize);
|
|
||||||
sgbm_->setP2(32 * sgbmWinSize * sgbmWinSize);
|
|
||||||
sgbm_->setMinDisparity(0);
|
|
||||||
sgbm_->setNumDisparities(numberOfDisparities);
|
|
||||||
sgbm_->setUniquenessRatio(10);
|
|
||||||
sgbm_->setSpeckleWindowSize(100);
|
|
||||||
sgbm_->setSpeckleRange(32);
|
|
||||||
sgbm_->setDisp12MaxDiff(1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DisparityProcessor::~DisparityProcessor() {
|
DisparityProcessor::~DisparityProcessor() {
|
||||||
|
@ -79,26 +67,8 @@ bool DisparityProcessor::OnProcess(
|
||||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||||
|
|
||||||
cv::Mat disparity;
|
cv::Mat disparity;
|
||||||
#ifdef USE_OPENCV2
|
bm_->compute(input->first, input->second, disparity);
|
||||||
// StereoSGBM::operator()
|
output->value = disparity;
|
||||||
// http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#stereosgbm-operator
|
|
||||||
// Output disparity map. It is a 16-bit signed single-channel image of the
|
|
||||||
// same size as the input image.
|
|
||||||
// It contains disparity values scaled by 16. So, to get the floating-point
|
|
||||||
// disparity map,
|
|
||||||
// you need to divide each disp element by 16.
|
|
||||||
(*sgbm_)(input->first, input->second, disparity);
|
|
||||||
#else
|
|
||||||
// compute()
|
|
||||||
// http://docs.opencv.org/master/d2/d6e/classcv_1_1StereoMatcher.html
|
|
||||||
// Output disparity map. It has the same size as the input images.
|
|
||||||
// Some algorithms, like StereoBM or StereoSGBM compute 16-bit fixed-point
|
|
||||||
// disparity map
|
|
||||||
// (where each disparity value has 4 fractional bits),
|
|
||||||
// whereas other algorithms output 32-bit floating-point disparity map.
|
|
||||||
sgbm_->compute(input->first, input->second, disparity);
|
|
||||||
#endif
|
|
||||||
output->value = disparity / 16 + 1;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,17 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <opencv2/calib3d/calib3d.hpp>
|
||||||
|
|
||||||
#include "api/processor/processor.h"
|
#include "api/processor/processor.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
namespace cv {
|
namespace cv {
|
||||||
|
|
||||||
class StereoSGBM;
|
class StereoSGBM;
|
||||||
|
|
||||||
} // namespace cv
|
} // namespace cv
|
||||||
|
#endif
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -42,7 +46,7 @@ class DisparityProcessor : public Processor {
|
||||||
Object *const in, Object *const out, Processor *const parent) override;
|
Object *const in, Object *const out, Processor *const parent) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cv::Ptr<cv::StereoSGBM> sgbm_;
|
cv::Ptr<cv::StereoBM> bm_;
|
||||||
};
|
};
|
||||||
|
|
||||||
MYNTEYE_END_NAMESPACE
|
MYNTEYE_END_NAMESPACE
|
||||||
|
|
Loading…
Reference in New Issue
Block a user