• Sabina Pokhrel

Real-time Face Detection on Raspberry Pi

Updated: Dec 21, 2019

A step-by-step guide to implement real-time face detection on a Raspberry Pi running 24 frames per second

In this post, i will guide you through a step-by-step process of implementing a real-time face detection on a Raspberry Pi, running 24 frames per second on a single core.

In this post, I will guide you through a step-by-step process of implementing a real-time face detection on a Raspberry Pi, running 24 frames per second on a single core.

For the face detection, I will use Xailient FaceSDK.

Step 1: Install Python 3.7.3

Raspbian Buster comes with Python 3.7.3 preinstalled, so there is no need to explicitly install Python 3.7.3. To confirm, use the following command to see what version of Python is installed in your Raspberry Pi.

python --version

Step 2: Install tflite for Python 3.7

To install tflite for Python 3.7, enter following pip3 install command in your terminal.

pip3 install https://dl.google.com/coral/python/tflite_runtime-1.14.0-cp37-cp37m-linux_armv7l.whl

Step 3: Install OpenCV

Install OpenCV if it is not already installed. You can either use apt install or pip3 install OpenCV on your Raspberry Pi.

sudo apt install -y python3-opencv


pip3 install opencv-python

Step 4: Download Xailient FaceSDK and Unzip

Go to Xailient SDK page and register as a new user and login.

Go to SDK tab, where you will find instructions for downloading and installing Face SDK.

For Raspberry Pi 3B+, download the ARM32 version of the SDK. You can either open the link from your Raspberry Pi’s browser to download it directly to it or you can use the following wget command:

wget -O sdk.tar.gz "SDK Link"

Unzip the downloaded FaceSDK.

Step 5: Add Shared Library to Path

This is required as the library depends on some dynamically loaded shared Libraries.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$<Python_SDK path/Shared_arm32>

You can add library path to bashrc script so that you dont need to export everytime you login.

echo “export LD_LIBRARY_PATH=$LD_LIBRABRY_PATH:$<pathofSDK>/Shared_arm32” >> .bashrc

Step 6: Download config file

From the Xailient SDK page, download the config file by either opening the link from your Raspberry Pi’s browser to or using the following wget command:

wget -O config.json "Config Link"

Copy the config.json file into the FaceSDK folder.

Step 7: Install Xailient FaceSDK

To install the Xailient FaceSDK, run the Install.shfile that is inside the SDK folder. Go to the FaceSDK folder from your terminal and run the following command: 


For more details on the installation process, you can refer to the Readme file that comes along with the FaceSDK.

Step 8: Run sample Face Detection code

The FaceSDK comes with sample code that demonstrates how to use and interact with the Xailient Face Detector Python library.

Go to samples folder and run the picam_streaming_demo.py script to run real-time face detection.

You now have a real-time face detection running on a Raspberry Pi.

Found this post useful? Leave your thoughts as comments below.

More stories:

Integrate Face Detection on your App

Challenges of Running Deep Learning Computer Vision on Computationally Limited Devices

Struggles of Running Object Detection on a Raspberry Pi

You Need to Move from Cloud Computing to Edge Computing Now!

Xailient is commercializing breakthrough university research in Artificial Intelligence and Machine Learning. Our technology dramatically reduces the costs of data transmission, storage, and computation associated with extracting useful information from real-time video by processing the way humans think.


2,352 views0 comments

Recent Posts

See All