Results from cv::StereoSGBM::create. Which is the best and why?

asked 2016-01-05 09:29:11 -0500

ban gravatar image

updated 2016-01-08 15:43:55 -0500


I am trying to get something like 3D model ( Point Cloud) from two stereo photos. I have two cameras and I am trying to construct something like stereo camera.

But first, I used photos from openCV. I mean left* and right* photos.

Then, I used them to compute a depth map. First, I had to compute fundametnal matrix and so on. So my results are:

Fundamental Matrix:

[ -3.0705036824081975e-08, -5.5010692613284437e-06, -4.1537003996251830e-07, 1.6027916082131190e-06, 3.0918646836239451e-06, -9.0983417770729963e-02,
4.8923826219224341e-04 , 9.0751934311724153e-02, 1. ]

And rms error returned by cv::stereoCalibrate is 0.276421

I chose two photos (left04.jpg and right04.jpg) and I created a depth map for it. Obviously, I rectified images.

So I present here rectified photos and results and my questions:

Left rectified: image description Right rectified: image description

And depth maps using:

cv::StereoSGBM::create(0, 256, 31): image description cv::StereoSGBM::create(0, 256, 17): image description

cv::StereoSGBM::create(0, 128, 31): image description cv::StereoSGBM::create(0, 128, 17): image description cv::StereoSGBM::create(0, 128, 11): image description


  1. Which are the best for reconstruction 3D? Why? On my eye the best is the last one but I have no experience.

  2. Is it the best possible depth map or can I get better results ( I think so). But why and how to?

The second question is the most important for me because I have no experience and it is too hard to decide for me.

Please make clear my doubts.

edit retag flag offensive close merge delete



Good and bad results on depth maps depend on the application. If you need precision, you require a very good depth map, if you only want to do gross analysis, you don't require a high quality depth map.

Having this said, all your chessboard examples seem pretty bad, but I'm not too familiar with opencv's stereo module so I can't tell if it is possible to get better results.

Pedro Batista gravatar imagePedro Batista ( 2016-01-08 04:38:37 -0500 )edit

Thanks for your comment. Yes, my data are too bad. I have to construct 3D model so I need a good precision. So, what can I do to improve my results?

ban gravatar imageban ( 2016-01-08 15:42:54 -0500 )edit

I'd go over the scientific literature to find state of the art stereoscopy algorithms and try to implement them myself.

Also, search for opencv examples that use SteroBGM and are getting better results, to verify if there is something you should tweak in your code.

Pedro Batista gravatar imagePedro Batista ( 2016-01-11 05:12:52 -0500 )edit