人脸检测库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人脸检测库横空出 ...
随机推荐
- 理解Underscore的设计架构
在一个多月的毕业设计之后,我再次开始了Underscore的源码阅读学习,断断续续也写了好些篇文章了,基本把一些比较重要的或者个人认为有营养的函数都解读了一遍,所以现在学习一下Underscore的整 ...
- Java使用iText生成word文件的完美解决方案(亲测可行)
JAVA生成WORD文件的方法目前有以下种: 一种是jacob 但是局限于windows平台 往往许多JAVA程序运行于其他操作系统 在此不讨论该方案 一种是pio但是他的excel处理很程序 wor ...
- 51nod 1837 砝码称重【数学,规律】
题目链接:51nod 1837 砝码称重 小 Q 有 n 个砝码,它们的质量分别为 1 克. 2 克.……. n 克. 他给 i 克的砝码标上了编号 i (i = 1, 2, ..., n),但是编号 ...
- UVa 11582 - Colossal Fibonacci Numbers!(数论)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- [USACO07OPEN]吃饭Dining
嘟嘟嘟 这应该是网络流入门题之一了,跟教辅的组成这道题很像. 把每一只牛看成书,然后对牛拆点,因为每一只牛只要一份,食物和饮料分别看成练习册和答案. #include<cstdio> #i ...
- [19/04/05-星期五] 多线程_Thread(线程、线条)、基本术语
一.基本概念 多线程是Java语言的重要特性,大量应用于网络编程.服务器端程序的开发,最常见的UI界面底层原理.操作系统底层原理都大量使用了多线程. 我们可以流畅的点击软件或者游戏中的各种按钮,其实, ...
- 计算机名称和IP地址
获取本地IP地址 得到远程机IP地址与描述 若仅仅是查看IP地址
- js 飞机大战
完整文件及代码可以在网盘下载,下载链接为:https://pan.baidu.com/s/1hs7sBUs 密码: d83x 飞机大战css定义: <style> #container{ ...
- 学习openGL一——配置环境
openGL支持很多语言,C#, Java, Python, 和Lua.如果你没有使用C/C++,你必须下载和安装一个openGL包或库. 如果你使用了C/C++,你必须先建立一个编译环境,visua ...
- localStorage和cookie操作
localStorage和cookie操作代码: cookie: { isSupportCookie: function() { return navigator.cookieEnabled; }, ...