Disparity vs Depth
For a rectified stereo pair, a 3D point projects to the left and right images at the same row but different columns. The horizontal offset between the two projections is the disparity (in pixels). For focal length (pixels) and stereo baseline (meters), disparity and depth are related by
The relationship is inverse: near objects have large disparity, far objects have small disparity.
Where the formula comes from
Place the left camera at the origin and the right camera at , both looking down with the same focal length and principal point (which is exactly what rectification arranges). A point projects to
so the rows agree () and the column difference is
This is also why stereo SLAM systems can store a keypoint as the triple — as ORB-SLAM2 does — and use as a third residual row in bundle adjustment: the right-image column is the depth measurement.
The law: depth resolution degrades quadratically
Differentiating with respect to gives
so a fixed disparity-matching error (typically a fraction of a pixel) produces a depth error that grows with : doubling the distance quadruples the depth uncertainty. A worked example with px, m (so px·m) and matching precision px:
| Depth | Disparity | Depth error |
|---|---|---|
| 2 m | 25 px | 0.02 m (1%) |
| 10 m | 5 px | 0.5 m (5%) |
| 20 m | 2.5 px | 2 m (10%) |
At 20 m this rig’s “metric” depth is barely better than a guess — the same measurement that is millimeter-grade at arm’s length.
Design consequences
- Baseline sets the usable depth range. A larger baseline increases disparity for the same depth, improving long-range accuracy — but it also increases the minimum measurable depth (very close points fall outside both fields of view or exceed the disparity search range) and makes matching harder due to larger appearance change between views. Small-baseline rigs (e.g., ~10 cm on a drone) are accurate up close and nearly monocular at long range.
- A practical rule of thumb: stereo depth is reliable out to roughly 40x the baseline; beyond that, disparity shrinks below matching precision and points behave like monocular (bearing-only) observations. Stereo SLAM systems such as ORB-SLAM2 and Stereo DSO explicitly split points into “close” (trusted metric depth) and “far” (triangulated over time like monocular) using such a threshold.
- Sub-pixel matching matters. Since appears linearly in the depth error, sub-pixel disparity refinement (parabola fitting, SGM sub-pixel interpolation) directly improves 3D accuracy — it is the cheapest depth-accuracy upgrade available.
In the estimator: prefer inverse depth
Note that disparity is linear in inverse depth: with ,
Pixel-level matching noise therefore maps to approximately Gaussian noise in , but to skewed, heavy-tailed noise in (a px error at px spans a huge, asymmetric depth interval). This is why SLAM systems parameterize far points by inverse depth, and why measurement covariances should be modeled in disparity/inverse-depth space and propagated, rather than assumed Gaussian in metric depth.
In a SLAM pipeline the conversion appears in two places: turning per-keypoint disparities into 3D landmark positions (or an inverse-depth parameterization), and weighting stereo observations in bundle adjustment according to their depth-dependent uncertainty.
Common pitfalls
- Trusting far stereo depth: feeding 100 m “depths” from a 10 cm baseline into the estimator as if they were accurate metric measurements biases the map; treat low-disparity points as bearing-only.
- Gaussian-in- noise models: assuming constant depth noise (or Gaussian noise in ) makes the filter/BA overconfident exactly where stereo is weakest.
- Baseline calibration error: an error in scales every depth by the same factor — a global scale bias that no amount of averaging removes.
- Forgetting the minimum depth: points closer than the disparity search range silently fail to match, so the near limit is set by the search window, not by optics alone.
Why it matters for SLAM
The geometry decides whether stereo actually helps: it tells you which landmarks carry metric information, how to set your rig’s baseline for your operating range, and how to model measurement noise correctly in the estimator. Misunderstanding it (e.g., trusting stereo depth at 100 m from a 10 cm baseline) is a classic source of biased maps and inconsistent covariances.