In my first post I want to present something very simple to explain and very funny at the same time. It is a very simple example of color based object tracking. As all we know, color based object tracking can be very simple to achieve but it is not as robust to implement for something very serious but it do can be applied for some funny robots.
This example is implemented using c++ as all my image processing algorithms. While I was searching for some library for capturing the camera frames – I didn’t wanted to wast any time on that – I found a new version of the famous OpenCV library and I wanted to give it a try. If you don’t want to use OpenCV for capturing the camera frames, here is an excellent video grabber library: http://shukaiyang.myweb.hinet.net/vdograb/index.html
The algorithm is very simple. First each frame is captured using the cvQueryFrame, then each frame is processed without using any OpenCV function (I rather like to use mine) .
Each frame is first smoother in order to blur the image a little bit. After the smoothing, the image is analyzed in order to determine whether each pixel belongs to the color we are interested in. in this case the red one. All pixels matching this criteria are leaved untouched, all other pixels are whitened.
Two Red pens are tracked
The next step is to threshold the image, so we will have an white-black image only where the black pixels belong to the object we are follow. In order to improve the recognition, the final step is to use morphological operation to remove undesired spots due to image noise.
After the final step was performed, we have identified the objects matching the color we are tracking.
I use again OpenCV in the final step in order to display the object tracked in the original video frame as you can see in the video.
It is a simple way to start working on object recognition/tracking and start improving it as you learn more complex algorithms.