之前使用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)和线性分类器方法来检测人脸的更多相关文章

  1. 使用dlib基于CNN(卷积神经网络)的人脸检测器来检测人脸

    基于机器学习CNN方法来检测人脸比之前介绍的效率要慢很多 需要先下载一个训练好的模型数据: 地址点击下载 // dlib_cnn_facedetect.cpp: 定义控制台应用程序的入口点. // # ...

  2. 方向梯度直方图(HOG)和颜色直方图的一些比較

    近期在学习视频检索领域的镜头切割方面的知识,发现经常使用的方法是直方图的方法,所以才专门有时间来学习下.查看到这两种直方图的时候,感觉有点接近,好像又不同,放在这做个比較.大部分还是百科的内容,只是对 ...

  3. Histogram of Oriented Gridients(HOG) 方向梯度直方图

    Histogram of Oriented Gridients,缩写为HOG,是目前计算机视觉.模式识别领域很常用的一种描述图像局部纹理的特征.这个特征名字起的也很直白,就是说先计算图片某一区域中不同 ...

  4. 【翻译】HOG, Histogram of Oriented Gradients / 方向梯度直方图 介绍

    本文翻译自 SATYA MALLICK 的 "Histogram of Oriented Gradients" 原文链接: https://www.learnopencv.com/ ...

  5. (转)matlab练习程序(HOG方向梯度直方图)

    matlab练习程序(HOG方向梯度直方图)http://www.cnblogs.com/tiandsp/archive/2013/05/24/3097503.html HOG(Histogram o ...

  6. 特征描述子(feature descriptor) —— HOG(方向梯度直方图)

    HOG(Histogram of Oriented Gradients),描述的是图像的局部特征,其命名也暗示了其计算方法,先计算图像中某一区域不同方向上梯度的值,然后累积计算频次,得到直方图,该直方 ...

  7. 梯度直方图(HOG,Histogram of Gradient)

    1.介绍 HOG(Histogram of Oriented Gradient)是2005年CVPR会议上,法国国家计算机科学及自动控制研究所的Dalal等人提出的一种解决人体目标检测的图像描述子,该 ...

  8. 【计算机视觉】Histogram of Oriented Gridients(HOG) 方向梯度直方图

    Histogram of Oriented Gridients(HOG) 方向梯度直方图 Histogram of Oriented Gridients,缩写为HOG,是目前计算机视觉.模式识别领域很 ...

  9. (转)梯度方向直方图HOG(Histograms of Oriented Gradients )

    HOG(Histograms of Oriented Gradients )梯度方向直方图 方向梯度直方图(Histogram of Oriented Gradient, HOG)特征是一种在计算机视 ...

随机推荐

  1. Elasticsearch搜索调优

    最近把搜索后端从AWS cloudsearch迁到了AWS ES和自建ES集群.测试发现search latency高于之前的benchmark,可见模拟数据远不如真实数据来的实在.这次在产线的bac ...

  2. Linux 批量安装依赖

    1.依赖检测失败,xxx被xxxx需要. 当我安装rpm 的时候,出现依赖检测失败. 我们可以到http://rpmfind.net/linux/rpm2html/search.php 这个网站上去搜 ...

  3. 如何使用JMX来管理程序?

    什么是JMX JMX,全称Java Management Extensions,用于我们管理和监控java应用程序.JMX有以下用途: 监控应用程序的运行状态和相关统计信息. 修改应用程序的配置(无需 ...

  4. AbstractRoutingDataSource动态数据源切换

    操作数据一般都是在DAO层进行处理,可以选择直接使用JDBC进行编程(http://blog.csdn.net/yanzi1225627/article/details/26950615/) 或者是使 ...

  5. Jenkins+ant+jmeter环境搭建

    下载的工具版本: apache-jmeter-3.0 apache-ant-1.8.4 jenkins-2.46.3 之前用jmeter写了测试接口的脚本,运行及返回结果都正常,所以需要做的就是工具的 ...

  6. java之斗地主

    hashmap集合+ArrayList集合+Collections集合工具类shuffle()和sort()hashmap中get(key).put(key/value)Arraylist中的add( ...

  7. CountDownLanuch,CyclicBarrier,Semaphore,Lock

    一.你在项目中用过CountDownLanuch,CyclicBarrier,Semaphore吗? 1.CountDownLanuch是一个同步的工具类,它允许一个或多个线程一直等待,直到其他线程执 ...

  8. 1081 检查密码 (15分)C语言

    本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能.该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母.数字和小数点 .,还必须既有字母也有数字. 输入格式: 输入第一行 ...

  9. Java对象头与锁

    对象由多部分构成的,对象头,属性字段.补齐区域等.所谓补齐区域是指如果对象总大小不是4字节的整数倍,会填充上一段内存地址使之成为整数倍. 后面两个很好理解,今天我主要想总结一下对象头: 对象头这部分在 ...

  10. 论Java中的抽象类与接口

    目录 抽象类和抽象方法 定义 与普通类的区别以及注意点: 抽象类的作用 接口 定义 示例 注意 作用 最后:接口与抽象类的异同 使用场景 借鉴 抽象类和抽象方法 定义 抽象方法和抽象类都必须被abst ...