1. 下载Dlib
官网http://dlib.net/files/:Dlib下载,选择下载版本dlib-19.17.zip
2. 编译
(1)解压缩,进入dlib-19.17文件夹:
(2)打开cmd命令:在上图目录下,按下shift按键,然后鼠键右键,出现如下,选择【在此处代开Powershell窗口(是)】;
(3)编译命令:
首先要保证已经安装了cmake,并添加了环境变量path的配置,参考官方说明,执行编译:
说明:
(1) cmake .. 此安装默认生成32位的可执行文件,要想生成64位的,需要将cmake.. 命令替换为 cmake -G "Visual Studio 14 2015 Win64" -T host=x64 ..
(2) cmake --build . --config Release 编译release版:【警告可忽略,但耗时较久,耐心等待~~~~】
生成的lib在D:\SoftewareLoadPath\dlib-19.17\examples\build\dlib_build\Release文件下;
cmake --build . --config Debug 编译debug版:
生成的lib在D:\SoftewareLoadPath\dlib-19.17\examples\build\dlib_build\Debug文件下;
3. vs2015 配置 Release版和debug版
从属性管理器-Microsoft.Cpp.x64.user-配置:
VC++目录 > 包含目录:
D:\SoftewareLoadPath\dlib-19.17
VC++目录>库目录:
D:\SoftewareLoadPath\dlib-19.17\examples\build\dlib_build\Release
D:\SoftewareLoadPath\dlib-19.17\examples\build\dlib_build\Debug
链接器>附加依赖项:
dlib19.17.0_debug_64bit_msvc1900.lib
dlib19.17.0_release_64bit_msvc1900.lib
c/c++ > 预处理器:
否则加载图片时会遇到如下问题:
You must #define DLIB_JPEG_SUPPORT and link to libjpeg to read JPEG files.
Do this by following the instructions at http://dlib.net/compile.html.
Note that you must cause DLIB_JPEG_SUPPORT to be defined for your entire project.
So don’t #define it in one file. Instead, add it to the C/C++->Preprocessor->Preprocessor Definitions
field in Visual Studio’s Property Pages window so it takes effect for your entire application.
4. 实例测试
Dilib库目录examples里面有很多丰富且功能强大的demo,我们就用face_landmark_detection_ex.cpp这个demo来演示首先,把face_landmark_detection_ex.cpp添加到源文件下;
接下来,进行命令行配置,以进行执行操作:
(1)http://dlib.net/files/下载人脸识别68个特征点检测数据库,解压后拷贝到到新建工程的main.cpp文件所在目录下;
(2)将examples目录下faces文件夹里的图片复制到新建工程的main.cpp文件下,修改一张图片名为1.jpg,或者从网站上下载一张人脸的图片到新建工程的main.cpp文件下所在目录下,命名为1.jpg。
(3)配置命令行参数。点击调试—>项目属性—>调试,在命令参数一栏输入:
shape_predictor_68_face_landmarks.dat 1.jpg。(注意,两个文件之间用空格隔开)。
(4)执行结果: