使用dlib自带的面向梯度直方图(HOG)和线性分类器方法来检测人脸
之前使用opencv里面CascadeClassifier(级联分类器)来识别人脸,
下面使用dlib库来实现人脸识别。
dlib是一个开源的库,它包含了很多内容有机器学习,图像处理,数值算法等等。
#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
{
if (argc == )
{
cout << "Give some image files as arguments to this program." << endl;
return ;
} frontal_face_detector detector = get_frontal_face_detector();
image_window win; // Loop over all the images provided on the command line.
for (int i = ; i < argc; ++i)
{
cout << "processing image " << argv[i] << endl;
array2d<unsigned char> img;
load_image(img, argv[i]);
// 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.
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.
std::vector<rectangle> dets = detector(img); cout << "Number of faces detected: " << dets.size() << endl;
// 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(, , )); cout << "Hit enter to process the next image..." << endl;
cin.get();
}
}
catch (exception& e)
{
cout << "\nexception thrown!" << endl;
cout << e.what() << endl;
}
}
很简单只需要输入一张图片,利用dlib里自带的frontal_face_detector 来进行检测,返回没张人脸在图片里的区域(rect)
使用dlib自带的面向梯度直方图(HOG)和线性分类器方法来检测人脸的更多相关文章
- 使用dlib基于CNN(卷积神经网络)的人脸检测器来检测人脸
基于机器学习CNN方法来检测人脸比之前介绍的效率要慢很多 需要先下载一个训练好的模型数据: 地址点击下载 // dlib_cnn_facedetect.cpp: 定义控制台应用程序的入口点. // # ...
- 方向梯度直方图(HOG)和颜色直方图的一些比較
近期在学习视频检索领域的镜头切割方面的知识,发现经常使用的方法是直方图的方法,所以才专门有时间来学习下.查看到这两种直方图的时候,感觉有点接近,好像又不同,放在这做个比較.大部分还是百科的内容,只是对 ...
- Histogram of Oriented Gridients(HOG) 方向梯度直方图
Histogram of Oriented Gridients,缩写为HOG,是目前计算机视觉.模式识别领域很常用的一种描述图像局部纹理的特征.这个特征名字起的也很直白,就是说先计算图片某一区域中不同 ...
- 【翻译】HOG, Histogram of Oriented Gradients / 方向梯度直方图 介绍
本文翻译自 SATYA MALLICK 的 "Histogram of Oriented Gradients" 原文链接: https://www.learnopencv.com/ ...
- (转)matlab练习程序(HOG方向梯度直方图)
matlab练习程序(HOG方向梯度直方图)http://www.cnblogs.com/tiandsp/archive/2013/05/24/3097503.html HOG(Histogram o ...
- 特征描述子(feature descriptor) —— HOG(方向梯度直方图)
HOG(Histogram of Oriented Gradients),描述的是图像的局部特征,其命名也暗示了其计算方法,先计算图像中某一区域不同方向上梯度的值,然后累积计算频次,得到直方图,该直方 ...
- 梯度直方图(HOG,Histogram of Gradient)
1.介绍 HOG(Histogram of Oriented Gradient)是2005年CVPR会议上,法国国家计算机科学及自动控制研究所的Dalal等人提出的一种解决人体目标检测的图像描述子,该 ...
- 【计算机视觉】Histogram of Oriented Gridients(HOG) 方向梯度直方图
Histogram of Oriented Gridients(HOG) 方向梯度直方图 Histogram of Oriented Gridients,缩写为HOG,是目前计算机视觉.模式识别领域很 ...
- (转)梯度方向直方图HOG(Histograms of Oriented Gradients )
HOG(Histograms of Oriented Gradients )梯度方向直方图 方向梯度直方图(Histogram of Oriented Gradient, HOG)特征是一种在计算机视 ...
随机推荐
- Servlet 的面试题
Servlet运行在Servlet容器中,其生命周期由容器来管理.Servlet的生命周期通过javax.servlet.Servlet接口中的init().service()和destroy()方法 ...
- (转)hibernate缓存机制详细分析
在本篇随笔里将会分析一下hibernate的缓存机制,包括一级缓存(session级别).二级缓存(sessionFactory级别)以及查询缓存,当然还要讨论下我们的N+1的问题. 随笔虽长,但我相 ...
- 变量 (Variable)
Tensor不能反向传播. variable可以反向传播. 什么是 Variable import torch from torch.autograd import Variable # torch ...
- C++引用计数设计与分析(解决垃圾回收问题)
1.引言 上一篇博文讲到https://www.cnblogs.com/zhaoyixiang/p/12116203.html 我们了解到我们在浅拷贝时对带指针的对象进行拷贝会出现内存泄漏,那C++是 ...
- eclipse中SSM(maven)项目搭建全过程+实现用户登录功能
项目创建之前确保eclipse中已经配置好了jdk,tomcat,maven如果没有配置下面有配置教程的链接 eclipse中配置jdk的教程url:http://www.cnblogs.com/ ...
- 《带你装B,带你飞》pytest修炼之路1- 简介和环境准备
1. pytest简介 pytest是python的一种单元测试框架,与python自带的unittest测试框架类似,但是比unittest框架使用起来更简洁,效率更高.根据pytest的官方网站介 ...
- Python 多态与抽象类
一.多态 1.1 什么是多态 多态也称"多态性",指的是同一种类型的事物,不同的形态. 在python中的多态指的是让多种类若具备类似的数据属性与方法属性,都统一好命名规范,这样可 ...
- 使用rapidjson把文本json数据解析到树状结构
一个递归搞定 无聊的时候练练手就写了一个 头文件什么的我就不贴了 demo程序是MFC写的 void ParseObject(rapidjson::Value dc, CTreeCtrl * pTre ...
- $Noip2011/Luogu1311$ 选择客栈
$Luogu$ $Sol$ 暴力十分显然叭.正解不是很好想. 我最开始想维护所有色调的客栈的前缀和后缀,然后每扫到一个最低消费合法的就统计一次答案.但是这样会重复计数,两个合法客栈之间有几个消费合法的 ...
- 「洛谷P1343」地震逃生 解题报告
P1343 地震逃生 题目描述 汶川地震发生时,四川XX中学正在上课,一看地震发生,老师们立刻带领x名学生逃跑,整个学校可以抽象地看成一个有向图,图中有n个点,m条边.1号点为教室,n号点为安全地带, ...