Stereo Vision Visualizer

How two eyes calculate distance using math

Interactive Mode

1. Top-Down Geometry
This is a bird's-eye view. The two blue semi-circles are the eyes (cameras). The orange dot is the object.

Instructions: Click and drag the orange dot to move the object!

Drag the Orange Dot

Left Eye View

0px

Right Eye View

0px

The Concept of Disparity

Disparity is the difference in horizontal position of the object between the left and right image.

Close your left eye, then your right. Notice how close objects "jump" more than far objects? That jump is disparity.
Disparity (d)

Controls

Wider baseline = Better depth perception at range.

How much the lens zooms in.

Tip: Drag the orange ball in the diagram to change distance (Z)!

Calculating Depth (Z)
This formula is called Triangulation.

Computers (and brains) know the Baseline ($b$) and Focal Length ($f$). They measure the Disparity ($d$) from the images.

Since $d$ is in the denominator, as disparity gets smaller (close to 0), distance goes to infinity.

Z =
f ċ b
d
Focal Length (f): 500
Baseline (b): 60
Disparity (d): 0
Distance (Z): 0 units

Real World Applications

  • Self-Driving Cars: Use stereo cameras to detect how far away pedestrians are.
  • VR Headsets: Use this math in reverse to trick your brain into seeing depth.
  • Robotics: Helps robot arms pick up objects.