Instantly share code, notes, and snippets.

Embed
What would you like to do?

Install dlib and face_recognition on a Raspberry Pi

Instructions tested with a Raspberry Pi 2 with an 8GB memory card. Probably also works fine on a Raspberry Pi 3.

Steps

Download the latest Raspbian Jessie Light image. Earlier versions of Raspbian won't work.

Write it to a memory card using Etcher, put the memory card in the RPi and boot it up.

Log in. Default username / password is pi / raspberry.

Set up Wifi (if you are using Wifi) according to the Raspberry Pi instructions.

Run sudo raspi-config and configure the basics:

  • Set up your keyboard layout (It defaults to a British keyboard layout)
  • Change default user password
  • Enable the Raspberry Pi camera (if you have one attached)
  • Configure gpu memory split under 'Advanced'. Set it up '16'.
  • Save changes and reboot.

Install required libraries with these commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential \
    cmake \
    gfortran \
    git \
    wget \
    curl \
    graphicsmagick \
    libgraphicsmagick1-dev \
    libatlas-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
sudo apt-get clean

Install the picamera python library with array support (if you are using a camera):

sudo apt-get install python3-picamera
sudo pip3 install --upgrade picamera[array]

Temporarily enable a larger swap file size (so the dlib compile won't fail due to limited memory):

sudo nano /etc/dphys-swapfile

< change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024 and save / exit nano >

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

Download and install dlib v19.6:

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

Install face_recognition:

sudo pip3 install face_recognition

Revert the swap file size change now that dlib is installed:

sudo nano /etc/dphys-swapfile

< change CONF_SWAPSIZE=1024 to CONF_SWAPSIZE=100 and save / exit nano >

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

Download the face recognition code examples:

git clone --single-branch https://github.com/ageitgey/face_recognition.git
cd ./face_recognition/examples
python3 facerec_on_raspberry_pi.py

Totally Optional: If you want a desktop GUI, install PIXEL:

sudo apt-get install --no-install-recommends xserver-xorg xinit raspberrypi-ui-mods
@tilda

This comment has been minimized.

Show comment
Hide comment
@tilda

tilda Apr 22, 2017

Additional note:

If you are installing PIXEL, you should probably up your memory split to 64. 16 will not give much responsiveness.

tilda commented Apr 22, 2017

Additional note:

If you are installing PIXEL, you should probably up your memory split to 64. 16 will not give much responsiveness.

@samiturki

This comment has been minimized.

Show comment
Hide comment
@samiturki

samiturki May 10, 2017

Hi,
Although I go through all your Rpi manual installation, at the end, when i try python3 facerec_on_raspberry_pi.py, I've got:
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera
self._camera = mo.MMALCamera()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in init
super(MMALCamera, self).init()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 633, in init
prefix="Failed to create MMAL component %s" % self.component_type)
File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.ril.camera': Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "lib/face_recognition/examples/facerec_on_raspberry_pi.py", line 16, in
camera = picamera.PiCamera()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 431, in init
self._init_camera(camera_num, stereo_mode, stereo_decimate)
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 460, in _init_camera
"Camera is not enabled. Try running 'sudo raspi-config' "
picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.

samiturki commented May 10, 2017

Hi,
Although I go through all your Rpi manual installation, at the end, when i try python3 facerec_on_raspberry_pi.py, I've got:
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera
self._camera = mo.MMALCamera()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in init
super(MMALCamera, self).init()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 633, in init
prefix="Failed to create MMAL component %s" % self.component_type)
File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.ril.camera': Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "lib/face_recognition/examples/facerec_on_raspberry_pi.py", line 16, in
camera = picamera.PiCamera()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 431, in init
self._init_camera(camera_num, stereo_mode, stereo_decimate)
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 460, in _init_camera
"Camera is not enabled. Try running 'sudo raspi-config' "
picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.

@QuentinCG

This comment has been minimized.

Show comment
Hide comment
@QuentinCG

QuentinCG May 10, 2017

@samiturki The error is quite clear, no?

PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.

https://www.raspberrypi.org/learning/getting-started-with-picamera/worksheet/

QuentinCG commented May 10, 2017

@samiturki The error is quite clear, no?

PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.

https://www.raspberrypi.org/learning/getting-started-with-picamera/worksheet/

@QuentinCG

This comment has been minimized.

Show comment
Hide comment
@QuentinCG

QuentinCG May 18, 2017

This is very very slow on my RPi3:

  • 20-30sec to initialize the facerec_on_raspberry_pi.py example <-- This is fine for me
  • 5-10sec to check each image <-- This is problematic

Is there a way to check images faster? (it is not real time at all... 1-2sec would be ok but 5-10sec is enormous)

QuentinCG commented May 18, 2017

This is very very slow on my RPi3:

  • 20-30sec to initialize the facerec_on_raspberry_pi.py example <-- This is fine for me
  • 5-10sec to check each image <-- This is problematic

Is there a way to check images faster? (it is not real time at all... 1-2sec would be ok but 5-10sec is enormous)

@jyurek

This comment has been minimized.

Show comment
Hide comment
@jyurek

jyurek May 19, 2017

I'd love to know if there's a good way to speed this up, too.

jyurek commented May 19, 2017

I'd love to know if there's a good way to speed this up, too.

@vchatterji

This comment has been minimized.

Show comment
Hide comment
@vchatterji

vchatterji Jun 9, 2017

@jyurek try http://vmlaker.github.io/mpipe/
Utilizing all 4 cores of the Pi via process pipelines
Plus smaller resolution of 1080p/3

vchatterji commented Jun 9, 2017

@jyurek try http://vmlaker.github.io/mpipe/
Utilizing all 4 cores of the Pi via process pipelines
Plus smaller resolution of 1080p/3

@dfsdsdwe

This comment has been minimized.

Show comment
Hide comment
@dfsdsdwe

dfsdsdwe Jun 22, 2017

recently installed dlib with face recognition following this guide on my raspberry pi3 and when i try and run example programmes i am getting the message:
'File "face-recognition.py", line 50, in <module
import dlib
ImportError: dynamic module does not define init function (initdlib)'
any idea what is causing this? Thanks

dfsdsdwe commented Jun 22, 2017

recently installed dlib with face recognition following this guide on my raspberry pi3 and when i try and run example programmes i am getting the message:
'File "face-recognition.py", line 50, in <module
import dlib
ImportError: dynamic module does not define init function (initdlib)'
any idea what is causing this? Thanks

@masoudr

This comment has been minimized.

Show comment
Hide comment
@masoudr

masoudr Jun 26, 2017

Thanks, @vchatterji but can you explain a little more about how to use along with face_recognition examples?

masoudr commented Jun 26, 2017

Thanks, @vchatterji but can you explain a little more about how to use along with face_recognition examples?

@tedm

This comment has been minimized.

Show comment
Hide comment
@tedm

tedm Jul 17, 2017

how would one add biden.jpg (which is already there) as the 'match[1]' in the example?

tedm commented Jul 17, 2017

how would one add biden.jpg (which is already there) as the 'match[1]' in the example?

@roei03jen

This comment has been minimized.

Show comment
Hide comment
@roei03jen

roei03jen Jul 23, 2017

Good evening I have a problem when I install dlib v19.4: it always stop at 93% is that an error or Do i really need a really long patience thanks for the reply

roei03jen commented Jul 23, 2017

Good evening I have a problem when I install dlib v19.4: it always stop at 93% is that an error or Do i really need a really long patience thanks for the reply

@cimzar

This comment has been minimized.

Show comment
Hide comment
@cimzar

cimzar Jul 26, 2017

is there any way to send an output signal to one of the gpio pins on raspberrypi3 when there is a match in a picture?

cimzar commented Jul 26, 2017

is there any way to send an output signal to one of the gpio pins on raspberrypi3 when there is a match in a picture?

@HenryCWoo

This comment has been minimized.

Show comment
Hide comment
@HenryCWoo

HenryCWoo Jul 26, 2017

@roei03jen Did you make sure to complete this step (make sure that you saved):

sudo nano /etc/dphys-swapfile

< change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024 and save / exit nano >

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

HenryCWoo commented Jul 26, 2017

@roei03jen Did you make sure to complete this step (make sure that you saved):

sudo nano /etc/dphys-swapfile

< change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024 and save / exit nano >

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

@fumufu

This comment has been minimized.

Show comment
Hide comment
@fumufu

fumufu Aug 1, 2017

It's working fine on a RPi 3. I tested it successfully following the instructions above.
But it's quite slow to output the result on a RPi3, compared with the one in a VM on an Intel i5 PC.
So I am not sure if I can use the picamera to trace the face real-timely.

fumufu commented Aug 1, 2017

It's working fine on a RPi 3. I tested it successfully following the instructions above.
But it's quite slow to output the result on a RPi3, compared with the one in a VM on an Intel i5 PC.
So I am not sure if I can use the picamera to trace the face real-timely.

@CosminNechifor

This comment has been minimized.

Show comment
Hide comment
@CosminNechifor

CosminNechifor Aug 16, 2017

When I try to install face_recognition using:

sudo pip3 install face_recognition

I get this:

Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/response.py", line 186, in read
data = self._fp.read(amt)
File "/usr/lib/python3.4/http/client.py", line 500, in read
return super(HTTPResponse, self).read(amt)
File "/usr/lib/python3.4/http/client.py", line 539, in readinto
n = self.fp.readinto(b)
File "/usr/lib/python3.4/socket.py", line 371, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.4/ssl.py", line 617, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python3/dist-packages/pip/req.py", line 1198, in prepare_files
do_download,
File "/usr/lib/python3/dist-packages/pip/req.py", line 1376, in unpack_url
self.session,
File "/usr/lib/python3/dist-packages/pip/download.py", line 572, in unpack_http_url
download_hash = _download_url(resp, link, temp_location)
File "/usr/lib/python3/dist-packages/pip/download.py", line 433, in _download_url
for chunk in resp_read(4096):
File "/usr/lib/python3/dist-packages/pip/download.py", line 421, in resp_read
chunk_size, decode_content=False):
File "/usr/lib/python3/dist-packages/urllib3/response.py", line 256, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/lib/python3/dist-packages/urllib3/response.py", line 201, in read
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.

Storing debug log for failure in /home/pi/.pip/pip.log

Can someone give me a hint?

UPDATE: it worked after I installed once again dlib

CosminNechifor commented Aug 16, 2017

When I try to install face_recognition using:

sudo pip3 install face_recognition

I get this:

Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/response.py", line 186, in read
data = self._fp.read(amt)
File "/usr/lib/python3.4/http/client.py", line 500, in read
return super(HTTPResponse, self).read(amt)
File "/usr/lib/python3.4/http/client.py", line 539, in readinto
n = self.fp.readinto(b)
File "/usr/lib/python3.4/socket.py", line 371, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.4/ssl.py", line 617, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python3/dist-packages/pip/req.py", line 1198, in prepare_files
do_download,
File "/usr/lib/python3/dist-packages/pip/req.py", line 1376, in unpack_url
self.session,
File "/usr/lib/python3/dist-packages/pip/download.py", line 572, in unpack_http_url
download_hash = _download_url(resp, link, temp_location)
File "/usr/lib/python3/dist-packages/pip/download.py", line 433, in _download_url
for chunk in resp_read(4096):
File "/usr/lib/python3/dist-packages/pip/download.py", line 421, in resp_read
chunk_size, decode_content=False):
File "/usr/lib/python3/dist-packages/urllib3/response.py", line 256, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/lib/python3/dist-packages/urllib3/response.py", line 201, in read
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.

Storing debug log for failure in /home/pi/.pip/pip.log

Can someone give me a hint?

UPDATE: it worked after I installed once again dlib

@HarveyBrezinaConniffe

This comment has been minimized.

Show comment
Hide comment
@HarveyBrezinaConniffe

HarveyBrezinaConniffe Aug 23, 2017

When I try running sudo python3 setup.py install --compiler-flags "-mpfu=neon", I get this error: error: option --compiler-flags not recognized, I also find no mention of this option in the setup.py file?

HarveyBrezinaConniffe commented Aug 23, 2017

When I try running sudo python3 setup.py install --compiler-flags "-mpfu=neon", I get this error: error: option --compiler-flags not recognized, I also find no mention of this option in the setup.py file?

@donaldjansen

This comment has been minimized.

Show comment
Hide comment
@donaldjansen

donaldjansen Aug 24, 2017

has anyone got this to work on windows ?

donaldjansen commented Aug 24, 2017

has anyone got this to work on windows ?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 26, 2017

When I try running sudo python3 setup.py install --compiler-flags "-mpfu=neon", I get this error: error: option --compiler-flags not recognized, I also find no mention of this option in the setup.py file?

ghost commented Aug 26, 2017

When I try running sudo python3 setup.py install --compiler-flags "-mpfu=neon", I get this error: error: option --compiler-flags not recognized, I also find no mention of this option in the setup.py file?

@CosminNechifor

This comment has been minimized.

Show comment
Hide comment
@CosminNechifor

CosminNechifor Aug 26, 2017

Try installing dlib using:

sudo pip3 install dlib

It took me ~20 min, because I have a bad internet connection. And the face_recognition lib works fine.

CosminNechifor commented Aug 26, 2017

Try installing dlib using:

sudo pip3 install dlib

It took me ~20 min, because I have a bad internet connection. And the face_recognition lib works fine.

@jatinkrmalik

This comment has been minimized.

Show comment
Hide comment
@jatinkrmalik

jatinkrmalik Aug 30, 2017

Can anyone share some benchmarks like what FPS are they able to achieve with this? And on what resolution?

jatinkrmalik commented Aug 30, 2017

Can anyone share some benchmarks like what FPS are they able to achieve with this? And on what resolution?

@skerit

This comment has been minimized.

Show comment
Hide comment
@skerit

skerit Sep 7, 2017

The "mpfu" error is because it's a typo. It should be -mfpu=neon. F before p.

It'll compile without any problems then, but I haven't really noticed any performance boost.

skerit commented Sep 7, 2017

The "mpfu" error is because it's a typo. It should be -mfpu=neon. F before p.

It'll compile without any problems then, but I haven't really noticed any performance boost.

@MedKarim-BALI

This comment has been minimized.

Show comment
Hide comment
@MedKarim-BALI

MedKarim-BALI Sep 13, 2017

i try with mfpu=neon and it works
error: unrecognized command line option ‘-mpfu=neon’;
did you mean
==> ‘-mfpu=neon’?

MedKarim-BALI commented Sep 13, 2017

i try with mfpu=neon and it works
error: unrecognized command line option ‘-mpfu=neon’;
did you mean
==> ‘-mfpu=neon’?

@ss6054

This comment has been minimized.

Show comment
Hide comment
@ss6054

ss6054 Oct 14, 2017

Can it run at Raspberry Pi model B+?

ss6054 commented Oct 14, 2017

Can it run at Raspberry Pi model B+?

@noblekoshy

This comment has been minimized.

Show comment
Hide comment
@noblekoshy

noblekoshy Oct 19, 2017

Would dlib benefit from VFPV3 optimization in addition to NEON?

noblekoshy commented Oct 19, 2017

Would dlib benefit from VFPV3 optimization in addition to NEON?

@mecastro

This comment has been minimized.

Show comment
Hide comment
@mecastro

mecastro Oct 24, 2017

I'm having a problem installing the gui on raspberry pi pls help asap

mecastro commented Oct 24, 2017

I'm having a problem installing the gui on raspberry pi pls help asap

@HsalF-esereveR

This comment has been minimized.

Show comment
Hide comment
@HsalF-esereveR

HsalF-esereveR Nov 9, 2017

Wondering if it can work with an USB camera ?

HsalF-esereveR commented Nov 9, 2017

Wondering if it can work with an USB camera ?

@osmadja

This comment has been minimized.

Show comment
Hide comment
@osmadja

osmadja Nov 9, 2017

Yes, it is working with usb Camera on the PI 3. I currently use a logitech c920 and it is working. But even reducing image resolution to 320x240, the performance is bad : the face detection is 3s / frame and 1.2 to compute encodings. So it is more than 4s per frame. Anyone managed better performance ? using the PI 3 gpu ?

osmadja commented Nov 9, 2017

Yes, it is working with usb Camera on the PI 3. I currently use a logitech c920 and it is working. But even reducing image resolution to 320x240, the performance is bad : the face detection is 3s / frame and 1.2 to compute encodings. So it is more than 4s per frame. Anyone managed better performance ? using the PI 3 gpu ?

@HsalF-esereveR

This comment has been minimized.

Show comment
Hide comment
@HsalF-esereveR

HsalF-esereveR Nov 13, 2017

@osmadja. 👍

cd ./face_recognition/examples

python3 facerec_from_webcam_faster.py

I was running this code with a USB webcam and got an error.

So I want to do a real-time face recognition (As shown in this link -> https://cloud.githubusercontent.com/assets/896692/24430398/36f0e3f0-13cb-11e7-8258-4d0c9ce1e419.gif ) with a USB webcam (Logitech QuickCam Pro 9000) that supports 1600x1200 resolution

Are you using it for real-time the same way like I do ?

HsalF-esereveR commented Nov 13, 2017

@osmadja. 👍

cd ./face_recognition/examples

python3 facerec_from_webcam_faster.py

I was running this code with a USB webcam and got an error.

So I want to do a real-time face recognition (As shown in this link -> https://cloud.githubusercontent.com/assets/896692/24430398/36f0e3f0-13cb-11e7-8258-4d0c9ce1e419.gif ) with a USB webcam (Logitech QuickCam Pro 9000) that supports 1600x1200 resolution

Are you using it for real-time the same way like I do ?

@cmsfw-github

This comment has been minimized.

Show comment
Hide comment
@cmsfw-github

cmsfw-github Dec 2, 2017

Hi! When I try to run this command: sudo python3 setup.py install --compiler-flags '-mpfu=neon' on raspberrypi 3b,I get errors as follows:

Checking .pth file support in /usr/local/lib/python3.4/dist-packages/
/usr/bin/python3 -E -c pass
TEST PASSED: /usr/local/lib/python3.4/dist-packages/ appears to support .pth files
running bdist_egg
running build
Detected Python architecture: 32bit
Detected platform: linux
Removing build directory /usr/local/dlib/./tools/python/build
Configuring cmake ...
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- broken
CMake Error at /usr/share/cmake-3.0/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/c++" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec3550236372/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3550236372.dir/build.make
CMakeFiles/cmTryCompileExec3550236372.dir/build
make[1]: Entering directory
'/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o
/usr/bin/c++ -mpfu=neon -o
CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o -c
/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: error: unrecognized command line option ‘-mpfu=neon’
CMakeFiles/cmTryCompileExec3550236372.dir/build.make:57: recipe for target
'CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o' failed
make[1]: ***
[CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o] Error 1
make[1]: Leaving directory
'/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec3550236372/fast' failed
make: *** [cmTryCompileExec3550236372/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
-- Configuring incomplete, errors occurred!
See also "/usr/local/dlib/tools/python/build/CMakeFiles/CMakeOutput.log".
See also "/usr/local/dlib/tools/python/build/CMakeFiles/CMakeError.log".
error: cmake configuration failed!

What should I do to correct these errors? Thank you for your reply!****

cmsfw-github commented Dec 2, 2017

Hi! When I try to run this command: sudo python3 setup.py install --compiler-flags '-mpfu=neon' on raspberrypi 3b,I get errors as follows:

Checking .pth file support in /usr/local/lib/python3.4/dist-packages/
/usr/bin/python3 -E -c pass
TEST PASSED: /usr/local/lib/python3.4/dist-packages/ appears to support .pth files
running bdist_egg
running build
Detected Python architecture: 32bit
Detected platform: linux
Removing build directory /usr/local/dlib/./tools/python/build
Configuring cmake ...
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- broken
CMake Error at /usr/share/cmake-3.0/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/c++" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec3550236372/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3550236372.dir/build.make
CMakeFiles/cmTryCompileExec3550236372.dir/build
make[1]: Entering directory
'/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o
/usr/bin/c++ -mpfu=neon -o
CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o -c
/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: error: unrecognized command line option ‘-mpfu=neon’
CMakeFiles/cmTryCompileExec3550236372.dir/build.make:57: recipe for target
'CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o' failed
make[1]: ***
[CMakeFiles/cmTryCompileExec3550236372.dir/testCXXCompiler.cxx.o] Error 1
make[1]: Leaving directory
'/usr/local/dlib/tools/python/build/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec3550236372/fast' failed
make: *** [cmTryCompileExec3550236372/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
-- Configuring incomplete, errors occurred!
See also "/usr/local/dlib/tools/python/build/CMakeFiles/CMakeOutput.log".
See also "/usr/local/dlib/tools/python/build/CMakeFiles/CMakeError.log".
error: cmake configuration failed!

What should I do to correct these errors? Thank you for your reply!****

@myorulmaz

This comment has been minimized.

Show comment
Hide comment
@myorulmaz

myorulmaz Dec 2, 2017

RuntimeError: Error deserializing object of type short

how can i fix this error, can you help me

myorulmaz commented Dec 2, 2017

RuntimeError: Error deserializing object of type short

how can i fix this error, can you help me

@Chronoculars

This comment has been minimized.

Show comment
Hide comment
@Chronoculars

Chronoculars Dec 4, 2017

When I run ¨sudo pip3 install face-recognition¨, I recieve this rather long error:

Exception:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 417, in wrap_socket
cnx.do_handshake()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1426, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1149, in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 350, in _make_request
self._validate_conn(conn)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 837, in validate_conn
conn.connect()
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connection.py", line 323, in connect
ssl_context=context)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/ssl
.py", line 324, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 421, in wrap_socket
raise timeout('select timed out')
socket.timeout: select timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 594, in urlopen
chunked=chunked)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 353, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 313, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='www.piwheels.hostedpi.com', port=443): Read timed out. (read timeout=15)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3/dist-packages/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

Does anyone know how to fix this?
Thanks!

Chronoculars commented Dec 4, 2017

When I run ¨sudo pip3 install face-recognition¨, I recieve this rather long error:

Exception:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 417, in wrap_socket
cnx.do_handshake()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1426, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1149, in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 350, in _make_request
self._validate_conn(conn)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 837, in validate_conn
conn.connect()
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connection.py", line 323, in connect
ssl_context=context)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/ssl
.py", line 324, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 421, in wrap_socket
raise timeout('select timed out')
socket.timeout: select timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 594, in urlopen
chunked=chunked)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 353, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 313, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='www.piwheels.hostedpi.com', port=443): Read timed out. (read timeout=15)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3/dist-packages/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

Does anyone know how to fix this?
Thanks!

@melvudin

This comment has been minimized.

Show comment
Hide comment
@melvudin

melvudin Dec 9, 2017

@cmsfw-github
Use -mfpu instead of -mpfu

melvudin commented Dec 9, 2017

@cmsfw-github
Use -mfpu instead of -mpfu

@cmsfw-github

This comment has been minimized.

Show comment
Hide comment
@cmsfw-github

cmsfw-github Dec 12, 2017

@melvudin
Thank you! I‘ve solved this problem successfully!

cmsfw-github commented Dec 12, 2017

@melvudin
Thank you! I‘ve solved this problem successfully!

@ageitgey

This comment has been minimized.

Show comment
Hide comment
@ageitgey

ageitgey Dec 13, 2017

@melvudin doh typo, thanks!

Owner

ageitgey commented Dec 13, 2017

@melvudin doh typo, thanks!

@Alex-Ladron

This comment has been minimized.

Show comment
Hide comment
@Alex-Ladron

Alex-Ladron Dec 13, 2017

After installing and running on "(cv)" to access the webcam, I keep getting the following error:

File "facerec_from_webcam.py", line 15, in
obama_image = face_recognition.load_image_file("obama.jpg")
AttributeError: module 'face_recognition' has no attribute 'load_image_file'

Appreciate any help! Thank you!

Alex-Ladron commented Dec 13, 2017

After installing and running on "(cv)" to access the webcam, I keep getting the following error:

File "facerec_from_webcam.py", line 15, in
obama_image = face_recognition.load_image_file("obama.jpg")
AttributeError: module 'face_recognition' has no attribute 'load_image_file'

Appreciate any help! Thank you!

@kkeyan

This comment has been minimized.

Show comment
Hide comment
@kkeyan

kkeyan Jan 14, 2018

ImportError: No module named face_recognition on raspberry pi

kkeyan commented Jan 14, 2018

ImportError: No module named face_recognition on raspberry pi

@vrushang25

This comment has been minimized.

Show comment
Hide comment
@vrushang25

vrushang25 Jan 18, 2018

how to install it for python 2.7 in raspberry pi 3-B?

vrushang25 commented Jan 18, 2018

how to install it for python 2.7 in raspberry pi 3-B?

@liguilini

This comment has been minimized.

Show comment
Hide comment
@liguilini

liguilini Jan 20, 2018

Hi! When I try to run python3 ./face_recognition/examples/facerec_on_raspberry_pi.py I get exception occurred. how to fix it?
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 16, in
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./Documents/facerecognition/face_recognition/examples/facerec_on_raspberry_pi.py", line 9, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 3, in
import scipy.misc
File "/usr/local/lib/python3.5/dist-packages/scipy/init.py", line 61, in
from numpy import show_config as show_numpy_config
File "/usr/local/lib/python3.5/dist-packages/numpy/init.py", line 142, in
from . import add_newdocs
File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 26, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

liguilini commented Jan 20, 2018

Hi! When I try to run python3 ./face_recognition/examples/facerec_on_raspberry_pi.py I get exception occurred. how to fix it?
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 16, in
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./Documents/facerecognition/face_recognition/examples/facerec_on_raspberry_pi.py", line 9, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 3, in
import scipy.misc
File "/usr/local/lib/python3.5/dist-packages/scipy/init.py", line 61, in
from numpy import show_config as show_numpy_config
File "/usr/local/lib/python3.5/dist-packages/numpy/init.py", line 142, in
from . import add_newdocs
File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 26, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

@EnglishAlex

This comment has been minimized.

Show comment
Hide comment
@EnglishAlex

EnglishAlex Jan 21, 2018

I ran sudo apt-get clean and git clean -xdf it didn't help.
I searched for errors related to libf77blas.so.3 - found one reference to installing another library.. I ran sudo apt-get install libatlas-base-dev and this fixed the "Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory" error.

EnglishAlex commented Jan 21, 2018

I ran sudo apt-get clean and git clean -xdf it didn't help.
I searched for errors related to libf77blas.so.3 - found one reference to installing another library.. I ran sudo apt-get install libatlas-base-dev and this fixed the "Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory" error.

@liguilini

This comment has been minimized.

Show comment
Hide comment
@liguilini

liguilini Jan 22, 2018

@EnglishAlex Thank you.I run sudo apt-get install libatlas but it didn't help.When i run sudo apt-get install libatlas-base-dev.I‘ve solved this problem successfully.

liguilini commented Jan 22, 2018

@EnglishAlex Thank you.I run sudo apt-get install libatlas but it didn't help.When i run sudo apt-get install libatlas-base-dev.I‘ve solved this problem successfully.

@mthd98

This comment has been minimized.

Show comment
Hide comment
@mthd98

mthd98 Feb 4, 2018

hi i need help when i import face_recognition it give me this error
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 4, in
import dlib
ImportError: libatlas.so.3: cannot open shared object file: No such file or directory

mthd98 commented Feb 4, 2018

hi i need help when i import face_recognition it give me this error
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 4, in
import dlib
ImportError: libatlas.so.3: cannot open shared object file: No such file or directory

@superleggera24

This comment has been minimized.

Show comment
Hide comment
@superleggera24

superleggera24 Feb 13, 2018

After 24 hours following this tutorial I finally got it working. I got errors from numpy, int64 errors and so on. What did it for me, was this:

  1. After downloading a recent raspbian img, instantly updating python to 3.6
  2. From then on every command with python3 in it, you should use python3.6 instead
  3. Then there is dlib. This tutorial uses 19.6 in the example codes, but the setup.py requirements say >= 19.7. This means your freshly installed dlib is instantly removed. Yes, I know. It took very long for me too. The first command you should change 19.6 to 19.9.
  4. Also very important: dont use pip3, but use pip3.6

I hope this helped any of you, I know it sure did help me.

superleggera24 commented Feb 13, 2018

After 24 hours following this tutorial I finally got it working. I got errors from numpy, int64 errors and so on. What did it for me, was this:

  1. After downloading a recent raspbian img, instantly updating python to 3.6
  2. From then on every command with python3 in it, you should use python3.6 instead
  3. Then there is dlib. This tutorial uses 19.6 in the example codes, but the setup.py requirements say >= 19.7. This means your freshly installed dlib is instantly removed. Yes, I know. It took very long for me too. The first command you should change 19.6 to 19.9.
  4. Also very important: dont use pip3, but use pip3.6

I hope this helped any of you, I know it sure did help me.

@sylveryte

This comment has been minimized.

Show comment
Hide comment
@sylveryte

sylveryte Feb 19, 2018

@superleggera24
Thank you, It helped, I sucessfully installed face_recognition on raspbian lite. With "python3.6 -m pip ...". I installed both dlib and face_recognition with pip. It takes a lot of time around 2-3 hours for all modules[dlib,scipy,numpy,pillow,click,face_recognition.

sylveryte commented Feb 19, 2018

@superleggera24
Thank you, It helped, I sucessfully installed face_recognition on raspbian lite. With "python3.6 -m pip ...". I installed both dlib and face_recognition with pip. It takes a lot of time around 2-3 hours for all modules[dlib,scipy,numpy,pillow,click,face_recognition.

@wljgithub

This comment has been minimized.

Show comment
Hide comment
@wljgithub

wljgithub Mar 5, 2018

thanks,i occur the same error :
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.
fortunately,I fix it after i ran " sudo apt-get install libatlas-base-dev "
thank you very much,guys

wljgithub commented Mar 5, 2018

thanks,i occur the same error :
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.
fortunately,I fix it after i ran " sudo apt-get install libatlas-base-dev "
thank you very much,guys

@IarveJ

This comment has been minimized.

Show comment
Hide comment
@IarveJ

IarveJ Mar 8, 2018

So Im trying to install this on a relatively new board the PYNQ board by Xilinx. Using these same instructions it is possible, however the install takes a very long time to :
Running setup.py install for dlib ...

Is this normal and should be expected?

IarveJ commented Mar 8, 2018

So Im trying to install this on a relatively new board the PYNQ board by Xilinx. Using these same instructions it is possible, however the install takes a very long time to :
Running setup.py install for dlib ...

Is this normal and should be expected?

@mostafazaghlol

This comment has been minimized.

Show comment
Hide comment
@mostafazaghlol

mostafazaghlol Mar 12, 2018

I face a problem with this Line

``sudopython3 setup.py install --compiler-flags "-mfpu=neon"

It take from 4 to 6 hour to finish and when it reach 98 % it stopped with error ? is there any second choose ?

mostafazaghlol commented Mar 12, 2018

I face a problem with this Line

``sudopython3 setup.py install --compiler-flags "-mfpu=neon"

It take from 4 to 6 hour to finish and when it reach 98 % it stopped with error ? is there any second choose ?

@diegozaks

This comment has been minimized.

Show comment
Hide comment
@diegozaks

diegozaks Mar 19, 2018

Been about 16 hours, on 96% on a RPi Zero W... Waiting, this is my 5th attempt.
Had to use
< change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=512 and save / exit nano >

since 1024 would just error "ran out of memory" at around 40%. Probably because the Zero has only 512mb of ram.

Will update if it works this time. I've already ordered a Pi3 B+, looking forward to that one if this does not work.

Update: build failed at 96%, ran out of memory.

Update 2: completed build
Tried again, make sure GPU memory split is set to 16, not 64"
Got it working, has to reinstall numpy afterward since I was getting this error.
libf77blas.so.3: cannot open shared object file: No such file or directory

It now works. The Pi Zero is as slow as advertised. The "find_faces_in_picture.py" takes about 60 seconds. Looking at ways to optimize while my Pi 3 B+ arrives.

diegozaks commented Mar 19, 2018

Been about 16 hours, on 96% on a RPi Zero W... Waiting, this is my 5th attempt.
Had to use
< change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=512 and save / exit nano >

since 1024 would just error "ran out of memory" at around 40%. Probably because the Zero has only 512mb of ram.

Will update if it works this time. I've already ordered a Pi3 B+, looking forward to that one if this does not work.

Update: build failed at 96%, ran out of memory.

Update 2: completed build
Tried again, make sure GPU memory split is set to 16, not 64"
Got it working, has to reinstall numpy afterward since I was getting this error.
libf77blas.so.3: cannot open shared object file: No such file or directory

It now works. The Pi Zero is as slow as advertised. The "find_faces_in_picture.py" takes about 60 seconds. Looking at ways to optimize while my Pi 3 B+ arrives.

@vinitvilla

This comment has been minimized.

Show comment
Hide comment
@vinitvilla

vinitvilla Mar 21, 2018

I face some problems when doing this operation: (python3 facerec_on_raspberry_pi.py)

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 16, in
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 9, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 3, in
import scipy.misc
File "/usr/local/lib/python3.5/dist-packages/scipy/init.py", line 61, in
from numpy import show_config as show_numpy_config
File "/usr/local/lib/python3.5/dist-packages/numpy/init.py", line 142, in
from . import add_newdocs
File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 26, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

KINDLY HELP

vinitvilla commented Mar 21, 2018

I face some problems when doing this operation: (python3 facerec_on_raspberry_pi.py)

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 16, in
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 9, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 3, in
import scipy.misc
File "/usr/local/lib/python3.5/dist-packages/scipy/init.py", line 61, in
from numpy import show_config as show_numpy_config
File "/usr/local/lib/python3.5/dist-packages/numpy/init.py", line 142, in
from . import add_newdocs
File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.5/dist-packages/numpy/core/init.py", line 26, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

KINDLY HELP

@neutralvibes

This comment has been minimized.

Show comment
Hide comment
@neutralvibes

neutralvibes Apr 20, 2018

For those looking to improve performance you need to install OpenBlas before compiling dlib. It does make things a bit faster if you do.

To install OpenBLAS

sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev

Important

As I found out painfully, OpenBLAS does help, but it will chew up your cores and cause days of head banging if you don't set the following environment variables in your shell before running any recognition.

export OPENBLAS_NUM_THREADS=1 
export OPENBLAS_MAIN_FREE=1

May the force be with you

neutralvibes commented Apr 20, 2018

For those looking to improve performance you need to install OpenBlas before compiling dlib. It does make things a bit faster if you do.

To install OpenBLAS

sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev

Important

As I found out painfully, OpenBLAS does help, but it will chew up your cores and cause days of head banging if you don't set the following environment variables in your shell before running any recognition.

export OPENBLAS_NUM_THREADS=1 
export OPENBLAS_MAIN_FREE=1

May the force be with you

@boomza19193

This comment has been minimized.

Show comment
Hide comment
@boomza19193

boomza19193 Apr 23, 2018

pi@raspberrypi:~ $ git clone -b 'v19.6' --single-branch https://github.com/davisking/dlib.git dlib/
Cloning into 'dlib'...
fatal: unable to access 'https://github.com/davisking/dlib.git/': GnuTLS recv error (-54): Error in the pull function.

How i solve this problem?

boomza19193 commented Apr 23, 2018

pi@raspberrypi:~ $ git clone -b 'v19.6' --single-branch https://github.com/davisking/dlib.git dlib/
Cloning into 'dlib'...
fatal: unable to access 'https://github.com/davisking/dlib.git/': GnuTLS recv error (-54): Error in the pull function.

How i solve this problem?

@netrosec

This comment has been minimized.

Show comment
Hide comment
@netrosec

netrosec May 10, 2018

Help!! Face_Recognition does not download successfully on my pi 3b. It downloads half way then spits out some errors in red that are too large to paste here. I have dlib installed already. Anyone encountered the same problem downloading the api?

netrosec commented May 10, 2018

Help!! Face_Recognition does not download successfully on my pi 3b. It downloads half way then spits out some errors in red that are too large to paste here. I have dlib installed already. Anyone encountered the same problem downloading the api?

@Oliverredtree

This comment has been minimized.

Show comment
Hide comment
@Oliverredtree

Oliverredtree May 20, 2018

Hi,guys.when I run python3 facerec_on_raspberry_pi.py , I get exception occurred. how to fix it?

Loading known face image(s)
Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 24, in
obama_face_encoding = face_recognition.face_encodings(obama_image)[0]
File "/home/pi/.local/lib/python3.5/site-packages/face_recognition/api.py", line 200, in face_encodings
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
File "/home/pi/.local/lib/python3.5/site-packages/face_recognition/api.py", line 200, in
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
RuntimeError: The full_object_detection must use the iBUG 300W 68 point face landmark style.

Oliverredtree commented May 20, 2018

Hi,guys.when I run python3 facerec_on_raspberry_pi.py , I get exception occurred. how to fix it?

Loading known face image(s)
Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 24, in
obama_face_encoding = face_recognition.face_encodings(obama_image)[0]
File "/home/pi/.local/lib/python3.5/site-packages/face_recognition/api.py", line 200, in face_encodings
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
File "/home/pi/.local/lib/python3.5/site-packages/face_recognition/api.py", line 200, in
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
RuntimeError: The full_object_detection must use the iBUG 300W 68 point face landmark style.

@MaulyGabriel

This comment has been minimized.

Show comment
Hide comment
@MaulyGabriel

MaulyGabriel May 28, 2018

I had a problem after the installation, when I run the examples of the segmentation fault

MaulyGabriel commented May 28, 2018

I had a problem after the installation, when I run the examples of the segmentation fault

@PauloCirino

This comment has been minimized.

Show comment
Hide comment
@PauloCirino

PauloCirino May 28, 2018

I'm having a weird problem.
I did just like superleggera24 said so, and installed the dlib 19.9;
Installed the OpenBLAS stuff ...
And Everything compiled the way it was supposed to.

Tested the face_recognition.face_locations function and it took, on average, 0.7 seconds.
But the face_recognition.face_encodings function runs forever(I waited 20 minutes before rebooting).
I tried changing the memory split, but it didn't work.
And this entire time, all 4 cores of the raspberry are working 100%.
Don't know what that might be, I'm going to try to reinstall everything and see if I made any mistakes on the way.

image

So i found what was the problem, and it is with the dlib.face_recognition_model_v1 function ....
Long story short, this guy had the same problem and provided a fix (davisking/dlib#660).

PauloCirino commented May 28, 2018

I'm having a weird problem.
I did just like superleggera24 said so, and installed the dlib 19.9;
Installed the OpenBLAS stuff ...
And Everything compiled the way it was supposed to.

Tested the face_recognition.face_locations function and it took, on average, 0.7 seconds.
But the face_recognition.face_encodings function runs forever(I waited 20 minutes before rebooting).
I tried changing the memory split, but it didn't work.
And this entire time, all 4 cores of the raspberry are working 100%.
Don't know what that might be, I'm going to try to reinstall everything and see if I made any mistakes on the way.

image

So i found what was the problem, and it is with the dlib.face_recognition_model_v1 function ....
Long story short, this guy had the same problem and provided a fix (davisking/dlib#660).

@alijaddoa

This comment has been minimized.

Show comment
Hide comment
@alijaddoa

alijaddoa Jul 3, 2018

Dear thank you for that,
i have installed all the packages, but when i try to run on of the example, an error it' occurring which is
"
Traceback (most recent call last):
File "face_distance.py", line 1, in
import face_recognition
ImportError: No module named face_recognition

"

can you please help with that
thank you

alijaddoa commented Jul 3, 2018

Dear thank you for that,
i have installed all the packages, but when i try to run on of the example, an error it' occurring which is
"
Traceback (most recent call last):
File "face_distance.py", line 1, in
import face_recognition
ImportError: No module named face_recognition

"

can you please help with that
thank you

@srs123

This comment has been minimized.

Show comment
Hide comment
@srs123

srs123 Jul 9, 2018

how to install cv2 in raspberry pi 3 ?
i install raspberry jessie os cv2 install and face recongnition refere code link

srs123 commented Jul 9, 2018

how to install cv2 in raspberry pi 3 ?
i install raspberry jessie os cv2 install and face recongnition refere code link

@gschrago

This comment has been minimized.

Show comment
Hide comment
@gschrago

gschrago Jul 11, 2018

Hi,
I have the following error while testing the fresh installation:

pi@pi-cam1:~/dlib/face_recognition/examples $ python3 facerec_on_raspberry_pi.py
Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 9, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 4, in
import dlib
ImportError: libatlas.so.3: cannot open shared object file: No such file or directory

Could you please kindly advise.
Thanks and best regards.
Gerard Schrago.

gschrago commented Jul 11, 2018

Hi,
I have the following error while testing the fresh installation:

pi@pi-cam1:~/dlib/face_recognition/examples $ python3 facerec_on_raspberry_pi.py
Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 9, in
import face_recognition
File "/usr/local/lib/python3.5/dist-packages/face_recognition/init.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 4, in
import dlib
ImportError: libatlas.so.3: cannot open shared object file: No such file or directory

Could you please kindly advise.
Thanks and best regards.
Gerard Schrago.

@ZT-XU

This comment has been minimized.

Show comment
Hide comment
@ZT-XU

ZT-XU Jul 27, 2018

I run the example and I get this:
python3 facerec_on_raspberry_pi.py
Loading known face image(s)
Capturing image.
Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 33, in
camera.capture(output, format="rgb",use_video_port=True)
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1423, in capture
'Timed out waiting for capture to end')
picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end
can't anyone help me?

ZT-XU commented Jul 27, 2018

I run the example and I get this:
python3 facerec_on_raspberry_pi.py
Loading known face image(s)
Capturing image.
Traceback (most recent call last):
File "facerec_on_raspberry_pi.py", line 33, in
camera.capture(output, format="rgb",use_video_port=True)
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1423, in capture
'Timed out waiting for capture to end')
picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end
can't anyone help me?

@chn-lee-yumi

This comment has been minimized.

Show comment
Hide comment
@chn-lee-yumi

chn-lee-yumi Jul 27, 2018

When I installing dlib, I found that it's unnecesary to change the size of swapfile. During the installation, the max usage of swap is less than 10MB. So the default settings(100MB) is OK.
My model is Raspberry Pi 2B, 1G RAM.
By the way, I change the GPU memory to 8MB, it still runs well.
After all is complete, I try python3 face_distance.py, it throws out an error about libatlas.so.3, so I use this command to fix it:sudo apt-get install libatlas3-base.( I see a lot of people meet this error.)
@gschrago @mthd98

chn-lee-yumi commented Jul 27, 2018

When I installing dlib, I found that it's unnecesary to change the size of swapfile. During the installation, the max usage of swap is less than 10MB. So the default settings(100MB) is OK.
My model is Raspberry Pi 2B, 1G RAM.
By the way, I change the GPU memory to 8MB, it still runs well.
After all is complete, I try python3 face_distance.py, it throws out an error about libatlas.so.3, so I use this command to fix it:sudo apt-get install libatlas3-base.( I see a lot of people meet this error.)
@gschrago @mthd98

@tutaf

This comment has been minimized.

Show comment
Hide comment
@tutaf

tutaf Aug 4, 2018

Is this instruction for camera connected through CSI or usb too?

tutaf commented Aug 4, 2018

Is this instruction for camera connected through CSI or usb too?

@cqupi

This comment has been minimized.

Show comment
Hide comment
@cqupi

cqupi Aug 12, 2018

@chn-lee-yumi Nice man!困扰我一下午问题被你一句话解决,你是怎么做到的!

cqupi commented Aug 12, 2018

@chn-lee-yumi Nice man!困扰我一下午问题被你一句话解决,你是怎么做到的!

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