Install dlib dependences
The dlib library requires four prerequisites:
- Boost
- Boost.Python
- CMake
- X11
These can all be installed via the following commands
sudo apt-get update
sudo apt-get install build-essential cmake
sudo apt-get install libgtk-3-dev
sudo apt-get install libboost-all-dev
Access your Python virtual environment (if you are using them)
All of my OpenCV install tutorials on the PyImageSearch blog make use of Python virtual environments.
Using Python’s virtualenv and virtualenvwrapper libraries, we can create separate Python environments for each project we are working on — this is considered a best practice when developing software in the Python programming language.
I’ve discussed Python virtual environments many times before on the PyImageSearch blog, so I’ll spare any discussion of them here. If you would like to read more about Python virtual environments please refer to any of my installing OpenCV tutorials along with this excellent Python virtual environment primer.
If you would like to install dlib into a pre-existing Python, virtual environment, use the workon command:
workon <your virtualenv name>
For example, most tutorials here on PyImageSearch create a virtual environment named cv. We can access the cv virtual environment via:
workon cv
Otherwise, I suggest creating an entirely separate virtual environment using the
mkvirtualenv
command.
The command below will create a Python virtual environment named py2_dlib with the Python 2.7 interpreter:
mkvirtualenv py2_dlib
While this command will create a Python 3 virtual environment named py3_dlib :
mkvirtualenv py3_dlib -p python3
Please keep in mind that this step is optional, but highly recommended.
Use pip to install dlib with Python bindings
We’ll start with the basic NumPy + SciPy stack, followed by scikit-image , a library commonly used in conjunction with dlib:pip install numpy
pip install scipy
pip install scikit-image
We can then install dlib via
pip
as well:
pip install dlib
Test out your dlib install
To test out your dlib install, open up a Python shell (making sure to access your Python virtual environment if you used one), and then try to import dlib :Example:
- Facial landmark detection with dlib and the Raspberry Pi
Refer https://www.pyimagesearch.com/2017/05/01/install-dlib-raspberry-pi/
- RTD
Reference:
Install dlib on the Raspberry Pi,
https://www.pyimagesearch.com/2017/05/01/install-dlib-raspberry-pi/