Introduction: Face Detection on Raspberry Pi 4B in 3 Steps

In this Instructable we are going to perform face-detection on Raspberry Pi 4 with Shunya O/S using the Shunyaface Library. Shunyaface is a face recognition/detection library. The project aims to achieve fastest detection and recognition speed with low power hardware so enthusiasts like you can bring your dream AI projects to life faster .


Raspberry Pi 4B (any variant)

Raspberry Pi 4B compliant power supply

8GB or bigger micro SD card


micro-HDMI Cable



laptop or another computer to program the memory card

Step 1: Install Shunya OS on Raspberry Pi 4

You will need a laptop or computer with a micro SD card reader/adapter to load the micro SD card with Shunya OS.

Download Shunya OS from the official release site

Flashing Shunya OS on the SD-Card using the steps given here: Flashing Shunya OS on Raspberry Pi 4.

Insert micro SD card into Raspberry Pi 4.

Connect mouse & keyboard to Raspberry Pi 4.

Connect Monitor to Raspberry Pi 4 via micro-HDMI

Connect the power cable and Power ON the Raspberry Pi 4.

The Raspberry Pi 4 should boot up with Shunya OS.

Step 2: Install Shunyaface

Shunyaface is a face detection/recognition library for all boards supported by Shunya OS.

To install Shunyaface we need to connect it to the wifi

1. Connect to the wifi using the command:

$ sudo nmtui

2. Installing shunyaface and cmake is easy, run the following commands:

$ sudo apt update

$ sudo apt install shunyaface cmake

Step 3: Example Code and Output

In the above code, an image is read using the imread function. This frame is passed to the detect function which returns a bounding box on the face and also plots the points on the endpoints of the lips and the centre of the eyes.

Download the code along with the necessary files given below and Untar the files using the commands given below:

$ tar -xvzf sample-facedetect.tar.gz

$ cd sample-facedetect

Compile it using the command

$ ./

Run it using the command

$ ./build/facedetect

This will show you an image with detected face.

Write your own code and compile

1. Edit src/facedetect-sample.cpp file and add your code there.

2. then run this command to compile and build binary

$ ./

3. Run it using the command

$ ./build/facedetect

Conclusion: Shunyaface can help you detect or recognize a face in a few lines of codes. If you like this tutorial please like it, share and also star our github repository given here