使用dlib基于CNN(卷积神经网络)的人脸检测器来检测人脸
基于机器学习CNN方法来检测人脸比之前介绍的效率要慢很多
需要先下载一个训练好的模型数据:
// dlib_cnn_facedetect.cpp: 定义控制台应用程序的入口点。
// #include "stdafx.h" #include <iostream>
#include <dlib/dnn.h>
#include <dlib/data_io.h>
#include <dlib/image_processing.h>
#include <dlib/gui_widgets.h> using namespace std;
using namespace dlib; // ---------------------------------------------------------------------------------------- template <long num_filters, typename SUBNET> using con5d = con<num_filters, , , , , SUBNET>;
template <long num_filters, typename SUBNET> using con5 = con<num_filters, , , , , SUBNET>; template <typename SUBNET> using downsampler = relu<affine<con5d<, relu<affine<con5d<, relu<affine<con5d<, SUBNET>>>>>>>>>;
template <typename SUBNET> using rcon5 = relu<affine<con5<, SUBNET>>>; using net_type = loss_mmod<con<, , , , , rcon5<rcon5<rcon5<downsampler<input_rgb_image_pyramid<pyramid_down<>>>>>>>>; // ---------------------------------------------------------------------------------------- int main(int argc, char** argv)
{
try { if (argc == )
{
cout << "Call this program like this:" << endl;
cout << "./dnn_mmod_face_detection_ex mmod_human_face_detector.dat faces/*.jpg" << endl;
cout << "\nYou can get the mmod_human_face_detector.dat file from:\n";
cout << "http://dlib.net/files/mmod_human_face_detector.dat.bz2" << endl;
return ;
} net_type net;
deserialize(argv[]) >> net; image_window win;
for (int i = ; i < argc; ++i)
{
matrix<rgb_pixel> img;
load_image(img, argv[i]); // Upsampling the image will allow us to detect smaller faces but will cause the
// program to use more RAM and run longer.
while (img.size() < * )
pyramid_up(img); // Note that you can process a bunch of images in a std::vector at once and it runs
// much faster, since this will form mini-batches of images and therefore get
// better parallelism out of your GPU hardware. However, all the images must be
// the same size. To avoid this requirement on images being the same size we
// process them individually in this example.
auto dets = net(img);
win.clear_overlay();
win.set_image(img);
for (auto&& d : dets)
win.add_overlay(d); cout << "Hit enter to process the next image." << endl;
cin.get();
}
}
catch (std::exception& e)
{
cout << e.what() << endl;
} }
使用dlib基于CNN(卷积神经网络)的人脸检测器来检测人脸的更多相关文章
- Deep Learning模型之:CNN卷积神经网络(一)深度解析CNN
http://m.blog.csdn.net/blog/wu010555688/24487301 本文整理了网上几位大牛的博客,详细地讲解了CNN的基础结构与核心思想,欢迎交流. [1]Deep le ...
- cnn(卷积神经网络)比较系统的讲解
本文整理了网上几位大牛的博客,详细地讲解了CNN的基础结构与核心思想,欢迎交流. [1]Deep learning简介 [2]Deep Learning训练过程 [3]Deep Learning模型之 ...
- 基于3D卷积神经网络的人体行为理解(论文笔记)(转)
基于3D卷积神经网络的人体行为理解(论文笔记) zouxy09@qq.com http://blog.csdn.net/zouxy09 最近看Deep Learning的论文,看到这篇论文:3D Co ...
- Keras(四)CNN 卷积神经网络 RNN 循环神经网络 原理及实例
CNN 卷积神经网络 卷积 池化 https://www.cnblogs.com/peng8098/p/nlp_16.html 中有介绍 以数据集MNIST构建一个卷积神经网路 from keras. ...
- 3层-CNN卷积神经网络预测MNIST数字
3层-CNN卷积神经网络预测MNIST数字 本文创建一个简单的三层卷积网络来预测 MNIST 数字.这个深层网络由两个带有 ReLU 和 maxpool 的卷积层以及两个全连接层组成. MNIST 由 ...
- [转]Theano下用CNN(卷积神经网络)做车牌中文字符OCR
Theano下用CNN(卷积神经网络)做车牌中文字符OCR 原文地址:http://m.blog.csdn.net/article/details?id=50989742 之前时间一直在看 Micha ...
- Deep Learning论文笔记之(四)CNN卷积神经网络推导和实现(转)
Deep Learning论文笔记之(四)CNN卷积神经网络推导和实现 zouxy09@qq.com http://blog.csdn.net/zouxy09 自己平时看了一些论文, ...
- CNN(卷积神经网络)、RNN(循环神经网络)、DNN(深度神经网络)的内部网络结构有什么区别?
https://www.zhihu.com/question/34681168 CNN(卷积神经网络).RNN(循环神经网络).DNN(深度神经网络)的内部网络结构有什么区别?修改 CNN(卷积神经网 ...
- CNN(卷积神经网络)、RNN(循环神经网络)、DNN,LSTM
http://cs231n.github.io/neural-networks-1 https://arxiv.org/pdf/1603.07285.pdf https://adeshpande3.g ...
随机推荐
- boostrap-非常好用但是容易让人忽略的地方【5】:input-group-btn
1.正常的使用 <div class="form-group"> <div class="input-group"> <input ...
- looping through multiple lists
map: 最大长度输出: zip: 最短输出: third: 有序排列: a = ['a1', 'a2', 'a3'] b = ['b1', 'b2'] print "Map:" ...
- 函数闭包模拟session
根据上一个认证功能的问题 要解决的就是只需要登录一次 也就是登录一次之后的用户名跟密码可以保存下来让其他函数用-->全局变量 user_dic = {"user_name": ...
- Java 从入门到进阶之路(十九)
在之前的文章我们介绍了一下 Java 中的Object,本章我们来看一下 Java 中的包装类. 在 Java 中有八个基本类型:byte,short,int,long,float,double,ch ...
- 如何把对象手动注入Spring容器并实现依赖注入
将对象注入到Spring容器并实现依赖注入 public class UserDao { @Resource AccountService accountService; public void pr ...
- 007 Ceph手动部署单节点
前面已经介绍了Ceph的自动部署,本次介绍一下关于手动部署Ceph节点操作 一.环境准备 一台虚拟机部署单节点Ceph集群 IP:172.25.250.14 内核: Red Hat Enterpris ...
- Java8 LocalDate计算两个日期的间隔天数
Java8新增了java.time包,提供了很多新封装好的类,使我们可以摆脱原先使用java.util.Time以及java.util.Calendar带来的复杂. 其中LocalDate正是本文中使 ...
- [UWP]XAML中的响应式布局技术
响应式布局的概念是一个页面适配多个终端及不同分辨率.在针对特定屏幕宽度优化应用 UI 时,我们将此称为创建响应式设计.WPF设计之初响应式设计的概念并不流行,那时候大部分网页设计师都按着宽度960像素 ...
- 「Luogu P3395」路障 解题报告
点开有惊喜 其实是题面 这D1T1给的很有面子! 我居然做的来! 从左上角走到右上角 然后n<=1000 所以果断放弃DFS,选择BFS 思路还是一样的BFS 证明: 走到一个点的时间越早越好( ...
- 1062 最简分数 (20分)C语言
一个分数一般写成两个整数相除的形式:N/M,其中 M 不为0.最简分数是指分子和分母没有公约数的分数表示形式. 现给定两个不相等的正分数 N1/M1和 N2/M2,要求你按从小到大的顺序列出它们之间 ...