Dlib+Vs2015配置
来源:互联网 发布:一个直播软件多少钱 编辑:程序博客网 时间:2024/06/05 01:11
(1)下载并解压Dlib
下载链接 http://dlib.net/
(2)设置环境变量
此步可以省略,不过后面就需要写全路径了。
新建环境变量:
DLIB = D:\Program Files\dlib-19.0\,其中“D:\Program Files\dlib-19.0”是我的解压目录
(3)建立VS2013空项目
3.1 设置包含目录
右键项目工程->属性->C/C++->常规->附加包含目录
如果没有像我一样设置环境变量的话,就需要把上面的$(DLIB)替换成你的解压目录。
3.2 设置预处理器定义
这里是为了添加对JPG和PNG图片的支持。
右键项目工程->属性->C/C++->预处理器->预处理器定义
3.3 设置库目录
右键项目工程->属性->链接器->常规->附加库目录
3.4 添加源文件
只需要添加两个源文件:
dlib\all\source.cppexamples\face_detection_ex.cpp
3.5 关闭SDL检查
当SDL检查启用时,编译器会严格检测缓冲区的溢出,这将导致一些函数编译失败。
项目属性->配置属性->C/C++->SDL检查,选测否。
3.5 添加资源文件
将下面三个文件夹下的所有文件添加到资源文件中
dlib\external\libjpegdlib\external\libpngdlib\external\zlib
(4)检测人脸关键点
#include <dlib/opencv.h> #include <opencv2/opencv.hpp> #include <dlib/image_processing/frontal_face_detector.h> #include <dlib/image_processing/render_face_detections.h> #include <dlib/image_processing.h> #include <dlib/gui_widgets.h> using namespace dlib; using namespace std; int main() { try { cv::VideoCapture cap(0); if (!cap.isOpened()) { cerr << "Unable to connect to camera" << endl; return 1; } //image_window win; // Load face detection and pose estimation models. frontal_face_detector detector = get_frontal_face_detector(); shape_predictor pose_model; deserialize("shape_predictor_68_face_landmarks.dat") >> pose_model; // Grab and process frames until the main window is closed by the user. while (cv::waitKey(30) != 27) { // Grab a frame cv::Mat temp; cap >> temp; cv_image<bgr_pixel> cimg(temp); // Detect faces std::vector<rectangle> faces = detector(cimg); // Find the pose of each face. std::vector<full_object_detection> shapes; for (unsigned long i = 0; i < faces.size(); ++i) shapes.push_back(pose_model(cimg, faces[i])); if (!shapes.empty()) { for (int i = 0; i < 68; i++) { circle(temp, cvPoint(shapes[0].part(i).x(), shapes[0].part(i).y()), 3, cv::Scalar(0, 0, 255), -1); // shapes[0].part(i).x();//68个 } } //Display it all on the screen imshow("Dlib特征点", temp); } } catch (serialization_error& e) { cout << "You need dlib's default face landmarking model file to run this example." << endl; cout << "You can get it from the following URL: " << endl; cout << " http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2" << endl; cout << endl << e.what() << endl; } catch (exception& e) { cout << e.what() << endl; } }
其中的问题:
Debug模式成功后,Release模式失败,原因是没有将Release配置文件进行配置,以及应该在“配置属性-->C/C++-->代码生成-->运行时库”中将“多线程(/MT)或者(/MD)”统一改为“多线程调试(/MTd)”。
添加源文件,要把source和face的源文件直接添加到源文件列表中 0 0
- Dlib+Vs2015配置
- dlib+VS2015配置与dlib特征点检测
- windows10-VS2015-Boost-Pyhton2.7-dlib配置
- dlib 01 dlib vs2015 编译 win10
- 机器学习库Dlib+VS2015
- vs2015配置dlib——————过程及遇到的问题
- Dlib 19.2+VS2015 人脸对齐
- dlib-18.18 install on win7+vs2015
- python dlib、opencv 配置
- win7+vs2013+dlib配置
- vs2013配置dlib库
- Dlib+VS2017配置
- Dlib环境配置
- 机器学习库Dlib在VS2015上的安装教程
- Dlib 19.2+VS2015 人脸检测(非CMake)
- vs2015 cmake 编译dlib生成动态链接库
- Dlib库的安装配置
- windows8下配置dlib(python)
- [Node.js]EventEmitter
- ie8不支持fixed以及jquery版本问题
- Oracle中多表联合更新处理方法详解
- Consecutive Tree Sequence
- mac 安装消息中间件---ActiveMQ
- Dlib+Vs2015配置
- winform 把窗口上的全部信息生成PDF文件显示
- 三星电子及时处理Note7燃损原因已查明
- C++编码器军规(003):避免对一个声明为const的变量使用const_cast
- 2016年知名企业阵亡名单丨不在变革中爆发,就在骄傲中死亡
- QString 保留小数点后一位数 & QT int 转16进制QString并补零
- 1.跨域资源共享资源CORS
- [Node.js]Stream
- Redhat7 更换Centos 7 yum源