Extracting the foreground objects in a video