Skip to content

Kalman filtering

Combine a predicted state with a noisy observation using their estimated uncertainties.

Try it on your image ↓

VISUAL WALKTHROUGHMotion
REFERENCE INPUTNoisy observations over time

The latest measurement does not lie exactly on the extrapolated motion path.

RESULTCorrect with the Kalman gain

The corrected position moves 65% toward the measurement in this scalar-gain example. The smaller ellipse illustrates reduced uncertainty, not a full covariance calculation.

STEP 03 / 03

Apply a covariance-weighted correction.

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 ↗

Filter an editable sequence of normalized (x,y) measurements with a constant-velocity model. The image is a backdrop: orange measurements, mint estimates.

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

Smooth position or velocity measurements and predict where a tracked object will appear next.

How it works

  1. 01Predict the next state and covariance through the motion model.
  2. 02Compare the measurement with the predicted observation.
  3. 03Apply a covariance-weighted correction.

corrected state = prediction + gain × measurement residual

What to tune

Set transitionMatrix, measurementMatrix, processNoiseCov and measurementNoiseCov to match the state and sensor model.

Where it breaks down

The basic filter assumes linear models and specified noise statistics. It estimates state, but does not detect the object or solve data association.

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.