Python-Dlib 安装

Dlib 各个系统安装流程。

OSX 系统

安装

1
2
3
4
5
6
7
8
brew install boost-python
git clone https://github.com/davisking/dlib
cd dlib/python_examples
mkdir build
cd build
cmake ../../tools/python
cmake --build . --config Release
cp dlib.so /usr/local/lib/python2.7/site-packages

验证

1
2
3
python
import dlib
dlib.rectangle(left, top, right ,bottom)

Ubuntu 系统

安装

1
2
3
4
5
6
7
8
sudo apt-get install libboost-python-dev cmake
git clone https://github.com/davisking/dlib
cd dlib/python_examples
mkdir build
cd build
cmake ../../tools/python
cmake --build . --config Release
cp dlib.so /usr/local/lib/python2.7/dist-packages

报错解决

问题:

1
2
3
/opt/libs/dlib/dlib/base64/../algs.h:313: error: expected constructor, destructor, or type conversion before ‘bool’
或者
cc1plus: error: unrecognized command line option "-std=c++11"

解决:

1
2
3
4
5
6
7
g++, gcc 版本不对
mv /usr/bin/c++ /usr/bin/c++_save
mv /usr/bin/g++ /usr/bin/g++_save
mv /usr/bin/gcc /usr/bin/gcc_save
ln -s /usr/local/bin/c++ /usr/bin/c++
ln -s /usr/local/bin/g++ /usr/bin/g++
ln -s /usr/local/bin/gcc /usr/bin/gcc

Ubuntu 系统

1
2
sudo apt-get install libcv-dev or libopencv-devpy
sudo apt-get install python-opencv or sudo pip3 install opencv-python

XML 资源文件

XML 资源文件