Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stereo vision: Depth estimation

I am working on Stereo vision task and I would like to get the distance between stereo vision cameras and the object. I am using Matlab with Computer Vision System Toolbox.
I have calibrated cameras with using "Camera Calibration Toolbox for Matlab" thus I have Intrinsic parameters of left and right camera and Extrinsic parameters (position of right camera wrt left camera). I have also a pair of rectified pictures and thier disparity map. For estimation of disparity I have used Matlab function disparity(). I know the baseline and the focal length of cameras but my results are still wrong.

baseline = 70 mm
focal length = 25 mm
disparity = 60 pixels
---------------------
depth = baseline * focal length / disparity = 70 * 25 / 60 = 29 mm

But I know that the distance is cca 600 mm. Is this formula right? What about the units? mm * mm / pixel != mm. And especially I would like to use Camera matrix (Intrinsic parameters) for calculation but I didn't figure out how. I would be thankful for any hint.

like image 337
PrincAm Avatar asked Nov 13 '13 14:11

PrincAm


1 Answers

Like you said, you have to convert the unit into mm. And for that you need this formulas

z = (b*F) / (d*s)

mm = (mm * mm) / (pixel * (mm/pixel)) 

Where

  • z = depth in mm
  • b = baseline in mm
  • F = focal length in mm
  • d = depth in pixel
  • s = sensor size in mm/pixel. (Normally it provide in um, so do conversion before).

EDIT

Sometime your focal is in pixel so you don't need to use the sensor size. So just use your formula :

z = b*F / d
mm = mm * pixel / pixel
like image 113
Vuwox Avatar answered Oct 21 '22 17:10

Vuwox