CentOS7安装face_recognition人脸识别库

0. face_recognition官方文档

https://github.com/ageitgey/face_recognition


1. 安装face_recognition

1.1 安装dlib

1) 安装开发环境

[root@localhost ~]# yum update
[root@localhost ~]#yum groupinstall "Development Tools"


2) 安装OpenCV

[root@localhost ~]# yum install cmake python-devel numpy gcc gcc-c++ gtk2-devel libdc1394-devel libv4l-devel ffmpeg-devel gstreamer-plugins-base-devel libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel libtiff-devel libwebp-devel opencv opencv-python opencv-devel


扫描二维码关注公众号,回复: 3751454 查看本文章

3) 升级gcc版本,确保安装过程正确

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo sudo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

软件会被安装在/opt/rh目录下。
配置环境变量:

export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc  
export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++

别忘了. /etc/profile。

将安装的目录软链接到local/bin。

ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
hash -r

*** 如果gcc已经为最新版本,忽略这一步骤。

[root@localhost ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)


4) 安装boost

[root@localhost ~]#yum install boost  
[root@localhost ~]#yum install boost-devel  
[root@localhost ~]#yum install boost-doc

或者

[root@localhost ~]#yum install boost boost-devel boost-doc


5) 安装dlib

[root@localhost ~]# pip install dlib
Collecting dlib
  Using cached https://files.pythonhosted.org/packages/35/8d/e4ddf60452e2fb1ce3164f774e68968b3f110f1cb4cd353235d56875799e/dlib-19.16.0.tar.gz
Installing collected packages: dlib
  Running setup.py install for dlib ... done
Successfully installed dlib-19.16.0

这一步安装非常耗时间(在我的机器上用了将近30多分钟)。


6) 安装libXdmcp

为了解决导入错误,还需要安装libXdmcp。

[root@localhost ~]# yum install libXdmcp libXdmcp-devel


1.2 安装face_recognition

[root@localhost ~]# pip install face_recognition

检查安装结果:

[root@localhost ~]# ipython
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.


Caching the list of root modules, please wait!
(This will only be done once - type '%rehashx' to reset cache!)

This is taking too long, we give up.

In [1]: import face_recognition

In [2]:





猜你喜欢

转载自blog.51cto.com/10931223/2309722