如何快糙好猛的使用libfacedetection库【最新版】
前言
最近已经很少看CSDN了。这一年多准备考研,基本上怕是不会再怎么上了。以前有一个http://blog.csdn.net/mr_curry/article/details/51804072 如何快糙好猛的使用Shiqi.Yu老师的公开人脸检测库(附源码)的BLOG,因为于老师的库已经更新了,所以重新写一下吧。
PS:这个库越来越强了,已经可以做人脸关键点检测了。关键点检测可以用于矫正人脸,再也不要用慢的要死的dlib啦~~
配置
五张图带你解决问题:(X64,Debug)
然后你需要把opencv的属性表也引进来:
两个方法,加系统变量或者放到和exe同一个文件夹下。加了系统变量后重启一次才生效,所以这里就直接放咯
代码
我们直接用FDDB上评测效果最好的函数:facedetect_multiview_reinforce
#include <opencv.hpp>
#include <facedetect-dll.h>
using namespace cv;
using namespace std;
//define the buffer size. Do not change the size!
#define DETECT_BUFFER_SIZE 0x20000
int main()
{
int * pResults = NULL;
//pBuffer is used in the detection functions.
//If you call functions in multiple threads, please create one buffer for each thread!
unsigned char * pBuffer = (unsigned char *)malloc(DETECT_BUFFER_SIZE);
if (!pBuffer)
{
fprintf(stderr, "Can not alloc buffer.\n");
return -1;
}
Mat src = imread("img.jpg");
Mat gray;
cvtColor(src, gray, CV_BGR2GRAY);
int doLandmark = 1;// do landmark detection
pResults = facedetect_multiview_reinforce(pBuffer, (unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, (int)gray.step,
1.2f, 2, 48, 0, doLandmark);
//print the detection results
for (int i = 0; i < (pResults ? *pResults : 0); i++)
{
short * p = ((short*)(pResults + 1)) + 142 * i;
rectangle(src, Rect(p[0], p[1], p[2], p[3]), Scalar(0, 255, 0), 2);
if (doLandmark)
{
for (int j = 0; j < 68; j++)
circle(src, Point((int)p[6 + 2 * j], (int)p[6 + 2 * j + 1]), 1, Scalar(0, 0, 255),2);
}
}
imshow("Show", src);
waitKey(0);
}
效果还是很赞:
视频流中的人脸检测代码就是用VideoCapture解析为Mat然后循环检测啊:
#include <opencv.hpp>
#include <facedetect-dll.h>
using namespace cv;
using namespace std;
//define the buffer size. Do not change the size!
#define DETECT_BUFFER_SIZE 0x20000
int main()
{
int * pResults = NULL;
//pBuffer is used in the detection functions.
//If you call functions in multiple threads, please create one buffer for each thread!
unsigned char * pBuffer = (unsigned char *)malloc(DETECT_BUFFER_SIZE);
if (!pBuffer)
{
fprintf(stderr, "Can not alloc buffer.\n");
return -1;
}
int doLandmark = 1;// do landmark detection
VideoCapture cap(0);
if (!cap.isOpened()){
cout << "Please check your USB camera's interface num." << endl;
return 0;
}
Mat src;
while (true)
{
cap >> src;
if (!src.empty()){
Mat gray;
cvtColor(src, gray, CV_BGR2GRAY);
pResults = facedetect_multiview_reinforce(pBuffer, (unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, (int)gray.step,
1.2f, 2, 48, 0, 1);
for (int i = 0; i < (pResults ? *pResults : 0); i++)
{
short * p = ((short*)(pResults + 1)) + 142 * i;
rectangle(src, Rect(p[0], p[1], p[2], p[3]), Scalar(0, 255, 0), 2);
if (doLandmark)
{
for (int j = 0; j < 68; j++)
circle(src, Point((int)p[6 + 2 * j], (int)p[6 + 2 * j + 1]), 1, Scalar(0, 0, 255), 2);
}
}
imshow("Show", src);
waitKey(1);
}
}
}
如何快糙好猛的使用libfacedetection库【最新版】的更多相关文章
- 如何快糙好猛的使用Shiqi.Yu老师的公开人脸检测库(附源码)
前言 本次编写所用的库为于仕祺老师免费提供的人脸检测库.真心好用,识别率和识别速度完全不是Opencv自带的程序能够比拟的.将其配合Opencv的EigenFace算法,基本上可以形成一个小型的毕业设 ...
- 怎样快糙猛的开始搞Kaggle比赛
- SAP 出库单新版
*&---------------------------------------------------------------------* *& Report ZSDR045 ...
- 人脸识别-<转>
人脸检测库libfacedetection介绍 libfacedetection是于仕琪老师放到GitHub上的二进制库,没有源码,它的License是MIT,可以商用.目前只提供了windows 3 ...
- android 开发必用的开源库
LogReport: https://github.com/wenmingvs/LogReport, 崩溃日志上传框架 wcl-permission-demo:Android 6.0 - 动态权 ...
- Git学习笔记(三)远程库(GitHub)协同开发,fork和忽略特殊文件
远程库 远程库,通俗的讲就是不再本地的git仓库!他的工作方式和我们本地的一样,但是要使用他就需要先建立连接! 远程库有两种,一个是自己搭建的git服务器:另一种就是使用GitHub,这个网站就是提供 ...
- c协程库libco几点体会
https://www.cnblogs.com/dearplain/p/9820913.html 这里说的是Tencent开源的libco. libco的用途和依赖 主要还是c/c++服务端,相比li ...
- Dalvik模式下在Android so库文件.init段、.init_array段构造函数上下断点
本文博客地址:http://blog.csdn.net/qq1084283172/article/details/78244766 在前面的博客<在Android so文件的.init..ini ...
- php大力力 [037节] Iconfont-阿里巴巴矢量图标库
Iconfont-阿里巴巴矢量图标库 从此不求人:自主研发一套PHP前端开发框架 Iconfont-中国第一个最大且功能最全的矢量图标库,提供矢量图标下载.在线存储.格式转换等功能.阿里巴巴体验团队倾 ...
随机推荐
- Android学习笔记之按键操作
我们如何和Android 程序来进行交互那份?来让 Android 程序产生相应的反应,我们不得不通过键盘事件.触摸事件.传感器事件等来实现. 键盘是Android中主要的输入设备,对按键的响应的处理 ...
- HTML基础第十一讲---背景标志
转自:https://i.cnblogs.com/posts?categoryid=1121494 您是否老觉得网页「空空的」,没错!一个可能是我们还没有很多内容,另一个可能则是我们还没有设定网页背景 ...
- VUE笔记 - 品牌后台 - v-for Splice Some Filter findIndex indexOf 直接return函数结果
<body> <div id="app"> <div class="panel panel-primary"> <di ...
- 边缘独立(marginal independent)的理解及举例
1. 定义 ∀xi∈dom(X),yj∈dom(Y),yk∈dom(Y),如果满足, P(X=xi|Y=yj)==P(X=xi|Y=yk)P(X=Xi) 则称随机变量 X 边缘独立于随机变量 Y. 理 ...
- loadrunne-- Analysis 分析器
本文转自:https://www.cnblogs.com/Chilam007/p/6445165.html Analysis简介 分析器就是对测试结果数据进行分析的组件,它是LR三大组件之一,保存着大 ...
- set_fix_multiple_port_nets
set_fix_multiple_port_nets -all -buffer_constants 加上这个命令之后 综合之后的网表就不会出现assign语句 否则会出现
- [React Intl] Format Numbers with Separators and Currency Symbols using react-intl FormattedNumber
Using a react-intl FormattedNumber component, we'll pass a Number and a few additional props in orde ...
- xml 标准字符过滤
今天在代码里面看见一串非常奇怪的推断语句 if (c < 0x9 || c > 0x9 && c < 0xA || c > 0xA && c & ...
- mootools常用特性和示例(基础篇2)
接着上一篇:mootools常用特性和示例(基础篇1) 1.表单操作 html: <form id="myForm" action="submit.php" ...
- 怎样在一个fragment or 随意类中操作还有一个fragment中的方法
1 怎样在acitivty中运行fragment中的方法: 首先获得这个Fragment的对象 xxxFragment fragmentObject = (xxxFragment) getFragme ...