Locally Adapted Gain Control for Reliable Foreground Detection