# how to get depth from disparity map?

hello

I'm beginer. Now, I am using stereo camera.(python) Using stereoBM_create(), I made a disparity map. Disparity boundary is (-16 ~ 496). As I known, disparity means that it is gaps between two pair of image. Therefore, it is not depth right? I don't want actual depth. But, that disparities means not the same values.

(ex) image 1 : real max depth 80m / of disparity 10

image 2 : real max depth 40m / of disparity 10

these are not same, right??)

As a result, how to get depth from disparity map??

+) Z = B*f / disparity . In this formula, f (focal length) is static value?? I am using MS lifecam-hd3000. But I don't know focal legnth..

edit retag close merge delete

Sort by ยป oldest newest most voted

Z = B*f / disparity is the correct formula to get the depth in mm.

(B is the baseline, the distance between the cams, and f the focal length)

but to apply proper block matching, you have to calibrate your stereo rig (and undistort the images)

the resulting Camera matrix holds the value(s) for f.

(there's a sample here, but in c++)

more

todo: there must be a ton of examples for stereo calibration from python, i'm unable to find a nice one now.

( 2018-09-22 11:09:16 -0600 )edit

@berak I calibrate my webcams. So I could get .npz files. But, there is not focal length information. As I known, camera matrix has f_x, f_y. You mean that I should calculate the focal length by using that values? But, I also need senor size too. I searched MS lifecam-hd3000 spec, but there aren't any information about sensor size.. Please check my method. Is that right??

( 2018-10-01 07:56:46 -0600 )edit

how could i ? i have no idea, what your "method" is.

( 2018-10-01 08:03:33 -0600 )edit

Official site

GitHub

Wiki

Documentation

## Stats

Seen: 10,104 times

Last updated: Sep 22 '18