Member-only story
Coding a Home Intruder System / Motion Detector with Python
Learn how to detect motion, process and analyze images by coding your own security camera
Analyzing and mining images and video streams for data can be extremely useful for many cases. In this article we’ll focus on a very basic technique: detecting motion in streams so that we can isolate the moving things and apply further analysis and/or detection.
The goal is to learn how motion-detection works and learn how to apply the required techniques so that you can use them in your own projects; think of image processing detecting movement and ways to display movement in the video stream. The end result of this article will be some code that can be applied as a home-intruder system or a wild-life camera for example. Let’s code!
Before we begin
Of course, when working with video streams there might be concern for data. Always take into account the potential risks of handling images in which persons are clearly visible. Check out the article below on how to mitigate potential risks handling this kind of data:
The result
Let’s first check out what we’re working towards:

As you see we are able to detect whether movement was detected in the video and even isolate the movement (the green rectangle). Notice that very small movements like changing lights or swaying grass is ignored. In the next parts we’ll explore how this is done.