Build A Security Camera with Python and OpenCV

Alessandro Lamberti
Artificialis
Published in
3 min readOct 23, 2021

--

Photo by Miłosz Klinowski on Unsplash

In this tutorial we’ll build a basic security system using only Python, the OpenCV module and a webcam.

The aim will be to detect a face or a body (thus the webcam). Once a face or body is detected, the system will automatically extract and save them into a folder.

So, with that said, this tutorial will assume you have Python installed and you know the basics of OpenCV module.
Let’s write some code.

OpenCV setup

If you already have OpenCV installed, you can skip this step.
Otherwise, go to your terminal inside your project folder, and type:

pip3 install opencv-python

If pip3 doesn’t work, try with only pip.

Now that we have the module installed, let’s open a main.py file and start writing out the logic.

Libraries and setup

Let’s first import some useful libraries and start writing out what we’ll use.

--

--