Facial Recognition & Identification on Raspberry Pi

Introduction

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.

facial-recognition-identification-on-raspberry-pi

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.

Python Versions

  • 2.7
  • 3.4 or above

Software Requirements

  • Jessie
  • Linux Motion
  • Nginx

Hardware requirements

hardware

  • 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

Install Requirements

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

Install OpenCV

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:

/home/YOURUSERNAME/IoT-JumpWay-RPI-Examples/Computer-Vision/Python/media

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:

    /etc/nginx/key.key

and

    /etc/nginx/csr.csr 

Once you have received your signed crt.crt and ca.crt file from certificate authority, you need to upload them to:

    /etc/nginx/ca.crt

and

    /etc/nginx/crt.crt 

 Read More: Facial Recognition & Identification on Raspberry Pi


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top