1. A system comprising: a memory for storing a plurality of video frames; and a processor configured to track objects in the plurality of video frames by: determining a first hypothesized location for each of the objects in each of the plurality of video frames by: performing a background subtraction on the video to obtain a background reference frame: comparing each of the plurality of video frames to the background reference frame to obtain a foreground mask for each of the plurality of video frames; and generating an occupancy map for each of the plurality of video frames using the foreground mask for each of the plurality of video frames; for each of the plurality of video frames, determining probabilities that the first hypothesized location of each of the objects in a video frame of the plurality of video frames is the same as the first hypothesized location of another object in an adjacent video frame; computing a first optimal trajectory for each of the objects using an algorithm based on the probabilities; checking the first optimal trajectory for each of the objects; and accepting or rejecting the first optimal trajectory for each of the objects based on the checking.