If you have a video of a steady scene with some objects moving around, it's possible to separate a still background from a changing foreground. Here, we will show you how to do it in OpenCV.
Background subtraction
Getting ready
Before you proceed with this recipe, you need to install the OpenCV version 3.3 (or greater) Python API package with contrib modules.
How to do it
You need to complete the following steps:
- Import the necessary modules:
import cv2
import numpy as np
- Define a function that opens a video file and applies a few background subtraction algorithms...