使用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 ...
随机推荐
- 【Docker】镜像分层存储与镜像精简
Linux操作系统 Linux操作系统由内核空间和用户空间组成. 内核空间是kernel,用户空间是rootfs, 不同Linux发行版的区别主要是rootfs.比如 Ubuntu 14.04 使用 ...
- c++ list的坑
std::list为空时调用pop_front的访问越界问题 std::list为空时调用pop_back访问越界问题 所以在使用pop_front . pop_back要先判断list是否为空 st ...
- 22.XML
转载:https://www.cnblogs.com/yuanchenqi/article/5732581.html xml是实现不同语言或程序之间进行数据交换的协议,跟json差不多,但json使用 ...
- 赋值、关系、逻辑运算、if、switch case
cout << boolalpha将打印输出0转为false,1转为true 逻辑运算符: &&(与) 且 两个条件为真时结果为真 ||(或) 或 两个 ...
- Java 从入门到进阶之路(十九)
在之前的文章我们介绍了一下 Java 中的Object,本章我们来看一下 Java 中的包装类. 在 Java 中有八个基本类型:byte,short,int,long,float,double,ch ...
- python3.6中使用selenium + chromedriver访问Chrome浏览器时报错
from selenium import webdriver from selenium.webdriver.chrome.options import Options if __name__ == ...
- 清晰架构(Clean Architecture)的Go微服务: 日志管理
良好的日志记录可以提供丰富的日志数据,便于在调试时发现问题,从而大大提高编码效率. 记录器提供的自动化信息越多越好,日志信息也需要以简洁的方式呈现,便于找到重要的数据. 日志需求: 无需修改业务代码即 ...
- 【题解】有标号的DAG计数2
[HZOI 2015] 有标号的DAG计数 II \(I\)中DP只有一个数组, \[ dp_i=\sum{i\choose j}2^{j(i-j)}dp_{i-j}(-1)^{j+1} \] 不会. ...
- Django进阶一
目录 表关系创建 django请求生命周期流程 路由层 无名分组 有名分组 反向解析 路由分发 名称空间 虚拟环境 django版本区别 伪静态 视图层 三板斧 JsonResponse前后端交互数据 ...
- Java环境准备
电脑重装系统了,所以需要重新配置环境变量. 首先必备工具:jak.eclipse.maven.tomcat 首先配置Java运行环境. 在系统环境变量中新建变量JAVA_HOME:jdk所在的路径,P ...