Python motion detection tool (with video recording)

This page is about a Python/OpenCV script that detect motion on webcam and allow record it to a file.

Screenshots :

Screenshot 1 Screenshot 2

  • State:

    Working PoC

  • Description:

    This project is simply the final recording system missing from "The smart way" part of the Motion Detection project of Robin David.

    Original extract from Motion Detection With OpenCV by Robin David:
    "I inspired myself of the Motion-tracker by Matt Williamson for the operations and filters to apply on the image but all the rest is different. The idea in this version is to find the contours of the moving objects and calculate the area of all of them. Then the average of the surface changing is compared with the total surface of the image and the video recording system is triggered if it exceed the given threshold."

    You now have at disposal a window with your camera vue and a widget to control the value of the threshold. At start, you will notice a small delay animation to let the camera focus correctly. When something is moving (relatively to the threshold value), the video frames are timestamped and the recording start.

  • License:

    MIT License
    MIT License

  • Code from my Github Gist: