File Exchange

image thumbnail

Simple demo program for color based tracking

version (2.61 KB) by Prakash Manandhar
Simple script to read a video file and track a single red marker in 2D using hue and saturation.


Updated 16 May 2011

View License

Simple script to read a video file and track a single red marker in 2D using the hue and saturation values. The largest red blob is detected and the mean co-ordinate position of this blob is tracked. This code does not have any tracking built-in: it treats each frame independently.

This assumes that the video is a constant frame rate video. The resulting co-ordinate time series are stored in the variables: t, Xc and Yc.

Download from

for a sample video on which this program was tested.

Cite As

Prakash Manandhar (2019). Simple demo program for color based tracking (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)


Hi Prakash,
I have a question if you dont mind. Assuming that i have to track the first identified blue colored object that appears in a video. After a couple of frames other objects with the same hsv parameters appear ( noise). My tracker will be found in a typical local minimum problem. If i dont want to refer to the geometry of each object separately ( which will consume time and energy), what will be the ideal filter to use in a way that whatever will appear in the video, the tracker will always go after the first object. I have asked this question everywhere, including here, cant find a proper hint.. Thanking you

Suraj Kamya

Mr Smart


Hi Prakash,

Would you be able to help on me on the matlab coding for the object tracking of the using Hue value ? As i am new to matlab i couldnt find much details on it .

My object is to perform color calibration in order to define the upper and lower limit of the HUE value for to detect the color at any light intensity .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux