Lucas Kanade affine template tracking

Lucas Kanade affine template tracking , also robust inverse in c-code.
Updated 1 Oct 2009

View License

This is an affine Lucas Kanade template tracker, which performs template tracking between movie frames. For example, to follow cars, moving coronary arteries or measure camera rotation.

The Matlab code is written to show the same steps as in the Literature, not optimized for speed. But also an inverse Lucas Kanada algorithm in c-code for quick template tracking is included, which also contains pixel weighting for more robustness.

S. Baker et Al. "Lucas-Kanade 20 Years On: A Unifying Framework"
D. Schreiber, "Robust template tracking with drift correction"

Try the TTdemo.m, see screenshot!

You can easily adapted the template tracking TTdemo to your own application, for instance:

- Update the template with image data from the new ROI found in the next movie frame.
- Use the ROIs in the next movie frames, also as templates.
- Calculate the speed from difference in affine parameters between movie frames. Speed can be used to detect if tracking fails, or to smooth the tracking, or to predict the next template position.

Bugs, success and other comments are welcome!

Cite As

Dirk-Jan Kroon (2024). Lucas Kanade affine template tracking (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Image Processing and Computer Vision in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Linux Ubuntu Tested

Reliability matrix added, fixed missing code line in LucasKanadeAffine.m