Ask Your Question
0

Disparity map on opencv 2.4

asked 2012-11-26 08:08:06 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

Hy! I am using openCv 2.4 with python 2.7. I wanted to make a disparity map from 2 stereo images and after a googling i found a good example in: https://github.com/Itseez/opencv/blob/master/samples/python2/stereo_match.py

But i don't get all the attributes of StereoSGBM even if i have read the documentation: http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#stereosgbm

Does anyone explain me better the code??

thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-05-23 07:38:16 -0500

bymulker gravatar image

updated 2016-05-23 07:48:07 -0500

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2012-11-26 08:08:06 -0500

Seen: 1,275 times

Last updated: May 23 '16