Search code examples
opencvimage-processingdepthstereo-3ddisparity-mapping

OpenCV 3.3 reating disparity maps returned smaller sized result


I am trying to get disparity map from stereo images. When I try stereo_match.cpp with images below, result image is smaller from original images and left of the image is missing.

Is it about parameters? What is the reason and how can solve it?

How can I improve the result with changing parameters or other things?

Here are parameters:

Ptr<StereoSGBM> sbm = StereoSGBM::create(16, 64, 3, 48, 192, 0, 0,10,200,100);
CV_WRAP static Ptr<StereoSGBM> create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3,
                                          int P1 = 0, int P2 = 0, int disp12MaxDiff = 0,
                                          int preFilterCap = 0, int uniquenessRatio = 0,
                                          int speckleWindowSize = 0, int speckleRange = 0,
                                          int mode = StereoSGBM::MODE_SGBM);

enter image description hereenter image description hereenter image description here


Solution

  • Here is theoretical explanation of disparity mapcreation:

    https://www.eecis.udel.edu/~grauerg/globalStereoPresCompVisionClass.pdf

    In order to create disparity or depth map, there should be an object visible on both cameras. In your example, disparity map shows cameras common field of view.

    If you want to incerase this field of view you could move camera closer each other but it has a cost. You will have less accuracy in z dimension and more noise.