You can get good results for the aloe vera plant that is found in the OpenCV
examples data directory with sbm and sgbm respectively ;
cvtColor( viewL, viewL, COLOR_RGB2GRAY );
cvtColor( viewR, viewR, COLOR_RGB2GRAY );
sStereo->alg = StereoCameraRig::STEREO_BM;
sStereo->SADWindowSize = 9;
sStereo->numberOfDisparities = 112;
sStereo->preFilterSize = 5;
sStereo->preFilterCap = 61;
sStereo->minDisparity = -39;
sStereo->textureThreshold = 507;
sStereo->uniquenessRatio = 0;
sStereo->speckleWindowSize = 0;
sStereo->speckleRange = 8;
sStereo->disp12MaxDiff = 1;
or : ..
sStereo->alg = StereoCameraRig::STEREO_SGBM;
sStereo->SADWindowSize = 11;
sStereo->numberOfDisparities = 192;
sStereo->preFilterCap = 4;
sStereo->minDisparity = -64;
sStereo->uniquenessRatio = 1;
sStereo->speckleWindowSize = 150;
sStereo->speckleRange = 1;
sStereo->disp12MaxDiff = 1;
sStereo->P1 = 600;
sStereo->P2 = 2400;
sStereo->textureThreshold = 500;
You have to convert images to grey for sbm while sgbm can work with color
images without any problems.
Note: The left and right images of the plant are rectified meaning y-axis aligned.
In order to make such a rectification (from scratch) you must stereo calibrate the system to get
intrinsic and extrinsic parameters of the system.