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接口的检测结果:

GitHubhttps://github.com/fengbingchun/Face_Test

人脸检测库libfacedetection介绍的更多相关文章

  1. 【计算机视觉】如何使用于仕琪老师的libfacedetect人脸检测库

    前言 最近又开始进行人脸检测方向的内容,看到于仕琪老师的多角度检测想试一下,还不清楚原理,先测试效果如何. libfacedetect人脸检测库是深圳大学于仕琪老师发布的开源库,与opencv自带的人 ...

  2. 基于Android平台的简易人脸检测库

    代码地址如下:http://www.demodashi.com/demo/12135.html ViseFace 简易人脸检测库,不依赖三方库,可快速接入人脸检测功能. 项目依赖:compile 'c ...

  3. 如何快糙好猛的使用Shiqi.Yu老师的公开人脸检测库(附源码)

    前言 本次编写所用的库为于仕祺老师免费提供的人脸检测库.真心好用,识别率和识别速度完全不是Opencv自带的程序能够比拟的.将其配合Opencv的EigenFace算法,基本上可以形成一个小型的毕业设 ...

  4. [转]40多个关于人脸检测/识别的API、库和软件

    [转]40多个关于人脸检测/识别的API.库和软件 http://news.cnblogs.com/n/185616/ 英文原文:List of 40+ Face Detection / Recogn ...

  5. 40多个关于人脸检测/识别的API、库和软件

    英文原文:List of 40+ Face Detection / Recognition APIs, libraries, and software 译者:@吕抒真 译文:链接 自从谷歌眼镜被推出以 ...

  6. 转:40多个关于人脸检测/识别的API、库和软件

    文章来自于:http://blog.jobbole.com/45936/ 自从谷歌眼镜被推出以来,围绕人脸识别,出现了很多争议.我们相信,不管是不是通过智能眼镜,人脸识别将在人与人交往甚至人与物交互中 ...

  7. [深度学习工具]·极简安装Dlib人脸识别库

    [深度学习工具]·极简安装Dlib人脸识别库 Dlib介绍 Dlib是一个现代化的C ++工具箱,其中包含用于在C ++中创建复杂软件以解决实际问题的机器学习算法和工具.它广泛应用于工业界和学术界,包 ...

  8. 第九节、人脸检测之Haar分类器

    人脸检测属于计算机视觉的范畴,早期人们的主要研究方向是人脸识别,即根据人脸来识别人物的身份,后来在复杂背景下的人脸检测需求越来越大,人脸检测也逐渐作为一个单独的研究方向发展起来. 目前人脸检测的方法主 ...

  9. 手把手教你 在Pytorch框架上部署和测试 关键点人脸检测项目DBFace,成功实现人脸检测效果

    这期教向大家介绍仅仅 1.3M 的轻量级高精度的关键点人脸检测模型DBFace,并手把手教你如何在自己的电脑端进行部署和测试运行,运行时bug解决. 01. 前言 前段时间DBFace人脸检测库横空出 ...

随机推荐

  1. 勒让德定理---阶乘中素因子p的指数

  2. 手把手教你自定义attr

    最近在学习的过程中遇到了自定义的attr和自定义的style.因此各种百度,各种博客的学习,算是有了一个系统的了解.在这里记录下自己的收获. 一.为什么要使用自定义attr以及本文定位 在androi ...

  3. linux解压eclipse启动时无法找到jre环境的解决办法

    使用软链接的方法: 1.打开终端进入到eclipse安装主目录下:mkdir jre 2.cd jre 3.ln -s /home/zhoushuo/app/jdk1.8.0_102/bin bin

  4. Hadoop-2.2.0中文文档—— Common - 超级用户模拟别的用户

    简单介绍 此文档描写叙述了一个超级用户怎样在安全的方式下以还有一用户的名义提交作业或訪问hdfs. Use Case 下一部分描写叙述的的代码演示样例对此用户用例是可用的. 一个username为's ...

  5. 【转】XZip and XUnzip - Add zip and/or unzip to your app with no extra .lib or .dll

    原文:http://www.codeproject.com/Articles/4135/XZip-and-XUnzip-Add-zip-and-or-unzip-to-your-app-w Downl ...

  6. Avito Cool Challenge 2018 C. Colorful Bricks 【排列组合】

    传送门:http://codeforces.com/contest/1081/problem/C C. Colorful Bricks time limit per test 2 seconds me ...

  7. Mac系统下配置JAVA Maven Ant 环境变量

    Mac 启动加载文件位置(可设置环境变量) ------------------------------------------------------- (1)首先要知道你使用的Mac OS X是什 ...

  8. DataTable和Json的相互转换

    1 #region DataTable 转换为Json字符串实例方法 2 /// <summary> 3 /// GetClassTypeJosn 的摘要说明 4 /// </sum ...

  9. 阿里云linux服务器登录失败,Connection closed

    ssh_exchange_identification: read: Connection reset by peer报错如下: [root@izbp17x1~]# ssh admin@139.196 ...

  10. 第20章 USART—串口通讯

    本章参考资料:<STM32F76xxx参考手册>USART章节. 学习本章时,配合<STM32F76xxx参考手册>USART章节一起阅读,效果会更佳,特别是涉及到寄存器说明的 ...