Foreground detection for dynamic background