Stereo disparity (source code)

= Stereo disparity
{title2=$d$}

<Stereo disparity> is the difference between the image positions of the same scene feature in two views. For an ideal horizontally aligned pair, use signed horizontal coordinates with matched principal points and define
$$
d=u_L-u_R.
$$
With the orientation and <camera baseline> convention of <stereoscopic triangulation>, a point in front of the <cameras> has $d=fB/Z$: <stereo disparity> measures inverse depth, rather than depth itself. Halving $d$ doubles $Z$ when the <camera baseline> and <focal length> stay fixed.

A <disparity map> assigns this difference to matched image locations. Finding the matches is a separate <stereo correspondence> problem. A repeated pattern can give several plausible matches; a feature hidden from one <camera> has no visible partner. A small measured <stereo disparity> is therefore not, by itself, proof of a distant object: the match and calibration must also be credible.<What Is Stereo Reconstruction? by MathWorks>[Stereo Image Rectification and Disparity Map Computation: aligned rows, matching pixels and disparity-to-depth conversion]{ref}

The ideal relation also explains why far-away reconstruction becomes sensitive to <measurement error>. Differentiating $Z=fB/d$ gives $\mathrm dZ/\mathrm dd=-fB/d^2$; the first-order <propagation of uncertainty> is $\sigma_Z\simeq fB\sigma_d/d^2$. Thus equal disparity errors produce larger depth errors at greater depth. The example and curves under <stereoscopy> quantify this effect.