Week 05 · Stereo and depth
Quantify how a one-pixel error affects close and distant depth estimates.
← Week 4 · Subject contents · Week 6 →
Quantify how a one-pixel error affects close and distant depth estimates.
Work through the problem
For rectified cameras with focal length f and baseline B, disparity d=u_left−u_right satisfies d=fB/Z. Rearranging gives depth Z=fB/d. With f=800 pixels and B=0.12 metres, disparity 24 pixels corresponds to 4 metres.
The derivative dZ/dd=−fB/d² shows why the same pixel error is more serious at low disparities. Moving from 24 to 23 pixels adds about 0.174 m. Moving from 6 to 5 adds 3.2 m. Do not divide by zero when a match provides no usable disparity.
One pixel matters more at low disparity.
Run the Python lab
import numpy as np
fB = 800*.12
d = np.array([6.,12.,24.,48.])
depth = fB/d
error = fB/(d-1)-depth
for a,b,c in zip(d,depth,error):
print(f"{a:.0f} px -> {b:.2f} m, minus one pixel -> +{c:.3f} m")
assert np.isclose(depth[2],4) and error[0]>error[-1]
Output from the lab
6 px -> 16.00 m, minus one pixel -> +3.200 m
12 px -> 8.00 m, minus one pixel -> +0.727 m
24 px -> 4.00 m, minus one pixel -> +0.174 m
48 px -> 2.00 m, minus one pixel -> +0.043 m
Practice
- What happens if you double the baseline at the same depth and keep focal length fixed?
Check your reasoning
- Disparity doubles, and the depth error from a one-pixel perturbation gets smaller.
← Week 4 · Subject contents · Week 6 →
Further reading · Szeliski · Computer Vision: Algorithms and Applications