人脸检测库libfacedetection介绍
libfacedetection是于仕琪老师放到GitHub上的二进制库,没有源码,它的License是MIT,可以商用。目前只提供了windows 32和64位的release动态库,主页为https://github.com/ShiqiYu/libfacedetection,采用的算法好像是Multi-BlockLBP,提供了四套接口,分别为frontal、frontal_surveillance、multiview、multiview_reinforce,其中multiview_reinforce效果最好,速度比其它稍慢,四套接口的参数类型完全一致,可以根据需要对参数min_neighbors和min_object_width进行调整。
新建一个控制台工程,用来测试libfacedetection,测试代码如下:
#include <iostream>
#include <string>
#include <vector>
#include <facedetect-dll.h>
#include <opencv2/opencv.hpp>
int main()
{
std::vector<std::string> images{ "1.jpg", "2.jpg", "3.jpg", "4.jpeg", "5.jpeg", "6.jpg", "7.jpg", "8.jpg", "9.jpg", "10.jpg",
"11.jpeg", "12.jpg", "13.jpeg", "14.jpg", "15.jpeg", "16.jpg", "17.jpg", "18.jpg", "19.jpg", "20.jpg" };
std::vector<int> count_faces{1, 2, 6, 0, 1, 1, 1, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0, 8, 2};
std::string path_images{ "E:/GitCode/Face_Test/testdata/" };
if (images.size() != count_faces.size()) {
fprintf(stderr, "their size that images and count_faces are mismatch\n");
return -1;
}
typedef int* (*detect_face)(unsigned char * gray_image_data, int width, int height, int step,
float scale, int min_neighbors, int min_object_width, int max_object_width);
detect_face detect_methods[]{
&facedetect_frontal,
&facedetect_multiview,
&facedetect_multiview_reinforce,
&facedetect_frontal_surveillance
};
std::string detect_type[4] {"face frontal", "face multiview", "face multiview reinforce", "face surveillance"};
for (int method = 0; method < 4; method++) {
detect_face detect = detect_methods[method];
fprintf(stderr, "detect type: %s\n", detect_type[method].c_str());
for (int i = 0; i < images.size(); i++) {
cv::Mat src_ = cv::imread(path_images + images[i], 1);
if (src_.empty()) {
fprintf(stderr, "read image error: %s\n", images[i].c_str());
return -1;
}
cv::Mat src;
cv::cvtColor(src_, src, CV_BGR2GRAY);
int* results = nullptr;
results = detect(src.data, src.cols, src.rows, src.step, 1.2f, 2, 10, 0);
std::string save_result = path_images + std::to_string(method) + "_" + images[i];
//fprintf(stderr, "save result: %s\n", save_result.c_str());
for (int faces = 0; faces < (results ? *results : 0); faces++) {
short* p = ((short*)(results + 1)) + 6 * faces;
int x = p[0];
int y = p[1];
int w = p[2];
int h = p[3];
int neighbors = p[4];
int angle = p[5];
fprintf(stderr, "image_name: %s, faces_num: %d, face_rect=[%d, %d, %d, %d], neighbors=%d, angle=%d\n",
images[i].c_str(), *results, x, y, w, h, neighbors, angle);
cv::rectangle(src_, cv::Rect(x, y, w, h), cv::Scalar(0, 255, 0), 2);
}
cv::imwrite(save_result, src_);
}
}
int width = 200;
int height = 200;
cv::Mat dst(height * 5, width * 4, CV_8UC3);
for (int i = 0; i < images.size(); i++) {
std::string input_image = path_images + "2_" + images[i];
cv::Mat src = cv::imread(input_image, 1);
if (src.empty()) {
fprintf(stderr, "read image error: %s\n", images[i].c_str());
return -1;
}
cv::resize(src, src, cv::Size(width, height), 0, 0, 4);
int x = (i * width) % (width * 4);
int y = (i / 4) * height;
cv::Mat part = dst(cv::Rect(x, y, width, height));
src.copyTo(part);
}
std::string output_image = path_images + "result.png";
cv::imwrite(output_image, dst);
fprintf(stderr, "ok\n");
return 0;
}
张图像,验证此库的检测率,下图是采用multiview_reinforce接口的检测结果:
GitHub:https://github.com/fengbingchun/Face_Test
人脸检测库libfacedetection介绍的更多相关文章
- 【计算机视觉】如何使用于仕琪老师的libfacedetect人脸检测库
前言 最近又开始进行人脸检测方向的内容,看到于仕琪老师的多角度检测想试一下,还不清楚原理,先测试效果如何. libfacedetect人脸检测库是深圳大学于仕琪老师发布的开源库,与opencv自带的人 ...
- 基于Android平台的简易人脸检测库
代码地址如下:http://www.demodashi.com/demo/12135.html ViseFace 简易人脸检测库,不依赖三方库,可快速接入人脸检测功能. 项目依赖:compile 'c ...
- 如何快糙好猛的使用Shiqi.Yu老师的公开人脸检测库(附源码)
前言 本次编写所用的库为于仕祺老师免费提供的人脸检测库.真心好用,识别率和识别速度完全不是Opencv自带的程序能够比拟的.将其配合Opencv的EigenFace算法,基本上可以形成一个小型的毕业设 ...
- [转]40多个关于人脸检测/识别的API、库和软件
[转]40多个关于人脸检测/识别的API.库和软件 http://news.cnblogs.com/n/185616/ 英文原文:List of 40+ Face Detection / Recogn ...
- 40多个关于人脸检测/识别的API、库和软件
英文原文:List of 40+ Face Detection / Recognition APIs, libraries, and software 译者:@吕抒真 译文:链接 自从谷歌眼镜被推出以 ...
- 转:40多个关于人脸检测/识别的API、库和软件
文章来自于:http://blog.jobbole.com/45936/ 自从谷歌眼镜被推出以来,围绕人脸识别,出现了很多争议.我们相信,不管是不是通过智能眼镜,人脸识别将在人与人交往甚至人与物交互中 ...
- [深度学习工具]·极简安装Dlib人脸识别库
[深度学习工具]·极简安装Dlib人脸识别库 Dlib介绍 Dlib是一个现代化的C ++工具箱,其中包含用于在C ++中创建复杂软件以解决实际问题的机器学习算法和工具.它广泛应用于工业界和学术界,包 ...
- 第九节、人脸检测之Haar分类器
人脸检测属于计算机视觉的范畴,早期人们的主要研究方向是人脸识别,即根据人脸来识别人物的身份,后来在复杂背景下的人脸检测需求越来越大,人脸检测也逐渐作为一个单独的研究方向发展起来. 目前人脸检测的方法主 ...
- 手把手教你 在Pytorch框架上部署和测试 关键点人脸检测项目DBFace,成功实现人脸检测效果
这期教向大家介绍仅仅 1.3M 的轻量级高精度的关键点人脸检测模型DBFace,并手把手教你如何在自己的电脑端进行部署和测试运行,运行时bug解决. 01. 前言 前段时间DBFace人脸检测库横空出 ...
随机推荐
- JAVA串口开发帮助类分享-及写在马年末
摘要: 在系统集成开发过程中,存在着各式的传输途径,其中串口经常因其安全性高获得了数据安全传输的重用,通过串口传输可以从硬件上保证数据传输的单向性,这是其它介质所不具备的物理条件.下面我就串口java ...
- 安装MySql-Python遇到的错误及解决方法
用pip安装mysql-python时报错: _mysql.c _mysql.c(42) : fatal error C1083: Cannot open include file: 'config- ...
- 模式:模版、样式;属于分类、识别的范围;分类、归类的标准-How are patterns obtained?
模式及套路 模式:模版.样式:属于分类.识别的范围. How are patterns obtained? Through : re-use, classification and finally a ...
- UVA11987 【Almost Union-Find】
这是一道神奇的题目,我调了大概一天多吧 首先hack一下翻译,操作3并没有要求查询后从其所在集合里删除该元素 于是我们来看一下这三个操作 第一个合并属于并查集的常规操作 第三个操作加权并查集也是可以解 ...
- 全新释放 | RealSight APM, 让客户的极致数字体验成为可能
根据专业评测机构 downdetector.com 统计,2018年,Facebook 系统全年宕机 200 次,Youtube 宕机 140 次,Google 宕机 100 次.每次宕机损失至少 ...
- 最简单的Servlet继承HttpServlet查询数据库登录验证
<%-- Created by IntelliJ IDEA. User: yunqing Date: 2017-12-06 Time: 9:11 To change this template ...
- mybatis框架的核心配置Mapper.xml
映射管理器resultMap:映射管理器,是Mybatis中最强大的工具,使用其可以进行实体类之间的关系,并管理结果和实体类间的映射关系 需要配置的属性:<resultMap id=" ...
- 手工检测SQL注入(安全性测试)
手动你的ASP站可否注入: http://127.0.0.1/xx?id=11 and 1=1 (正常页面) http://127.0.0.1/xx?id=11 and 1=2 (出错页面) 检测表段 ...
- 第24章 QSPI—读写串行FLASH
本章参考资料:<STM32F76xxx参考手册>.<STM32F76xxx规格书>.库帮助文档<STM32F779xx_User_Manual.chm>及<S ...
- mysql 修改数据类型
只修改列的数据类型的方法: 通常可以写成 alter table 表名 modify column 列名 新的列的类型 例如:student表中列sname的类型是char(20),现在要修改为var ...