- Building a Hardware Accelerated Facial Recognition System
For this project, you will need
- A Jetson Nano Developer Kit
- MicroSD Memory Card (32GB UHS-I minimum)
- 5V 4A Power Supply with 2.1mm DC barrel connector
- 2-pin Jumper
- Compatible camera: Logitech C270 USB Webcam
- USB cable (Micro-B to Type-A)
- Phyton3 and Jupyter Notebook installed in your computer
Lets Get Started!!!
Jetson Nano is a extremely powerful piece of hardware capable of accelerating Machine Learning projects. To build a facial recognition system, we need to install several Python libraries
From the Jetson Nano desktop, open up a Terminal window and run the following commands:
sudo apt-get update sudo apt-get install python3-pip cmake libopenblas-dev liblapack-dev libjpeg-dev
git clone https://github.com/JetsonHacksNano/installSwapfile ./installSwapfile/installSwapfile.sh
At this point, you need to reboot the system to make sure the swapfile is running.
Open up a terminal window and type in the following:
pip3 install numpy
Now we are ready to install dlib, a deep learning library created by Davis King that does the heavy lifting for the face_recognition library.
wget http://dlib.net/files/dlib-19.17.tar.bz2 tar jxvf dlib-19.17.tar.bz2 cd dlib-19.17 gedit dlib/cuda/cudnn_dlibapi.cpp
This will open up the file that we need to edit in a text editor. Search the file for the following line of code (which should be line 854)
forward_algo = forward_best_algo;
And comment it out by adding two slashes in front of it, so it looks like this:
//forward_algo = forward_best_algo;
Now save the file, close the editor, and go back to the Terminal window. Next, run these commands to compile and install dlib:
sudo python3 setup.py install
Finally, we need to install the face_recognition Python library. Do that with this command:
sudo pip3 install face_recognition
Lets Begin !!!
To get started, let’s download the code
wget -O doorcam.py tiny.cc/doorcam
Then you can run the code and try it out:
You’ll see a video window pop up on your desktop. Whenever a new person steps in front of the camera, it will register their face and start tracking how long they have been near your door. If the same person leaves and comes back more than 5 minutes later, it will register a new visit and track them again. You can hit ‘q’ on your keyboard at any time to exit.
The app will automatically save information about everyone it sees to a file called known_faces.dat. When you run the program again, it will use that data to remember previous visitors. If you want to clear out the list of known faces, just quit the program and delete that file.