使用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)特征是一种在计算机视 ...
随机推荐
- 开篇 | 揭秘 Flink 1.9 新架构,Blink Planner 你会用了吗?
本文为 Apache Flink 新版本重大功能特性解读之 Flink SQL 系列文章的开篇,Flink SQL 系列文章由其核心贡献者们分享,涵盖基础知识.实践.调优.内部实现等各个方面,带你由浅 ...
- CSDN博客 专用备份工具
CSDN博客 专用备份工具 用要的朋友可下载. 本程序为个人所用,仅供学习.作者:潇湘博客网站:http://blog.csdn.NET/fkedwgwy默认文件存放位置为用户名文件夹下,也可以直接自 ...
- IPv4数据报格式及其语义
一.IP数据报的格式如下图所示 版本 首部长度 服务类型 数据报长度 16比特标识 标志 13比特片偏移 寿命 上层协议 首部检验和 32比特源IP地址 32比特目的IP地址 选项(如果有的话) 数据 ...
- 聊聊多线程哪一些事儿(task)之 一
多线程,一个多么熟悉的词汇,作为一名程序员,我相信无论是从事什么开发语言,都能够轻轻松松说出几种实现多线程的方式,并且在实际工作种也一定用到过多线程,比如:定时器.异步作业等等,如果你说你没有用过多线 ...
- 91.requests&BeautifulSoup
转载:https://www.cnblogs.com/wupeiqi/articles/6283017.html equests Python标准库中提供了:urllib.urllib2.httpli ...
- MindManager使用技巧
任务窗格在右下角. 1.条件的设置与编辑 2.优先级视图 不是优先级图标 3.圆圈图 4.洋葱图的使用 右键选择背景再选择解锁所有背景就可以对所有圆形进行调整了 点图形边缘出现十字架可以进行移动 5 ...
- redis 集群模式
redis cluster 介绍 自动将数据进行分片,每个 master 上放一部分数据 提供内置的高可用支持,部分 master 不可用时,还是可以继续工作的 在 redis cluster 架构下 ...
- 记一次线上 OOM 和性能优化
大家好,我是鸭血粉丝(大家会亲切的喊我 「阿粉」),是一位喜欢吃鸭血粉丝的程序员,回想起之前线上出现 OOM 的场景,毕竟当时是第一次遇到这么 紧脏 的大事,要好好记录下来. 1 事情回顾 在某次周五 ...
- idea编辑器的使用
编辑器下载和安装就不说了,网上每次版本都更换得好快 ,发新版的人很多idea2019:https://pan.baidu.com/s/1zc1wkQLLVxbXSjy4ISN4aQ 提取码:cgah, ...
- CommandPattern(命令模式)-----Java/.Net
命令模式(Command Pattern)是一种数据驱动的设计模式,它属于行为型模式.请求以命令的形式包裹在对象中,并传给调用对象.调用对象寻找可以处理该命令的合适的对象,并把该命令传给相应的对象,该 ...