Engineering · Interactive demo

How can a camera tell how far away something is?

Drag a cyclist toward a pair of cameras and watch the shift between their two views grow as the distance shrinks.

Created by ExplainerTools.

About this explainer

Made by
ExplainerTools
Format
Interactive demo
Subject
Engineering
Where it runs
Plays here
Full tool
Open the tool page
Published
Added to collection
  • stereo cameras
  • depth
  • disparity
  • driver assistance

How the model works

1 See

Close one eye, then the other, and your thumb jumps while the wall behind it stays put. A pair of cameras can turn that jump into a distance.

2 Change
  • Object distance3 m · close → 200 m · far
  • Camera spacing5 mm → 60 cm
  • Camera resolution640 px → 3,840 px (4K)

Presets Eye spacing · 6.3 cmPhone lenses · 1 cmCar stereo camera · 30 cmFar object · 150 m

Model · ideal camera pair, flat road

Two ideal pinhole cameras looking at a flat road with a fixed matching error, and no lens distortion or matching limits.

Model notes and sources

Model. Two identical pinhole cameras sit side by side, a baseline B apart, both pointing straight ahead. A point at distance Z lands d = f·B/Z pixels further right in the left camera’s image than in the right one’s. That shift is the disparity, so the distance is Z = f·B/d. Here f is the focal length in pixels, f = (W/2)/tan(FOV/2), for an image W pixels wide. The model camera has a 44° horizontal field of view, so at 1,280 pixels wide f ≈ 1,584 px. Cameras 30 cm apart see a cyclist 10 m away shift by 1,584 × 0.30 ÷ 10 ≈ 48 px; at 3.6 m, by about 132 px. A skyline 5 km away shifts by about 0.1 px.

Depth error. A stereo matcher finds the shift only to within a fraction of a pixel; the model assumes ±0.25 px (illustrative). The distance is then uncertain by about δZ ≈ Z²·δd/(f·B). The error grows with the square of the distance and shrinks with a wider baseline or a sharper camera. The tool’s measured distance rounds the shift to the nearest 0.25 px; a shift under 0.125 px rounds to zero, and then the distance can’t be told from the skyline.

The thumb trick. Your eyes are about 6.3 cm apart (US Army survey averages: 64.0 mm for men, 61.7 mm for women). We take a thumb 2 cm wide at arm’s length, 60 cm away. Your two eyes then see it from directions 2·arctan(3.15/60) ≈ 6.0° apart, about three thumb-widths, so it jumps. A wall 4 m away shifts by about 0.9°. The film draws each eye’s view like a camera looking straight ahead, as the model does. Your brain also turns your eyes and fuses the two views, and the model leaves that out.

Fixed values and drawing. Rider and bike are 1.8 m tall, 0.8 m right of the cameras’ line of sight. The cameras are 1.6 m above the road. The road is a flat plane, so each image row below the horizon shifts by B·(row − horizon)/1.6 m, and everything above the horizon (the skyline) by f·B/5 km. The low barriers are treated as part of the road. The top view is not to scale: the baselines and angles are drawn much larger, and distance is drawn on a squeezed (logarithmic) scale. The photos (the causeway, the cyclist, the living room, the hand and the car interior) are AI-generated illustrations. The left and right views are made from one photo: the cyclist and the hand are cut from edits of it and shifted by the model’s disparity, and the road and wall behind them shift by their own disparity. Every number comes from the model.

Not modeled. Lens distortion and calibration, including rectification (lining the two images up row by row); how a matcher finds the same point in both images (smooth, shiny or repeating surfaces are hard); parts visible to only one camera; motion between frames; and the radar, single-camera cues and machine learning that many systems combine with stereo. Human depth perception also uses focus, eye convergence, motion parallax and familiar sizes.

In cars and phones. Some driver-assistance systems use a forward-facing pair of cameras behind the windshield. Subaru’s EyeSight, for example, uses two cameras mounted about a foot (30 cm) apart near the rear-view mirror. The phone preset’s 1 cm stands for two neighbouring lenses and is illustrative. Phones also estimate depth from dual-pixel sensors and machine learning.

Sources: R. Szeliski, Computer Vision: Algorithms and Applications, 2nd ed. (2022), ch. 12, Depth estimation (disparity d = f·B/Z); Computer stereo vision; Binocular disparity; Pupillary distance (2012 Anthropometric Survey of US Army Personnel); Brake & Front End, Understanding Subaru’s EyeSight System (cameras “about a foot apart”); Y. Zhang et al. (2020), Du²Net: Learning depth estimation from dual-cameras and dual-pixels (depth error grows quadratically with distance); U. Franke (2013), stereo vision for driver assistance (a few pixels of disparity at 100 m and beyond; subpixel precision “a must”).

An ExplainerTools Original.

See how the world works.

Explore interactive ideas in space, science, math, and more. Try a demo, read an interactive article, watch a short video, and follow what makes you curious.

Find your next rabbit hole

New Originals

Change one thing and see why.

The three newest models, each with a short film. Watch the question, then play with the answer.

All Originals

Follow your curiosity

A collection of small doors into big ideas.

Format

Subject

Topic

Sort by

Rankings count activity here on ExplainerTools. Newest means added to this collection.

Loading collection…

Opening the collection…

Make something click.

Made an explainer, or found one you love? Give it a place in the collection.

Your next question

What do you wish someone would explain?

Send one question. If it becomes an ExplainerTools Original, you can hear when it is ready.

One weekly email with new explainers. We send a confirmation link first, and you can unsubscribe at any time.

We save your question, your email if you add one, and whether you asked to subscribe. Privacy

Share something worth understanding.

An interactive demo, an interactive article, or an educational video. Every suggestion is reviewed before it joins the collection.

Submit the creator’s original link. We credit creators and link to their work.

A collection for the curious.

ExplainerTools collects interactive explainers, visual essays, and educational videos that help an idea make sense. Browse by subject, follow a topic, or find a creator whose way of explaining speaks to you.

The work belongs to its creators.

Every entry credits its original creator. Supported experiences play here, with a link to the creator’s original work available in the player. Inclusion does not imply a partnership or endorsement.

How rankings work

Views, likes, and bookmarks count activity on ExplainerTools. They don’t include views or likes from a creator’s website or social accounts. Newest means most recently added to this collection. Ties are ordered by date added, then our curated catalog order.

Your collection

New likes and bookmarks require a free account and sync across devices when sign-in is available. Previously saved items from this browser may remain visible here.

Browse the catalog data or read about privacy.