使用dlib人脸识别的例子
来源:互联网 发布:spss19.0软件 编辑:程序博客网 时间:2024/05/21 22:57
来自官方的例子: http://dlib.net/face_detection_ex.cpp.html
做了一些修改:
#include <dlib/image_processing/frontal_face_detector.h>#include <dlib/gui_widgets.h>#include <dlib/image_io.h>#include <iostream>using namespace dlib;using namespace std;int main(int argc, char *argv[]){ try { //定义一个frontal_face_detctor类的实例detector,用get_frontal_face_detector函数初始化该实例 frontal_face_detector detector = get_frontal_face_detector(); image_window win;//一个显示窗口 array2d<unsigned char> img; // 加载一张图片,从(图片路劲)加载到变量img load_image(img, "D:\\img.jpg"); // Make the image bigger by a factor of two. This is useful since // the face detector looks for faces that are about 80 by 80 pixels // or larger. Therefore, if you want to find faces that are smaller // than that then you need to upsample the image as we do here by // calling pyramid_up(). So this will allow it to detect faces that // are at least 40 by 40 pixels in size. We could call pyramid_up() // again to find even smaller faces, but note that every time we // upsample the image we make the detector run slower since it must // process a larger image. /*确保检测图片是检测器的两倍。这第一点是十分有用的,因为脸部检测器搜寻的人脸大小是80*80或者更大。 因此,如果你想找到比80*80小的人脸,需要将检测图片进行上采样,我们可以调用pyramid_up()函数。 执行一次pyramid_up()我们能检测40*40大小的了,如果我们想检测更小的人脸,那还需要再次执行pyramid_up()函数。 注意,上采样后,速度会减慢!*/ pyramid_up(img);//对图像进行上采用,检测更小的人脸 // Now tell the face detector to give us a list of bounding boxes // around all the faces it can find in the image. //detector()函数检测人脸,返回一系列边界盒子 std::vector<rectangle> dets = detector(img); cout << "Number of faces detected: " << dets.size() << endl;//dets.size 人脸数量 // Now we show the image on the screen and the face detections as // red overlay boxes. // 在原图片上显示结果 win.clear_overlay(); win.set_image(img); win.add_overlay(dets, rgb_pixel(255, 0, 0)); cout << "Hit enter to process the next image..." << endl; cin.get(); } catch (exception& e) { cout << "\nexception thrown!" << endl; cout << e.what() << endl; }}
我使用QT+VS2015编译测试的,附上我的qmake
win32:CONFIG(release, debug|release): LIBS += $$PWD/dlib/dlib.libelse:win32:CONFIG(debug, debug|release): LIBS += $$PWD/dlib/dlibd.libDEFINES += DLIB_PNG_SUPPORTDEFINES += DLIB_JPEG_SUPPORTDEFINES += DLIB_HAVE_AVXINCLUDEPATH += D:/OpenCV/dlib-19.2/
环境路径参考上一篇dlib编译博文。
有一点疑问:为什么显示出来的图片变成了黑白的?
0 0
- 使用dlib人脸识别的例子
- Dlib人脸识别加速
- 使用Dlib进行人脸识别(从Haar到Dlib)
- tensorflow74 使用tensorflow dlib opencv做特定人脸识别
- dlib 07 dlib自带demo 基于DNN的人脸识别
- python基于dlib的人脸识别+标记
- Dlib+OpenCV深度学习人脸识别
- dlib 人脸识别库编译
- DLIB 人脸识别 python代码
- dlib实现人脸识别-python
- 使用Dlib库进行人脸检测,人脸对齐和人脸识别
- 在android平台编译并使用dlib人脸识别库
- 基于深度学习的人脸识别系统系列(Caffe+OpenCV+Dlib)——【一】如何在Visual Studio中像使用OpenCV一样使用Caffe
- 【深度学习】基于深度学习的人脸识别系统系列(Caffe+OpenCV+Dlib)
- C++实现基于深度学习的人脸识别系统(Dlib+Caffe+Opencv)
- Dlib在GPU下的环境配置(以人脸识别为例)
- 基于深度学习的人脸识别系统系列(Caffe+OpenCV+Dlib)——【四】使用CUBLAS加速计算人脸向量的余弦距离
- 使用OpenCV进行人脸识别的例子
- solver.prototxt文件里面参数含义及其设置
- Spring和MyBatis环境整合
- 攻击、技能冷却 关键代码
- 消息中间件的技术选型心得-RabbitMQ、ActiveMQ和ZeroMQ
- 蓝牙开发
- 使用dlib人脸识别的例子
- Jemeter分布式测试
- Redis与Memcached的区别
- TCP keep-alive原理
- A、B基金
- git的使用
- 主要开源协议一览
- 数据结构与算法分析笔记与总结(java实现)--数组11:数组中的逆序对(﹡)
- webservice编写天气预报功能