Stereo Matching

Machine Learning
Introduced by
David Scharstein and Richard Szeliski
Year
1990s
Type
Depth estimation and 3D vision
Family
3D reconstruction

What does it do?

Stereo matching is a computer vision technique for recovering depth information by finding corresponding points between a pair of stereo images (taken from slightly different viewpoints).

By locating the same scene feature in both images and measuring the disparity (horizontal shift), stereo matching reconstructs 3D structure using the principles of triangulation.

The intuition behind the method

Stereo vision works like human binocular vision: each eye sees the scene from a slightly different angle. Objects closer to the observer appear at different horizontal positions in the two views (larger disparity), while distant objects shift less. By measuring this disparity—the difference in pixel positions of the same object between the left and right images—and using the known camera baseline and focal length, depth can be computed via triangulation. Stereo matching finds these correspondences across the stereo pair.

History

Stereo matching builds on epipolar geometry and the study of binocular vision. Scharstein and Szeliski's 2002 paper, a taxonomy and evaluation of dense two-frame stereo correspondence algorithms, organised the field by classifying the methods and comparing them empirically. Later approaches combine local matching costs with global optimisation, such as belief propagation or graph cuts, or use convolutional neural networks to improve robustness. Learned matching costs, such as the convolutional network approach of Zbontar and LeCun (CVPR, 2015), replace hand-designed costs with trained networks. They require labelled stereo training data, and their accuracy in a new setting depends on how closely the training data match the target scene; classical costs remain practical with calibrated hardware and little training data. Stereo remains central to robotics, autonomous driving and 3D reconstruction.

When to use it

Choose stereo matching when you have a calibrated, synchronised pair of cameras with a known, fixed baseline suited to the working distance, and the scene has enough texture for reliable correspondences. Typical cases are robotic navigation, obstacle detection and 3D reconstruction. Textureless surfaces such as blank walls or sky, and reflective or transparent surfaces such as glass or water, give few reliable matches, so depth there is weak or missing. Occlusions produce invalid depth in classical and learned stereo alike and must be masked. For such scenes an active sensor (structured light or time-of-flight) is often considered, but the choice also depends on working range, cost and environment; for example, strong sunlight can interfere with active sensing.

Limitations and considerations

  • Requires well-textured scenes; fails in textureless regions (sky, blank walls) where there are no distinct features to match
  • Sensitive to calibration errors and camera synchronisation, since these shift the epipolar geometry and the measured disparities
  • Occlusion and disocclusion regions produce invalid depth (object visible in one image but not the other)
  • Computationally expensive for high-resolution images; a naive exhaustive search cost grows with image size and with the disparity range searched

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Passive: it needs only two cameras and no projector or emitter, unlike structured-light or time-of-flight sensing
  • Produces a depth value for every pixel where a correspondence is found, not only at sparse feature points
  • Depth follows directly from triangulation, so the parameters (baseline, focal length) have a clear geometric meaning
  • Per-pixel and per-disparity computations can be parallelised, which suits GPU or specialised hardware
  • Does not require active illumination, although changes in illumination still alter the matching costs

Applications

  • 3D reconstruction: building 3D models of scenes from multiple stereo pairs
  • Autonomous vehicle perception: stereo cameras for obstacle detection and navigation
  • Robotics and grasping: depth perception for robotic arm control and object manipulation
  • Virtual reality and augmented reality: depth estimation for scene understanding and rendering
  • Medical imaging: depth information for 3D visualisation

How it works

How it works

1

Calibrate the stereo camera pair to obtain intrinsic (focal length, principal point) and extrinsic (relative pose) parameters; rectify images so epipolar lines are horizontal.

2

Compute a matching cost for each candidate disparity. For each pixel in the left image, search along its epipolar line in the right image and score each candidate disparity with a cost such as sum of absolute differences, sum of squared differences or normalised cross-correlation, usually aggregated over a small window. Classical stereo methods fit no learned parameters at this stage; learning-based methods replace this step with a trained network that produces the cost volume.

3

Find the disparity with minimum matching cost for each pixel; apply consistency checks and filtering to remove false matches (occlusions, ambiguous regions).

4

Convert disparity to depth by triangulation: depth = (baseline × focal_length) / disparity. Mask invalid pixels (occlusions, low-confidence or unmatched pixels) instead of reading them as zero depth, and validate the depth map against ground truth or geometric consistency checks.

Common pitfalls

  • Using uncalibrated or poorly calibrated cameras; calibration errors directly propagate to depth errors
  • Choosing a matching cost that does not suit the image pair; sum of absolute differences and sum of squared differences assume that brightness is consistent between views and can fail under exposure or gain differences, where normalised cross-correlation or the census transform are more robust options to test on the target data
  • Failing to handle occlusions; regions occluded in the right image produce invalid depth estimates
  • Applying stereo to textureless scenes without active illumination or other depth sensing modality

Frequently asked questions

What is disparity and how does it relate to depth?

Disparity is the horizontal shift of a feature between the left and right stereo images, measured in pixels. Depth is inversely proportional to disparity: depth = (baseline × focal_length) / disparity. Small disparities correspond to distant objects, while large disparities indicate nearby objects. Measuring disparity accurately is the key challenge in stereo matching.

Why does stereo matching fail in textureless regions?

Textureless regions (blank walls, sky) have no distinctive features to track between images. Without spatial variation in intensity, the matching cost is similar for all disparities, making the correspondence ambiguous. Active stereo (structured light) overcomes this by projecting patterns to create artificial texture.

What is the epipolar constraint and why is it important?

The epipolar constraint states that for a given pixel in the left image, its correspondence in the right image must lie on a specific line (the epipolar line), determined by camera geometry. This constraint dramatically reduces the search space from 2D to 1D, making stereo matching tractable. Stereo rectification aligns the epipolar lines horizontally, further simplifying implementation.

How do local and global stereo matching methods differ?

Local methods compute matching cost at each pixel based on a small window and select the disparity with minimum cost independently. Global methods enforce smoothness constraints across the image, assuming neighboring pixels have similar disparities (with exceptions at occlusion boundaries). Global methods produce smoother, more coherent depth maps but require more computation.

What assumptions does classical stereo matching rely on?

The pair must be rectified so that epipolar lines are horizontal and each correspondence lies on the same image row. Matching assumes photometric consistency: a scene point looks similar in both views, which holds only approximately under different exposure, gain or specular reflection. Most classical methods also assume roughly Lambertian (matte) surfaces, a known, bounded disparity range to search, and enough overlap between the two fields of view that most pixels can be matched. Where these assumptions fail, the affected pixels should be treated as unreliable.

How should the depth output be interpreted?

Depth from triangulation is not uniformly accurate. Because depth is inversely proportional to disparity, a fixed disparity error produces a depth error that grows with distance: for a given camera, depth uncertainty grows roughly with the square of depth and shrinks with a longer baseline and a longer focal length. Disparities are quantised, typically to whole pixels or sub-pixel steps, which limits the accuracy of distant objects that shift by only a few pixels. Pixels without a reliable match, including occlusions, should be masked as invalid rather than treated as zero depth.

Related methods

Sources

  1. Scharstein, D., & Szeliski, R. (2002). A taxonomy and evaluation of dense two-frame stereo correspondence algorithms. International Journal of Computer Vision, 47(1), 7–42.

    Open DOI reference
  2. Kanade, T., Okutomi, M., Nakano, T., et al. (1996). A stereo matching algorithm with an adaptive window. Image and Vision Computing, 12(10), 605–618.

    Open publication reference
  3. 05_de26a4e4a84b58966e95c39af2c51b48b1de5af1, p. 10