Motion & Video

kalman filter tracking

Kalman-filter tracking treats an object's position and velocity as a hidden state that evolves smoothly in time, and it alternates two steps forever: predict where the object should be next from a simple physics model, then correct that prediction using the noisy measurement (a detection) when one arrives. The magic is that it blends prediction and measurement optimally, automatically trusting whichever is currently more certain, and it carries an explicit estimate of its own uncertainty.

Formally it is recursive estimation for a linear-Gaussian state-space model. The state vector x typically holds position and velocity, e.g., (x, y, vx, vy). The motion model says x_k = F·x_{k-1} + w, where F is the constant-velocity transition (next position = position + velocity) and w is zero-mean Gaussian process noise with covariance Q. The measurement model says z_k = H·x_k + v, where H selects the observed part (just position) and v is Gaussian measurement noise with covariance R. The predict step pushes the mean through F and inflates the covariance P by Q; the update step computes the Kalman gain K = P·Hᵀ·(H·P·Hᵀ + R)⁻¹, nudges the predicted state toward the measurement by K times the residual, and shrinks P. Under the linear-Gaussian assumptions this is provably the minimum-mean-squared-error estimator.

In tracking this buys three things: smoothing of jittery detections, prediction through brief missing detections (the filter coasts on velocity during a one- or two-frame gap), and a gated search region (the predicted covariance defines an ellipse of plausible next positions, which speeds and stabilizes data association). When motion is nonlinear, the Extended or Unscented Kalman Filter (EKF/UKF) linearizes or uses sigma points; when the posterior is non-Gaussian or multimodal, a particle filter replaces it. The Kalman filter is the motion backbone of classic multi-object trackers SORT and DeepSORT.

The filter is only as good as its motion model. A constant-velocity assumption smooths nicely but lags or overshoots during sharp accelerations and turns; tune Q (how much you trust the model) against R (how much you trust measurements). Too-small Q makes the filter sluggish and unable to follow maneuvers.