人脸检测库libfacedetection介绍

article/2025/10/24 21:41:56

libfacedetection是于仕琪老师放到GitHub上的二进制库,没有源码,它的License是MIT,可以商用。目前只提供了windows 32和64位的release动态库,主页为https://github.com/ShiqiYu/libfacedetection,采用的算法好像是Multi-BlockLBP,提供了四套接口,分别为frontalfrontal_surveillancemultiviewmultiview_reinforce,其中multiview_reinforce效果最好,速度比其它稍慢,四套接口的参数类型完全一致,可以根据需要对参数min_neighborsmin_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;
}

从网上找了20张图像,验证此库的检测率,下图是采用multiview_reinforce接口的检测结果:



GitHub:https://github.com/fengbingchun/Face_Test


http://chatgpt.dhexx.cn/article/cPqDwBAv.shtml

相关文章

face_recognition使用:人脸识别开源python库(face_recognition是基于dlib的深度学习人脸识别库)

face_recognition实现人脸识别的思路&#xff1a; &#xff11;.给定想要识别的人脸的图片并对其进行编码&#xff08;每个人只需要一张&#xff09;&#xff0c;并将这些不同的人脸编码构建成一个列表。编码其实就是将人脸图片映射成一个&#xff11;&#xff12;&#xff18;…

C/C++ 计算机视觉库/人脸识别开源软件

计算机视觉库 OpenCV OpenCV是Intel开源计算机视觉库。它由一系列 C 函数和少量 C 类构成&#xff0c;实现了图像处理和计算机视觉方面的很多通用算法。 OpenCV 拥有包括 300 多个C函数的跨平台的中、高层 API。它不依赖于其它的外部库——尽管也可以使用某些外部库。 OpenCV 对…

libfacedetection 人脸检测库的基本使用

目录 1、源码下载 2、编译 3、构建工程 4、个人总结 运行总结&#xff1a; 与CascadeClassifier级联分类器 人脸检测 对比: 1、源码下载 直接从github上克隆项目仓库。 git clone https://github.com/ShiqiYu/libfacedetection.git2、编译 这个项目使用了cmake脚本&#…

人脸检测库libfacedetection使用方法

libfacedetection介绍 libfacedetection是一个开源的人脸检测库&#xff0c;使用C编写&#xff0c;将模型文件转化为C的静态变量&#xff0c;不依赖外部第三方库&#xff0c;使用时可以直接把源代码拷到自己的工程&#xff0c;也可以使用动态库(so)/静态库(a)的方式来调用&…

人脸识别之一图像采集及人脸库的建立

完整人脸识别系统&#xff08;源码教程环境&#xff09;&#xff1a; 开源毕业设计&#xff1a;基于嵌入式ARM-Linux的应用OpenCV和QT实现的人脸识别系统(源码论文) 完全毕设教程&#xff1a;Linux上Opencv与Qt实现的人脸识别的考勤点名/门禁系统(PC与嵌入式ARM版本) 人脸识别…

C++实现人脸识别(百度云平台)

C实现人脸识别&#xff08;百度云平台&#xff09; 项目资源下载 项目思路&#xff1a;opencv 采集人脸照片&#xff0c;将照片发送至百度智能云平台&#xff0c;百度云平台与人脸库中的数据进行比较并返回结果。 一、项目环境 Ubuntu 64 20.0.4 opencv 4.2.0 二、环境配置…

人脸识别开源库

https://blog.csdn.net/qq_42156420/article/details/83445801 以往的人脸识别主要是包括人脸图像采集、人脸识别预处理、身份确认、身份查找等技术和系统。现在人脸识别已经慢慢延伸到了ADAS中的驾驶员检测、行人跟踪、甚至到了动态物体的跟踪。由此可以看出&#xff0c;人脸…

人脸识别——基于DLib库

目录 1.人脸识别的流程 2.ResNet-34算法概述 3.测试准备 4.测试代码 5.测试结果 1.人脸识别的流程 dlib库提供高精度人脸识别算法是基于深度学习网络ResNet-34实现&#xff0c;该网络基于三百万张照片进行训练&#xff0c;最终获得了人脸检测模型。 模型下载地址&#xff…

深度学习系列18:开源人脸识别库

这年头&#xff0c;能有个开源的人脸库真是感天谢地了&#xff0c;而且可以在arm机器上使用&#xff0c;真不容易。git地址见https://github.com/ageitgey/face_recognition 1. 人脸检测 人脸检测可以选hog和cnn两种。默认用hog&#xff08;在cpu上用cnn真的很慢&#xff09;…

人脸识别库的安装

确保你的python为3.6 !!! 1.安装cmake pip install cmake2.安装boost pip install boost3.安装dlib 选择19.8.1 pip install dlib19.8.14.安装face-recognition pip install face-recognition

应用一个基于Python的开源人脸识别库,face_recognition

转载请注明出处&#xff1a;http://blog.csdn.net/hongbin_xu 或 http://hongbin96.com/ 文章链接&#xff1a;http://blog.csdn.net/hongbin_xu/article/details/74981819 或http://hongbin96.com/125 今天看微信时&#xff0c;看到一篇推送文章介绍了一个基于python的开源人…

开源人脸识别库,face_recognition

转载请注明出处&#xff1a;http://blog.csdn.net/hongbin_xu 或 http://hongbin96.com/ 文章链接&#xff1a;http://blog.csdn.net/hongbin_xu/article/details/74981819 或http://hongbin96.com/125 今天看微信时&#xff0c;看到一篇推送文章介绍了一个基于python的开源人…

[深度学习] Python人脸识别库Deepface使用教程

deepface是一个Python轻量级人脸识别和人脸属性分析&#xff08;年龄、性别、情感和种族&#xff09;框架&#xff0c;提供非常简单的接口就可以实现各种人脸识别算法的应用。deepface官方仓库为deepface。deepface提供了多种模型&#xff0c;模型下载地址为deepface_models。 …

[深度学习] Python人脸识别库face_recognition使用教程

Python人脸识别库face_recognition使用教程 face_recognition号称是世界上最简单的开源人脸识别库&#xff0c;可以通过Python或命令行识别和操作人脸。face_recognition提供了十分完整的技术文档和应用实例&#xff0c;人脸识别初学者建议研究该库上手。face_recognition的官…

Face Recognition 库-人脸识别

1. Face Recognition 库简介&#xff1a; 中文文档&#xff1a; [face_recognition/README_Simplified_Chinese.md] Face Recognition 库主要封装了dlib这一 C 图形库&#xff0c;通过 Python 语言将它封装为一个非常简单就可以实现人脸识别的 API 库&#xff0c;屏蔽了人脸识…

应用层下的人脸识别(二):人脸库

本文为系列文章的第二篇&#xff0c;介绍人脸库的相关内容。人脸库是人脸识别的基础&#xff0c;建立人脸库往往是人脸项目的首要任务&#xff0c;全文围绕着什么是人脸库及如何建立人脸库展开讨论。 1. 什么是人脸库 简单来讲&#xff0c;人脸库就是人脸数据的储存管理中心&a…

全国高校计算机能力挑战赛Java试题(一)

消除字符串 这个题目上来就是运用一个回文的一个思想&#xff0c;我目前算法也是入门阶段&#xff0c;所以也处于学习阶段。 public class xiaozfc {public static void main(String[] args) {Scanner sc new Scanner(System.in);String txt sc.next();ArrayList<String&…

Java课程设计--学生成绩管理系统

一、团队名称&#xff1a; 团队成员&#xff1a; 刘江华 2019122249819 19信管专升本杨利杰 2018122241648 18信管本张富强 2018122241658 18信管本 二、需求分析 1.数据存储在数据库和文件中 分为“教师”模块和“学生”模块。 2.学生模块提供登陆功能&#xff0c;登陆成功后…

Java8--20道关于Stream流的题目练习

正题开始 Student 类 具有属性&#xff1a; 不及格次数failCount&#xff0c; 名字name&#xff0c; 科任老师chineseTeacher&#xff0c; 班主任classTeacher题目1&#xff1a;筛选学生不及格次数3次及3次以上的学生列表 List<String> arrayList array.stream().filte…

第十三届蓝桥杯省赛 JAVA B组(真题解析+个人体会)(已更新完G题)

试题 A: 星期计算【填空题】 题目&#xff1a; 答案&#xff1a;7 解析&#xff1a; 此题直接对7求余即可。 public class Main {public static void main(String[] args) {System.out.println(Math.pow(20, 22) % 7 6);} } 贴一个BigInteger的代码 import java.math.Bi…