30 #include <opencv2/calib3d/calib3d.hpp>
31 #include <opencv2/imgproc/imgproc.hpp>
32 #include <opencv2/imgproc/types_c.h>
37 blockSize_(blockSize),
38 minDisparity_(
Parameters::defaultStereoBMMinDisparity()),
39 numDisparities_(numDisparities),
40 preFilterSize_(
Parameters::defaultStereoBMPreFilterSize()),
41 preFilterCap_(
Parameters::defaultStereoBMPreFilterCap()),
42 uniquenessRatio_(
Parameters::defaultStereoBMUniquenessRatio()),
43 textureThreshold_(
Parameters::defaultStereoBMTextureThreshold()),
44 speckleWindowSize_(
Parameters::defaultStereoBMSpeckleWindowSize()),
45 speckleRange_(
Parameters::defaultStereoBMSpeckleRange()),
46 disp12MaxDiff_(
Parameters::defaultStereoBMDisp12MaxDiff())
51 blockSize_(
Parameters::defaultStereoBMBlockSize()),
52 minDisparity_(
Parameters::defaultStereoBMMinDisparity()),
53 numDisparities_(
Parameters::defaultStereoBMNumDisparities()),
54 preFilterSize_(
Parameters::defaultStereoBMPreFilterSize()),
55 preFilterCap_(
Parameters::defaultStereoBMPreFilterCap()),
56 uniquenessRatio_(
Parameters::defaultStereoBMUniquenessRatio()),
57 textureThreshold_(
Parameters::defaultStereoBMTextureThreshold()),
58 speckleWindowSize_(
Parameters::defaultStereoBMSpeckleWindowSize()),
59 speckleRange_(
Parameters::defaultStereoBMSpeckleRange()),
60 disp12MaxDiff_(
Parameters::defaultStereoBMDisp12MaxDiff())
80 const cv::Mat & leftImage,
81 const cv::Mat & rightImage)
const
83 UASSERT(!leftImage.empty() && !rightImage.empty());
84 UASSERT(leftImage.cols == rightImage.cols && leftImage.rows == rightImage.rows);
85 UASSERT((leftImage.type() == CV_8UC1 || leftImage.type() == CV_8UC3) && rightImage.type() == CV_8UC1);
88 if(leftImage.channels() == 3)
90 cv::cvtColor(leftImage, leftMono, CV_BGR2GRAY);
98 #if CV_MAJOR_VERSION < 3
99 cv::StereoBM stereo(cv::StereoBM::BASIC_PRESET);
109 stereo(leftMono, rightImage, disparity, CV_16SC1);
111 cv::Ptr<cv::StereoBM> stereo = cv::StereoBM::create();
122 stereo->compute(leftMono, rightImage, disparity);