人脸识别引擎SeetaFaceEngine中Alignment模块使用的测试代码
人脸识别引擎SeetaFaceEngine中Alignment模块用于检测人脸关键点,包括5个点,两个眼的中心、鼻尖、两个嘴角,以下是测试代码:
int test_alignment()
{
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 };
const std::string path_images{ "E:/GitCode/Face_Test/testdata/" };
seeta::FaceDetection detector("E:/GitCode/Face_Test/src/SeetaFaceEngine/FaceDetection/model/seeta_fd_frontal_v1.0.bin");
detector.SetMinFaceSize(20);
detector.SetMaxFaceSize(200);
detector.SetScoreThresh(2.f);
detector.SetImagePyramidScaleFactor(0.8f);
detector.SetWindowStep(4, 4);
seeta::FaceAlignment point_detector("E:/GitCode/Face_Test/src/SeetaFaceEngine/FaceAlignment/model/seeta_fa_v1.1.bin");
for (auto name : images) {
fprintf(stderr, "start detect image: %s\n", name.c_str());
cv::Mat src_ = cv::imread(path_images + name, 1);
if (src_.empty()) {
fprintf(stderr, "read image error: %s\n", name.c_str());
continue;
}
cv::Mat src;
cv::cvtColor(src_, src, CV_BGR2GRAY);
seeta::ImageData img_data;
img_data.data = src.data;
img_data.width = src.cols;
img_data.height = src.rows;
img_data.num_channels = 1;
std::vector<seeta::FaceInfo> faces = detector.Detect(img_data);
for (auto face : faces) {
// Detect 5 facial landmarks: two eye centers, nose tip and two mouth corners
seeta::FacialLandmark points[5];
point_detector.PointDetectLandmarks(img_data, face, points);
cv::rectangle(src_, cv::Rect(face.bbox.x, face.bbox.y,
face.bbox.width, face.bbox.height), cv::Scalar(0, 255, 0), 2);
for (auto point : points) {
cv::circle(src_, cv::Point(point.x, point.y), 2, cv::Scalar(0, 0, 255), 2);
}
}
std::string save_result = path_images + "_" + name;
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 + "_" + 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);
return 0;
}
从网上找了20张图像,用于测试此模块,测试结果如下:
GitHub:https://github.com/fengbingchun/Face_Test
人脸识别引擎SeetaFaceEngine中Alignment模块使用的测试代码的更多相关文章
- 人脸识别引擎SeetaFaceEngine中Identification模块使用的测试代码
人脸识别引擎SeetaFaceEngine中Identification模块用于比较两幅人脸图像的相似度,以下是测试代码: int test_recognize() { const std::stri ...
- 人脸识别引擎SeetaFaceEngine中Detection模块使用的测试代码
人脸识别引擎SeetaFaceEngine中Detection模块用于人脸检测,以下是测试代码: int test_detection() { std::vector<std::string&g ...
- 人脸识别引擎SeetaFaceEngine简介及在windows7 vs2013下的编译
SeetaFaceEngine是开源的C++人脸识别引擎,无需第三方库,它是由中科院计算所山世光老师团队研发.它的License是BSD-2. SeetaFaceEngine库包括三个模块:人脸检测( ...
- 【计算机视觉】SeetaFace Engine开源C++人脸识别引擎
SeetaFace Engine是一个开源的C++人脸识别引擎,它可以在不依赖第三方的条件下载CPU上运行.他包含三个关键部分,即:SeetaFace Detection,SeetaFace Alig ...
- Android打开相机进行人脸识别,使用虹软人脸识别引擎
上一张效果图,渣画质,能看就好 功能说明: 人脸识别使用的是虹软的FreeSDK,包含人脸追踪,人脸检测,人脸识别,年龄.性别检测功能,其中本demo只使用了FT和FR(人脸追踪和人脸识别),封装了开 ...
- 教你如何认识人脸识别开发套件中的双目摄像、3D结构光摄像头、单目摄像头的区别及详细讲解
深圳市宁远电子提供的人脸识别模组可支持双目摄像头和3D结构光摄像头,在客户咨询中经常有被问到双目的为什么会比单目的成本高,区别在哪里,他们的适用于哪些场景呢?在此,深圳市宁远电子技术工程师就为大家详细 ...
- 关于人脸识别引擎FaceRecognitionDotNet的实例
根据我上篇文章的分享,我提到了FaceRecognitionDotNet,它是python语言开发的一个项目face_recognition移植.结果真是有喜有忧,喜的是很多去关注了,进行了下载,我看 ...
- 人脸识别引擎SeetaFace编译 ubuntu
00.SeetaFace简介 SeetaFace Engine is an open source C++ face recognition engine, which can run on CPU ...
- .NET的关于人脸识别引擎分享(C#)
https://www.cnblogs.com/RainbowInTheSky/p/10247921.html
随机推荐
- POJ 2407 Relatives 欧拉函数题解
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...
- nd.array.where
http://mxnet.apache.org/api/python/ndarray/ndarray.html#mxnet.ndarray.where Return the elements, eit ...
- [POI2006]TET-Tetris 3D
题目 二维线段树板子题啊 但是惊讶的发现我不会打标记 毕竟内层是线段树不能\(pushup\)也不能\(pushdown\) 于是考虑一下标记永久化 其实非常显然\(mx_i\)表示区间最大值,\(t ...
- windows C++ new/delete内存大小
转载自:https://blog.csdn.net/will_hsbsch/article/details/21124055 windows 上,但使用C++语言new一块内存,用指针P指向这块内存, ...
- 5、Dubbo-监控中心
5.1).dubbo-admin 图形化的服务管理页面:安装时需要指定注册中心地址,即可从注册中心中获取到所有的提供者/消费者进行配置管理 5.2).dubbo-monitor-simple 简单的监 ...
- JavaScript(jQuery)中的事件委托
一:什么是事件委托? 事件委托是利用事件冒泡,只指定一个事件处理程序来管理某一类型的所有事件. 二:为什么要用事件委托? 1.在JavaScript中添加到页面上的事件处理程序的个数直接关系到页面的整 ...
- Linux开启路由的方法
Linux开启路由的命令很简单,只需要一条命令即可: [root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward 这个只是临时修改,如果 ...
- 我的QT5学习之路(一)——浅谈QT的安装和配置
一.前言 说到Qt,不能不说到C++,这门伟大的语言.因为其面向对象的编程思想和陡峭的学习曲线,一开始学习起来很是吃力.Qt从QT4开始基本封装了很多C++的工具库和界面库,而且支持跨平台,这是它最大 ...
- oracle 11GR2 单机打补丁PSU 11.2.0.4.180717
上传补丁包,修改权限 su - oracle mdir /tmp/psu mv p6880880_112319_Linux-x86-64.zip /tmp/psu/mv databasepsu1807 ...
- [ERROR] Can't find error-message file '/data/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
1. MySQL5.7.21启动时报错: [ERROR] Can't find error-message file '/data/mysql/3307/share/errmsg.sys'. Chec ...