Correspondence and reconstruction
A stereo system has to solve two problems:
- Correspondence: which pixel in the left image and which in the right image show the same scene point?
- Reconstruction: given a correspondence and the geometry of the cameras, where is the point?
This demo is about the second problem and assumes the simplest setup: both optical axes are parallel, both image planes lie in the same plane, and the scanlines are aligned, . A point can then only correspond to a point on the same scanline, and its two pixels differ only in . Other setups can be brought into this form by rectification.
Depth from disparity
Put the left center of projection at the origin and the right one at a distance , the baseline, along . Similar triangles give for both cameras
Setting both equal and solving for :
The disparity is inversely proportional to the depth: near points have a large disparity, and means a point at infinity. Geometrically, is where the ray through meets the ray through .
Depth resolution and the baseline
Pixels have a width, so a pixel pair does not determine a point but a small area: the overlap of the two pixel wedges, shaded in the top view. Its depth extent follows from the derivative of :
The depth error for one pixel of disparity error grows with the square of the distance. A longer focal length or a longer baseline makes it smaller, so a small baseline gives a large depth error. A large baseline has its own problems: the search for correspondences covers more pixels, the two views look more different, and less of the scene is visible in both images, especially near the cameras.
Noise and wrong matches
Sensor noise, quantization and discretization shift the measured pixels, and each shift tilts a ray. Near the cameras, where the rays meet at a large angle, that barely moves the intersection; far away, where they are almost parallel, it moves it a lot. A wrong correspondence is worse: if the pixel of in the left image is matched with the pixel of in the right image, the rays still meet, but at a point where there is nothing.
Try this
- Drag away from the cameras and watch the shaded cell grow: at 4 m it spans less than a meter in depth, at 10 m several meters.
- Halve and double the baseline : the cells and the curve in the plot shrink as grows. Then make large, about 1.5 m, and drag a point close to the cameras: it leaves the region both cameras see.
- Lower the focal length to 30 px: a point at 10 m has a disparity of only 1 px, and the next possible value, 0 px, means infinity.
- Add noise of 0.5–1 px and press New noise a few times: the reconstruction of the far point jumps much more than that of .
- Swap the correspondence: the two rays from and cross at two points that do not exist. Move behind : one of the swapped pairs may have and no intersection at all.