Foreground Detection Optimization for SoCs embedded on Smart Cameras