Made some modification of code style and perfect function
This commit is contained in:
parent
5677aa56b2
commit
23e28e20a6
|
@ -28,8 +28,16 @@ DisparityProcessor::DisparityProcessor(std::int32_t proc_period)
|
|||
VLOG(2) << __func__ << ": proc_period=" << proc_period;
|
||||
|
||||
int blockSize_ = 15; // 15
|
||||
int minDisparity_ = 0; // 0
|
||||
int numDisparities_ = 64; // 64
|
||||
|
||||
#ifdef USE_OPENCV2
|
||||
bm_ = cv::Ptr<cv::StereoBM>(
|
||||
new cv::StereoBM(
|
||||
cv::StereoBM::BASIC_PRESET,
|
||||
numDisparities_,
|
||||
blockSize_));
|
||||
#else
|
||||
int minDisparity_ = 0; // 0
|
||||
int preFilterSize_ = 9; // 9
|
||||
int preFilterCap_ = 31; // 31
|
||||
int uniquenessRatio_ = 15; // 15
|
||||
|
@ -37,7 +45,7 @@ DisparityProcessor::DisparityProcessor(std::int32_t proc_period)
|
|||
int speckleWindowSize_ = 100; // 100
|
||||
int speckleRange_ = 4; // 4
|
||||
|
||||
bm_ = cv::StereoBM::create();
|
||||
bm_ = cv::StereoBM::create(16, 9);
|
||||
bm_->setBlockSize(blockSize_);
|
||||
bm_->setMinDisparity(minDisparity_);
|
||||
bm_->setNumDisparities(numDisparities_);
|
||||
|
@ -47,6 +55,7 @@ DisparityProcessor::DisparityProcessor(std::int32_t proc_period)
|
|||
bm_->setTextureThreshold(textureThreshold_);
|
||||
bm_->setSpeckleWindowSize(speckleWindowSize_);
|
||||
bm_->setSpeckleRange(speckleRange_);
|
||||
#endif
|
||||
}
|
||||
|
||||
DisparityProcessor::~DisparityProcessor() {
|
||||
|
@ -68,7 +77,11 @@ bool DisparityProcessor::OnProcess(
|
|||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
|
||||
cv::Mat disparity;
|
||||
#ifdef USE_OPENCV2
|
||||
(*bm_)(input->first, input->second, disparity);
|
||||
#else
|
||||
bm_->compute(input->first, input->second, disparity);
|
||||
#endif
|
||||
disparity.convertTo(output->value, CV_32F, 1./16);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,13 +21,11 @@
|
|||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
#if 0
|
||||
namespace cv {
|
||||
|
||||
class StereoSGBM;
|
||||
class StereoBM;
|
||||
|
||||
} // namespace cv
|
||||
#endif
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@ bool PointsProcessor::OnProcess(
|
|||
UNUSED(parent)
|
||||
const ObjMat *input = Object::Cast<ObjMat>(in);
|
||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
// cv::reprojectImageTo3D(input->value, output->value, Q_, true, -1);
|
||||
bool handleMissingValues = true;
|
||||
|
||||
cv::Mat disparity = input->value;
|
||||
output->value.create(disparity.size(), CV_MAKETYPE(CV_32FC3, 3));
|
||||
cv::Mat _3dImage = output->value;
|
||||
|
@ -60,12 +59,9 @@ bool PointsProcessor::OnProcess(
|
|||
|
||||
double minDisparity = FLT_MAX;
|
||||
|
||||
if (handleMissingValues) {
|
||||
cv::minMaxIdx(disparity, &minDisparity, 0, 0, 0);
|
||||
}
|
||||
cv::minMaxIdx(disparity, &minDisparity, 0, 0, 0);
|
||||
|
||||
for (int y = 0; y < disparity.rows; y++) {
|
||||
|
||||
float *sptr = disparity.ptr<float>(y);
|
||||
cv::Vec3f *dptr = _3dImage.ptr<cv::Vec3f>(y);
|
||||
|
||||
|
@ -81,6 +77,7 @@ bool PointsProcessor::OnProcess(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user