Facial Recognition & Identification on Raspberry Pi
Facial recognition and identification will soon be playing a major role in our every day lives. The technology opens up a whole new world of possibilities, and applies to almost every aspect of our lives. Use cases of facial recognition/identification include security systems, authentication systems, personalised smart homes, and home care assistants.
What Will We Build?
This tutorial will help you to build a Raspberry Pi that allows you to train a Haarcascades model, detect recognised/unknown people, optionally monitor the camera in near realtime via a stream, and communicate with the IoT JumpWay sending sensor and warning messages that will allow your device to autonomously communicate with other IoT devices on your IoT JumpWay network.
This tutorial will use TechBubble Technologies IoT JumpWay Python MQTT Library for communication, OpenCV for computer vision, Motion to stream the webcame on a local port and a secure Nginx server so that the stream can be accessed safely from the outside world.
This example was our original version of TASS, since our move forward with more advanced computer vision libraries and frameworks, we decided to open up the source code.
- 3.4 or above
- Linux Motion
- Raspberry Pi.
- Linux Compatible Webcam
Before You Begin
There are a few tutorials that you should follow before beginning, especially if it is the first time you have followed any of our Raspberry Pi tutorials or if it is the first time you have used the TechBubble IoT JumpWay Developer Program. If this is the first time you have used the TechBubble IoT JumpWay in your IoT projects, you will require a developer account and some basics to be set up before you can start creating your IoT devices. Visit the following IoT JumpWay Developer Program Docs (5-10 minute read/setup) and check out the guides that take you through registration and setting up your Location Space, Zones, Devices and Applications (About 5 minutes read).
Preparing Your Raspberry Pi
Take some time to ensure your Raspberry Pi firmware and packages are up to date, and that your device is secure by following the Raspberry Pi 3 Preparation Doc tutorial.
Cloning The Repo
You will need to clone the TechBubble IoT JumpWay Raspberry Pi Examples repository to a location on your Raspberry Pi. Navigate to the directory you would like to download it to and issue the following commands, easiest is to download it to your home directory.
$ git clone https://github.com/TechBubbleTechnologies/IoT-JumpWay-RPI-Examples.git
Next you will need to navigate to the Computer-Vision directory and install the requirements, if you cloned the repository to your home directory, the commands would be as follows:
$ cd IoT-JumpWay-RPI-Examples/Computer-Vision/Python $ pip install --upgrade pip $ pip install -r requirements.txt
OpenCv needs to be installed, follow the Installing OpenCV On Your Raspberry Pi tutorial to accomplish this, this is the computer vision library we will be using.
Install Linux Motion
We will use Linux Motion to stream a live feed to a local port on the Raspberry Pi which OpenCv will connect to and read in the frames from the stream. To get Linux Motion set up, follow the Installing Linux Motion On Your Raspberry Pi tutorial.
There are some modifications to make here, in section 9 of the Motion tutorial, it tells you how to modify the directory where the media is saved, for this tutorial you should change that settings to:
Don’t forget to check out section 10 with regards to turning off the saving of images to save diskspace.
Set Up Domain Name & SSL
We like to make sure that we try to provide tutorials that will help people learn to create secure projects. For the video stream to work securely, you will need to set up a domain name that is pointed to your Raspberry Pi, you will also need to set up an SSL certificate to ensure that the server used for streaming the video is secure. The Setup Domain Name & SSL For Your Raspberry Pi tutorial explains how to do this, if in doubt ask your registrar or host to assist you. If you cloned this repository to your home directory, the paths that you need to use for your CSR and key generation in the following tutorial are:
Once you have received your signed crt.crt and ca.crt file from certificate authority, you need to upload them to: