Instructions tested with a Raspberry Pi 2 with an 8GB memory card. Probably also works fine on a Raspberry Pi 3.
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
Even after running --no-cahe-dir face_recognition I get this error
sudo pip3 install --no-cache-dir face_recognition
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting face_recognition
Downloading https://files.pythonhosted.org/packages/3f/ed/ad9a28042f373d4633fc8b49109b623597d6f193d3bbbef7780a5ee8eef2/face_recognition-1.2.3-py2.py3-none-any.whl
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from face_recognition) (5.4.1)
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from face_recognition) (1.16.2)
Requirement already satisfied: Click>=6.0 in /usr/lib/python3/dist-packages (from face_recognition) (7.0)
Collecting face-recognition-models>=0.3.0 (from face_recognition)
Downloading https://www.piwheels.org/simple/face-recognition-models/face_recognition_models-0.3.0-py2.py3-none-any.whl (100.6MB)
|█ | 2.9MB 14kB/s eta 1:50:54ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, 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/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, 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/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, 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/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, 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/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, 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/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, 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/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, 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/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1822, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1639, in _raise_ssl_error
raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (104, 'ECONNRESET')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/response.py", line 397, in _error_catcher
yield
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/response.py", line 479, in read
data = self._fp.read(amt)
File "/usr/lib/python3.7/http/client.py", line 447, in read
n = self.readinto(b)
File "/usr/lib/python3.7/http/client.py", line 491, in readinto
n = self.fp.readinto(b)
File "/usr/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 319, in recv_into
return self.recv_into(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 319, in recv_into
return self.recv_into(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 319, in recv_into
return self.recv_into(*args, **kwargs)
[Previous line repeated 4 more times]
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 309, in recv_into
raise SocketError(str(e))
OSError: (104, 'ECONNRESET')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/base_command.py", line 188, in main
status = self.run(options, args)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/commands/install.py", line 345, in run
resolver.resolve(requirement_set)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/legacy_resolve.py", line 196, in resolve
self._resolve_one(requirement_set, req)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/legacy_resolve.py", line 359, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/legacy_resolve.py", line 307, in _get_abstract_dist_for
self.require_hashes
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/operations/prepare.py", line 199, in prepare_linked_requirement
progress_bar=self.progress_bar
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/download.py", line 1050, in unpack_url
progress_bar=progress_bar
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/download.py", line 910, in unpack_http_url
progress_bar)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/download.py", line 1138, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/download.py", line 847, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/hashes.py", line 75, in check_against_chunks
for chunk in chunks:
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/download.py", line 815, in written_chunks
for chunk in chunks:
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/ui.py", line 156, in iter
for x in it:
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/download.py", line 804, in resp_read
decode_content=False):
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/response.py", line 531, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/response.py", line 496, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib/python3.7/contextlib.py", line 130, in exit
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.7/dist-packages/pip/_vendor/urllib3/response.py", line 415, in _error_catcher
raise ProtocolError('Connection broken: %r' % e, e)
pip._vendor.urllib3.exceptions.ProtocolError: ('Connection broken: OSError("(104, 'ECONNRESET')")', OSError("(104, 'ECONNRESET')"))