Building a Raspberry Pi Security Camera with Face Recognition

Rithika Chowta
2 min readMay 27, 2019

--

Tinkering around with OpenCV during a college project gave me a newfound interest in computer vision. Following along that path led me to develop a simple face recognition security system on my Raspberry Pi. While the performance is not great on the Pi, with a good GPU, the system should work pretty well. I’d recommend it over getting a pre-made system any day. Plus you get to have all that fun developing it and customizing it as you wish.

So to begin with I installed Raspbian Jessie on the Pi. Raspbian Stretch is fine too but I find it so annoying that there is no way to configure wifi to start on boot without hooking up to a monitor. Then I installed face_recognition, dlib and opencv-python modules. face_recognition is a Python API for — you guessed it — face recognition. It uses HOG to detect faces, OpenFace to encode them and a linear SVM classifier to recognise them. And it ain’t called the world’s simplest face recognition library for nothing. There truly is nothing like it. Kudos to Adam Geitgey for simplifying something that I thought was so complex. Do read his post. He explains it better than I ever can. Well worth the 13 mins!

Back to business. After that was done, I used one of the examples in Adam’s Github repo to process live video. I added a few images to the known faces folder. All I had to then was to modify it to send an email if a face is not recognised. I did this by invoking a shell script from the main program which uses mpack to send an email with the image of the intruder attached. Voila! Just like that you’re done.

Yes that is literally how easy it is to build a smart security system of your own. The FPS was around 7. You can choose to comment out the imshow lines which will improve the FPS considerably.

Thanks for reading! Code up on my Github.

--

--