Ask Your Question

calculate distance using disparity map

asked 2014-03-17 13:19:15 -0500

La Rosa gravatar image

updated 2014-03-18 02:24:04 -0500

berak gravatar image

i am wondering how can i calculate the distance between tow webcams(stereo vision) and an object in front of them using the disparity map?

edit retag flag offensive close merge delete


Any help please!

La Rosa gravatar imageLa Rosa ( 2014-03-18 08:11:18 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-03-18 08:19:38 -0500

berak gravatar image

updated 2014-03-18 08:20:25 -0500

looking at this nice page, we get:

D:= Distance of point in real world,
b:= base offset, (the distance *between* your cameras)
f:= focal length of camera, 
d:= disparity:

D = b*f/d
edit flag offensive delete link more


it works but i'm getting the result in an matrix?!! is that ok?

La Rosa gravatar imageLa Rosa ( 2014-03-18 10:03:46 -0500 )edit

oh, hehe. yes that's ok.

if you went and divided b*d ( a number ) by your disparity matrix, python will make a matrix as result.

every cell now contains the resp. distance at that point

berak gravatar imageberak ( 2014-03-18 10:36:28 -0500 )edit

yopiii :) , thank you sooooo much

La Rosa gravatar imageLa Rosa ( 2014-03-18 10:39:34 -0500 )edit

can you give me the code for calculating distance using disparity?

apoorva gravatar imageapoorva ( 2014-04-09 08:33:53 -0500 )edit

@apoorva it's right in front of you ?

berak gravatar imageberak ( 2014-04-09 08:37:05 -0500 )edit

How come pixel size isn't included in the formula?

Or is the pixel size implicitly included if we state disparity in the same measurment unit as focal length?

acajic gravatar imageacajic ( 2015-09-02 03:46:29 -0500 )edit

Question Tools

1 follower


Asked: 2014-03-17 13:19:15 -0500

Seen: 8,139 times

Last updated: Mar 18 '14