Dlib 19.2+VS2015 人脸检测(非CMake)

最近在捣鼓人脸对齐,看见公司的同事都是用的dlib,所以也寻思着用一下,下面记载了我的整个配置流程:

step1  下载Dlib-19.2:http://dlib.net/compile.html

step2  解压:(我的路径:D:\FuXueping\DLib)

step3 安装VS2015.(注:百度经验上找的安装方法:http://jingyan.baidu.com/article/642c9d34fc5fa0644b46f74a.html

step4 环境变量配置:我的电脑——>右键——>属性——>高级系统设置——>环境变量——>path,继续操作如下图:

 

step5  打开vs2015新建一个工程,进行如下配置(用图片说明):

step 6    把dlib\external\libjpeg;dlib\external\libpng;dlib\external\zlib加载到资源文件中

我的人脸检测代码是:

 

#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>
#include<dlib\image_io.h>

#include<iostream>
#include<vector>


//#define DDLIB_JPEG_SUPPORT
//#define DLIB_PNG_SUPPORT


using namespace dlib;
using namespace std;

int main(int argc, char **argv)
{
	try
	{
		frontal_face_detector detector = get_frontal_face_detector();

		image_window win;//一个显示窗口

		array2d<unsigned char> img;
		cout << "processing image" << argv[1] << endl;
		load_image(img,argv[1]);//加载一张图片
		pyramid_up(img);//对图像进行上采样,检测更小的人脸

						//开始检测,返回一系列的边界框
		std::vector<rectangle> dets = detector(img);//detector()函数检测人脸,返回一系列边界盒子

		cout << "Number of faces detected:" << dets.size() << endl;//re
																   //在原图上显示结果
		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 (const std::exception& e)
	{
		cout << "\nexception thrown!" << endl;
		cout << e.what() << endl;
	}
	getchar();
}

运行的效果图:

 


总结:这次配置主要是问题就是图片读不出来,晚上折腾了三四个钟,早上才做出来,但人脸检测的速度真的好慢,希望人脸对齐的速度会好很多!

参考:http://blog.csdn.net/shuzfan/article/details/52149882

第一次用,配置当中可能有一些重复工作,希望错误的地方可以帮我指出。谢谢

 

 

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猫猫与橙子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值