I've calibrated my stereo camera using OpenCV's chessboard calibration routine. I am currently using the obtained intrinsic and extrinsic matrices to rectify my messages and use a block matching approach (I've used both BM and SGBM and get the same results) to eventually go to a 3D point cloud.
Unfortunately, I am finding problems in my 3D point cloud and for some reason, there seems to be an errorenous "step" in terms of depth values.
I am used a simple experiment of imaging a pile of dirt that has a lot of texture, I expected to see a consistent reconstruction, but what I find is that a portion of it, is at the right depth value, whereas the rest of it seems to be flat on the ground. I've tried varying my stereo mark size, the max/min disparity values etc. But still I don't see any change. I've also tried imaging it horizontally AND vertically, but the problem remains in both views.
Can anyone please suggest what I might be doing incorrectly?
For the moment, the simpler BM parameters are mentioned below:
int ndisparities = 16*15;//16*10;
int SADWindowSize = 31;
cv::StereoBM sbm( CV_STEREO_BM_BASIC, ndisparities, SADWindowSize );
sbm( rectified_imgRight, rectified_imgLeft, imgDisparity16S, CV_16S );
imgDisparity16S.convertTo(imgDisparity8U, CV_8U, 255/(ndisparities*16.));
cv::imwrite("disparity.png", imgDisparity8U);