Skip to content

Stereo block matching

Find horizontal correspondences between rectified stereo images using local block similarity.

Try it on your image ↓

VISUAL WALKTHROUGH3D vision
REFERENCE INPUTRectified stereo observations

Two cameras observe the same scene point from different positions.

RESULTDisparity indicates relative depth

Select a supported disparity and reject weak or inconsistent matches.

STEP 03 / 03

Select a supported disparity and reject weak or inconsistent matches.

Illustrative example. The stages explain the method; they are not a live OpenCV execution.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Compute disparity from rectified grayscale stereo views. The second image must use the same rectification. Native values are disparity pixels; negative values denote invalid matches.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Estimate a fast, coarse disparity map from a calibrated stereo pair.

How it works

  1. 01Rectify images so corresponding points share scanlines.
  2. 02Compare a local block across candidate horizontal shifts.
  3. 03Select a supported disparity and reject weak or inconsistent matches.

depth ∝ focal length × baseline / disparity

What to tune

numDisparities sets search range; blockSize trades detail against stability; uniqueness and texture settings reject uncertain matches.

Where it breaks down

Uniform regions, reflections and occlusion cause invalid disparities. The raw output uses a fixed-point scale and needs proper conversion.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.