The application of Konolige's block matching algorithm is not sufficiantly explained in the OpenCV documentation. The parameters of CvStereoBMState influence the accuracy of the disparities calculated by cv::StereoBM. However, those parameters are not documented. I will list those parameters below and describe, what I understand. Maybe someone can add a description of the parameters, which are unclear.
- preFilterType: Determines, which filter is applied on the image before the disparities are calculated. Can be CV_STEREO_BM_XSOBEL (Sobel filter) or CV_STEREO_BM_NORMALIZED_RESPONSE (maybe differences to mean intensity???)
- preFilterSize: Window size of the prefilter (width = height of the window, negative value)
- preFilterCap: Clips the output to [-preFilterCap, preFilterCap]. What happens to the values outside the interval?
- SADWindowSize: Size of the compared windows in the left and in the right image, where the sums of absolute differences are calculated to find corresponding pixels.
- minDisparity: The smallest disparity, which is taken into account. Default is zero, should be set to a negative value, if negative disparities are possible (depends on the angle between the cameras views and the distance of the measured object to the cameras).
- numberOfDisparities: The disparity search range [minDisparity, minDisparity+numberOfDisparities].
- textureThreshold: Calculate the disparity only at locations, where the texture is larger than (or at least equal to?) this threshold. How is texture defined??? Variance in the surrounding window???
- uniquenessRatio: Cited from calib3d.hpp: "accept the computed disparity d* only ifSAD(d) >= SAD(d*)(1 + uniquenessRatio/100.) for any d != d+/-1 within the search range."
- speckleRange: Unsure.
- trySmallerWindows: ???
- roi1, roi2: Calculate the disparities only in these regions??? Unsure.
- speckleWindowSize: Unsure.
- disp12MaxDiff: Unsure, but a comment in calib3d.hpp says, that a left-right check is performed. Guess: Pixels are matched from the left image to the right image and from the right image back to the left image. The disparities are only valid, if the distance between the original left pixel and the back-matched pixel is smaller than disp12MaxDiff.
CV_CALIB_ZERO_DISPARITY
instereoRectify
. If you did, thenminDisparity
should be set to zero or to a positive number, because in this case the disparity cannot be negative. For the other variables, I don't know. – Toxicity