A real time algorithm for people tracking using contextual reasoning