您的位置:首页 > 编程语言 > ASP

Dlib Configure on Raspberry PI

2018-02-27 13:02 302 查看

Install dlib dependences

The dlib library requires four prerequisites:Boost
Boost.Python
CMake
X11
These can all be installed via the following commandssudo 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 themkvirtualenv  command.

The command below will create a Python virtual environment named py2_dlib  with the Python 2.7 interpreter: mkvirtualenv py2_dlibWhile this command will create a Python 3 virtual environment named py3_dlib : mkvirtualenv py3_dlib -p python3Please 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

Note: Use 'pip3' for python3

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 :

Python 2.7.13:pi@raspberrypi:~ $ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>>
Python 3.5:
Use "pip3 install dlib" if Python3 did not find 'dlib'.pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>>

If you would like to access your OpenCV bindings along with your dlib bindings from the same virtual environment, make sure your cv2.so  bindings are properly sym-linked into the site-packages  directory of your Python virtual environment.

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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: