Skip to content

Instantly share code, notes, and snippets.

@mrpjevans
Last active May 4, 2022 12:41
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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!

@Dweblenod
Copy link

Dweblenod commented Aug 22, 2021

Hi there I am very much unfamiliar with what I am doing. Trying to nab these dependencies for a facial recognition project as recommended by the raspberry pi hackspace tutorial. Im getting several errors running the first command in the raspberry pi terminal: "Package [cmake/libgtk2.0-dev/gfortran] is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source". Then it goes on to say that several packages either have no installation candidate or cannot be located. Any comments/recommendations?

@mrpjevans
Copy link
Author

Sorry to hear this. I'll have to go through and try and find out what's changed.

@mrpjevans
Copy link
Author

Apologies for my delay in responding. I've tested this now and an initial step is missing. Before running the huge install command, make sure you run...

sudo apt -y update && sudo apt -y full-upgrade

This will ensure your repositories are up-to-date.

@Dweblenod
Copy link

Thank you so much! I will try this out

@Dweblenod
Copy link

I got up to stage 4 with this. When running the line "sudo python3 setup..." it said
running install running bdist_egg running build error: Cannot find cmake, ensure it is installed and in the path. You can install cmake using the instructions at https://cmake.org/install/ You can also specify its path with --cmake parameter

I will try messing around with it for a bit

@mrpjevans
Copy link
Author

Try
sudo apt install build-essential
Then try again

@chenyinhao98
Copy link

Also stucked on step 4, says "no module named 'distro' in the error message when running "sudo python3 setup.py install..." line.
Tried to install distro package but still doesn't work.
Messing around right now

@chenyinhao98
Copy link

ed0535a0f534fe5c2ef02fe62af079f

@mrpjevans
Copy link
Author

You need to install it as root, so...
sudo pip3 install distro

@Dweblenod
Copy link

Thank you so much for the help so far! I ran the "sudo apt install build-essential" line before the rest but at the fourth step I came up with the same error at the end. At "sudo nano /etc/dphys-swapfile" I assume I am saving correctly because I saw the changed value I made the first time around but perhaps I am still making a mistake somehow, somewhere

@mrpjevans
Copy link
Author

Try explicitly installing cmake:
sudo apt install cmake
And try again

@Dweblenod
Copy link

I got farther but a bunch of warnings and errors popped up. At the end it says Boost python library was not found and cmake configuration failed

Copy link

ghost commented Nov 13, 2021

I am also stuck at step 4 with the sudo python3 setup.py install --compiler-flags "-mfpu=neon" command.
I am getting an AttributeError: 'Thread' object has no attribute 'isAlive'
Any assistance would be appreciated.
IMG_5390

@mr-douglas
Copy link

mr-douglas commented Dec 15, 2021

Should there be an additional \ in the second-to-last line of the install step, ie:

python3-pip \
zip
python3-picamera

Should be

python3-pip \
zip \
python3-picamera

@mrpjevans
Copy link
Author

Thanks for pointing that out mr-douglas

@polyphonic13
Copy link

@DillonMcCardell did you ever get past the 'Thread' object has no attribute 'isAlive' error? I am stuck there as well.

@mrpjevans
Copy link
Author

@polyphonic13 Try step 4 but omit

-b 'v19.6'

From the git clone command.

@polyphonic13
Copy link

@DillonMcCardell thanks for the response. I ended up using a different solution and got it working. Go to know you fixed yours though!

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