Motion Detection
Learn how to detect motion using a video in Python.
We'll cover the following...
How to detect motion using frames
In this lesson, we’ll detect motion in a video using two consecutive frames and finding the differences between them. If the difference is minor, that means no motion occurred. If we find a significant difference between frames, then a motion must have occurred.
Look at lines 1–10 of the code block below. In this code, we’re creating a video capture instance. Then we’ll read the last and the current frames and convert them to grayscale in lines 13–15.
Here we’ll read two frames and convert them to grayscale. It might seem like we’re doing this outside the while ...