Ask Your Question

how to get depth from disparity map?

asked 2018-09-22 01:20:48 -0500

hotteock gravatar image


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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-09-22 01:37:59 -0500

berak gravatar image

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++)

edit flag offensive delete link more


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

berak gravatar imageberak ( 2018-09-22 11:09:16 -0500 )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??

hotteock gravatar imagehotteock ( 2018-10-01 07:56:46 -0500 )edit

Please check my method.

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

berak gravatar imageberak ( 2018-10-01 08:03:33 -0500 )edit

Question Tools



Asked: 2018-09-22 01:20:48 -0500

Seen: 5,668 times

Last updated: Sep 22 '18