30 #include <opencv2/calib3d/calib3d.hpp>
31 #include <opencv2/imgproc/imgproc.hpp>
32 #include <opencv2/imgproc/types_c.h>
38 blockSize_(
Parameters::defaultStereoSGBMBlockSize()),
39 minDisparity_(
Parameters::defaultStereoSGBMMinDisparity()),
40 numDisparities_(
Parameters::defaultStereoSGBMNumDisparities()),
41 preFilterCap_(
Parameters::defaultStereoSGBMPreFilterCap()),
42 uniquenessRatio_(
Parameters::defaultStereoSGBMUniquenessRatio()),
43 speckleWindowSize_(
Parameters::defaultStereoSGBMSpeckleWindowSize()),
44 speckleRange_(
Parameters::defaultStereoSGBMSpeckleRange()),
47 disp12MaxDiff_(
Parameters::defaultStereoSGBMDisp12MaxDiff()),
69 const cv::Mat & leftImage,
70 const cv::Mat & rightImage)
const
72 UASSERT(!leftImage.empty() && !rightImage.empty());
73 UASSERT(leftImage.cols == rightImage.cols && leftImage.rows == rightImage.rows);
74 UASSERT((leftImage.type() == CV_8UC1 || leftImage.type() == CV_8UC3) && rightImage.type() == CV_8UC1);
77 if(leftImage.channels() == 3)
79 cv::cvtColor(leftImage, leftMono, CV_BGR2GRAY);
87 #if CV_MAJOR_VERSION < 3
88 cv::StereoSGBM stereo(
100 stereo(leftMono, rightImage, disparity);
102 cv::Ptr<cv::StereoSGBM> stereo = cv::StereoSGBM::create(
114 stereo->compute(leftMono, rightImage, disparity);