Detecting moving objects
The first task that needs to be accomplished for us to be able to track anything in a video is to identify those regions of a video frame that correspond to moving objects.
There are many ways to track objects in a video, all of them fulfilling a slightly different purpose. For example, you may want to track anything that moves, in which case differences between frames are going to be of help; you may want to track a hand moving in a video, in which case Meanshift based on the color of the skin is the most appropriate solution; you may want to track a particular object of which you know the aspect, in which case techniques such as template matching will be of help.
Object tracking techniques can get quite complex, let's explore them in the ascending order of difficulty, starting from the simplest technique.
Basic motion detection
The first and most intuitive solution is to calculate the differences between frames, or between a frame considered "background" and all the...