This is a simple tracking example of moving object.  The basic concept is simple as following the steps 
  1. Use background subtraction   Code Here
  2. Draw a Rectangle over the object  (blue) (Use coordinates of center (X,Y))
  3. Init Kalman filter (red object) with detected (X,Y) coordinates
  4. If the measured position of the object is available update the Kalman filter. 
  5. If the measured position is not available just read the predicated state of the kalam filter