Kalman Filters: Predicting Through Noise
A Kalman filter predicts an object's next position, then corrects that prediction with noisy real-world measurements. It's used in video tracking to smooth an object's path between frames or in robotics to fuse imperfect sensor data.
Why it exists
Measurements from the real world are always noisy. A camera might detect an object's position slightly differently in each frame, even if the object is still. We need a way to filter out this noise and estimate the object's true state, like its position and velocity, over time.
The mental model
Imagine tracking a car on a highway using a shaky camera. A Kalman filter is an algorithm that constantly does two things: first, it predicts where the car will be in the next frame based on its current speed and direction. Second, when the next frame arrives, it takes the new, shaky measurement of the car's position and intelligently blends it with the prediction. It trusts its prediction more if the measurement seems wild, and trusts the new measurement more if it's close to the prediction. This predict-correct cycle produces a smooth, realistic track from noisy data.
How it works
The filter maintains its belief about an object's state (e.g., position, velocity) as a probability distribution. The process is a two-step loop. First, the 'predict' step uses a motion model to project the state forward in time, which also increases the uncertainty of the estimate. Second, the 'update' step incorporates a new measurement. It compares the prediction to the new measurement and uses the difference to correct the state estimate, reducing its uncertainty. The amount of correction is governed by the Kalman Gain, a value that balances the confidence in the prediction versus the confidence in the measurement.
When to use it
Use a Kalman filter when you are tracking an object over time and have a series of noisy measurements from sensors. It is ideal for systems that can be reasonably approximated with a linear motion model, such as tracking vehicles on a road, aircraft in the sky, or fusing data from different sensors like an accelerometer and a GPS in a smartphone.
When not to use it
The standard Kalman filter is not suitable for systems with highly non-linear dynamics, like tracking a person walking erratically or a buzzing insect. For these cases, more advanced versions like the Extended Kalman Filter (EKF) or Unscented Kalman Filter (UKF) are required. It also assumes the measurement noise follows a Gaussian (bell curve) distribution and can perform poorly otherwise.
One canonical example
A self-driving car's perception system uses a camera and radar to track a nearby vehicle. The camera's bounding box jitters frame-to-frame, and the radar's velocity reading has its own noise. A Kalman filter fuses these measurements over time to produce a single, stable estimate of the other vehicle's true position and velocity, allowing the car to reliably predict its future path.
Interview question
Which scenario best describes a suitable application for a standard Kalman filter?
- a.Tracking a buzzing insect's unpredictable flight path.
- b.Estimating a car's position and velocity using noisy GPS and accelerometer data.Correct
- c.Analyzing perfectly clean, pre-processed sensor data from a controlled lab environment.
- d.Predicting the exact trajectory of a ball thrown with complex air resistance effects.
Why? this is the answer
A standard Kalman filter is ideal for systems with noisy measurements that can be approximated by a linear motion model, such as a car's movement. Tracking a buzzing insect or a ball with complex air resistance involves highly non-linear dynamics, making them unsuitable for a standard Kalman filter, and clean data doesn't require noise filtering.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #computer vision
- #robotics
- #control theory
- #algorithms
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on computer vision — each one lists the topics its interview covers.
See open roles