Stereo Vision, page 2
When an object is seen from two cameras positioned side by side (like
human eyes), the object occupies a slightly different position relative
to each image. Below is a diagram of two cameras and several simple
objects in a scene. The pink and blue triangles give you an idea of the
part of the scene that each camera can see, and each has a colored line
down the middle for a reference point.

Notice that the sphere is slightly to the right side of the left
camera's image, and slightly on the left side of the right camera's
image. Clearly the object will appear in two slightly different places
in the two images. Specifically, the object in the right image will be
shifted somewhat to the left due to the camera's shift to the right.
The precise amount that each object will appear to be shifted left or
right depends upon how far away it is from the cameras. Below are the
views from each camera (left to right).


The further an object is away, the less the slight lateral difference
between the cameras will matter. For instance, the moon is so far away
that your eyes must cast essentially parallel lines to focus on it.
Such an object at "infinity" will appear in the exact same location of
the two images. However, if the object is relatively close to the
cameras (compared to the distance between the two cameras), the greater
the difference between the lateral positions of the object in the two
images.
Below is a set of two images (known as a stereo pair) of a row of cubes
seen head on by the left eye. Obviously, you can only see one cube in
the left view because it blocks the rest of them, which are all at the
same position relative to the image. The right image, however, allows
you to see the cubes from the side. Essentially, the further to the
right these cubes are in this image, the further in the distance they
must be.


Top view of the row of cubes and the camera setup. If you were to draw
a line through the image to a very distant cube, the line would be
almost parallel to the line going through all the cubes in the left
image. This angle between left camera, subject, and right camera can be
used to measure the relative distances to the objects in the scene.

The problem is, in theory, a simple one. Most pixels in the left image
correspond to other pixels in the right image. Once you know which
pixels correspond to which, you can calculate
the relative distances to the points in space represented by those
pixels. You figure out the angle (left camera -> subject -> right
camera) first by measuring the number of pixels of lateral shift that
there are on the subject in the two images.