Skip to content

Instantly share code, notes, and snippets.

@mrpjevans
Last active January 6, 2024 21:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrpjevans/9885e853b603ed046cbc5326b9942991 to your computer and use it in GitHub Desktop.
Save mrpjevans/9885e853b603ed046cbc5326b9942991 to your computer and use it in GitHub Desktop.
Installation process for facial recognition dependancies

Step 1: Install dependancies

sudo apt -y update && sudo apt -y full-upgrade
sudo apt install build-essential \
    cmake \
    gfortran \
    git \
    wget \
    curl \
    graphicsmagick \
    libgraphicsmagick1-dev \
    libatlas-base-dev \
    libavcodec-dev \
    libavformat-dev \
    libboost-all-dev \
    libgtk2.0-dev \
    libjpeg-dev \
    liblapack-dev \
    libswscale-dev \
    pkg-config \
    python3-dev \
    python3-numpy \
    python3-pip \
    zip \
    python3-picamera

Step 2: Updates

sudo pip3 install --upgrade picamera[array]

Step 3: Increase the swap file size so we can build dlib

sudo nano /etc/dphys-swapfile

Find CONF_SWAPSIZE and change its value from 100 to 1024. Save and exit then run this command:

sudo /etc/init.d/dphys-swapfile restart

Step 4: Build and install dlib

cd
git clone -b 'v19.6' --single-branch https://github.com/davisking/dlib.git
cd ./dlib
sudo python3 setup.py install --compiler-flags "-mfpu=neon"

This may take a significant time to run (Raspberry Pi 4 took about 30 minutes)

Step 5: Revert the swap size

sudo nano /etc/dphys-swapfile

Find CONF_SWAPSIZE and change its value from 1024 to 100. Save and exit then run this command:

sudo /etc/init.d/dphys-swapfile restart

Step 6: Install face_recognition and examples

sudo pip3 install face_recognition

You're done!

@mrpjevans
Copy link
Author

Hi. Amazing that a Zero 2 can do this. Thanks for your great work and for taking the time to update this. Sadly, if I spent all my time keeping these tutorials up to date with OS releases, I'd never be able to do anything else!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment