关于单幅多张人脸的关键点定位,怎么拿出来?
jiagh2010 opened this issue · comments
jiagh2010 commented
Mitscherlich Wei commented
示例代码中给的是默认取图片中检测到的第一张人脸 *face
(==face[0]
),按照检测的代码遍历然后分别标定就可以了:
#include <seeta/Struct_cv.h>
#include <seeta/FaceDetector2.h>
#include <seeta/PointDetector2.h>
// 根据文档说明 `seetaface2` 的原生对象只能为单例
seeta::FaceDetector2 FD("bindata/SeetaFaceDetector2.0.ats");
seeta::PointDetector2 PD("bindata/SeetaPointDetector2.0.pts5.ats");
cv::Mat mat = cv::imread("1.jpg");
seeta::cv::ImageData image = mat;
int num; // 人脸数目
SeetaRect *face = FD.Detect(image, &num);
for (int i = 0; i < num; ++i, ++face) {
// 检测到的人脸信息
// std::cout << "Face(" << i << "): " << "(" << face->x << ", " << face->y << ", " << face->width << ", " << face->height << ")" << std::endl;
// 对应的特征点信息 (5点)
SeetaPointF *points = PD.Detect(image, *face);
if (points) {
std::cout << "Points: [" << std::endl;
for (int j = 0; j < PD.LandmarkNum(); ++j) {
std::cout << "(" << points[j].x << ", " << points[j].y << ")," << std::endl;
}
std::cout << "]" << std::endl;
}
}
了解一下。
顺便打个广告:Mitscherlich/node-seeta 是我封装的基于 seetaface2
的 node.js
插件,可以在服务端部署自己的人脸识别算法,还有配套的命令行工具和服务器接口正在开发中。