ROBOTICS 101Concept explainer

Stereo Vision and Disparity

Two cameras side by side see the same point at slightly different places in their images. That shift, the disparity, is large for near objects and small for far ones, so it gives depth, the same way your two eyes do.

Depth from disparity

With focal length \(f\) in pixels and baseline \(B\) between the cameras, a point at depth \(Z\) appears shifted by disparity \(d\) pixels. Small disparity errors \(\delta d\) turn into depth errors that grow with the square of the depth:

$$d = x_L - x_R = \frac{f\,B}{Z} \qquad Z = \frac{f\,B}{d} \qquad \delta Z \approx \frac{Z^2}{f\,B}\,\delta d$$

What to notice

Push the object back and the two image positions move together, so the disparity shrinks. The red band in the top view shows the range of depths that a half-pixel disparity error allows. It is thin up close and long far away. That is why stereo depth is excellent within a few meters and poor at long range.

To see farther, widen the baseline or use a longer focal length. Both make the cameras disagree more for the same depth. The cost is a bigger device and a narrower field of view.