Part II · Geometry & The 3D World · Chapter 05

Depth & Stereo Vision

A single camera flattens the world and forgets how far away things are. Add a second camera — or simply slide one camera sideways — and the missing third dimension pops right back into view.

Try a two-second experiment right now. Hold one finger up near your nose and look at a wall or doorway across the room. Now blink your left eye closed, then switch and blink your right eye closed. Watch your finger jump wildly back and forth against the background!

Now stretch your arm all the way out and blink back and forth again. Your finger still jumps — but by a much smaller step. Look all the way out a window at a distant cloud or building, and it barely moves at all. That sideways jump between two viewpoints has a name: parallax, and the horizontal gap between where an object lands in the left eye versus the right eye is called disparity.

Two Eyes, One Secret Ruler

Why does a nearby object jump so much more than a far-away one? Imagine looking down from above at two cameras — a Left Eye and a Right Eye — staring straight ahead at a glowing beacon.

When the beacon is right in front of the cameras, the left eye has to glance sharply to the right to see it, while the right eye glances sharply to the left. Their two pictures disagree dramatically! Push that same beacon far away, and both eyes look almost straight ahead in parallel — their two pictures nearly overlap.

Interactive Lab 5.1 Two Eyes & Parallax Shift

Drag the glowing gold beacon closer to or farther from the two eyes in the top-down view. Watch the cyan (Left Eye) and coral (Right Eye) views overlap in the strip below!

Distance: 1.0× Eye Spacing: 1.0× Shift Gap (Disparity): 1.0× baseline Depth Signal: Clear & measurable
✦ Key Relationship · Shift Tells You Distance

Disparity works like an upside-down ruler — the bigger the jump, the closer the object:

  • Twice as close → the sideways shift between left and right views grows twice as large.
  • Twice as far → the shift shrinks to half as large, eventually fading near zero at the horizon.
  • Wider eye spacing → exaggerates the shift, helping self-driving cars and drones judge distant obstacles more accurately.
? Pause & Think

Suppose a robot has two stereo cameras mounted on its front bumper, and it stares straight at a completely blank, spotless white wall. Even though the wall is right in front of the robot, why might a stereo depth system struggle to measure how close the wall is?

To measure the horizontal shift between the left photo and the right photo, the machine first has to match the same landmark in both views (just like the corners and visual fingerprints from Chapter 3!). On a featureless white wall, every patch looks identical to every other patch, so the machine can't tell how far a pixel shifted — which is why depth cameras often project an invisible pattern of infrared dots onto blank walls.

One Camera in Motion: Turning Wiggle into Depth

Wait — what if you only have one eye, or one camera on a smartphone or flying drone? Look out the side window of a moving train or car. Nearby fence posts whip past in a blur, trees in the middle distance glide steadily by, and the far-away mountains seem to follow you slowly across the sky.

That's the exact same stereo geometry spread out across time! Taking a photo, sliding the camera sideways, and taking a second photo gives you a left view and a right view without ever needing a second lens.

Once a computer measures how fast every patch in the scene shifts, it can paint a depth map — a glowing heat map of distance where close objects shine bright gold, midground shapes glow cool teal, and the distant horizon fades into deep violet.

Interactive Lab 5.2 Motion Parallax & Depth Map Painter

Slide the camera sideways (or click Auto-Wiggle) to watch nearby objects sprint across the frame while distant peaks barely budge. Then reveal the machine's color-coded Depth Map!

Mode: Camera View Foreground Shift: 4× faster than mountains Color Key: Gold = Close · Violet = Far
★ Core Intuition · From Flat Pixels to a 3D Point Cloud

Once every pixel in a photo has both a direction (from Chapter 4's pinhole ray) and a distance (from Chapter 5's stereo or motion shift), the computer knows each pixel's true position in 3D space. Suddenly, a flat grid of colored squares becomes a solid 3D world that a robot can navigate, grasp, and map.

Chapter 5 Takeaways

  • Viewing the same scene from two slightly shifted positions creates parallax: nearby objects jump far across the frame, while distant ones barely move.
  • Disparity (the horizontal shift between left and right views) shrinks inversely with distance: twice as far means half the shift.
  • Wider camera spacing boosts depth sensitivity, which is why wide stereo rigs can judge far-away obstacles better than narrow ones.
  • A single moving camera can mimic two eyes using motion parallax, painting a depth map that turns shift speed into distance.