SeetaFaceDetection识别人脸
SeetaFaceDetection识别人脸
#pragma warning(disable: 4819) #include <seeta/FaceEngine.h> #include <seeta/Struct_cv.h>
#include <seeta/Struct.h> #include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <array>
#include <map>
#include <iostream> #include <qdebug.h>
#include <QDateTime> int main()
{
seeta::ModelSetting::Device device = seeta::ModelSetting::CPU;
int id = ;
seeta::ModelSetting FD_model("E:\\SeetaFaceEngine2\\SeetaFace2_install\\model\\fd_2_00.dat", device, id);
seeta::ModelSetting PD_model("E:\\SeetaFaceEngine2\\SeetaFace2_install\\model\\pd_2_00_pts5.dat", device, id);
seeta::ModelSetting FR_model("E:\\SeetaFaceEngine2\\SeetaFace2_install\\model\\fr_2_10.dat", device, id);
seeta::FaceEngine engine(FD_model, PD_model, FR_model, , ); // recognization threshold
float threshold = 0.5f; //set face detector's min face size
engine.FD.set(seeta::FaceDetector::PROPERTY_MIN_FACE_SIZE, ); //std::vector<std::string> GalleryImageFilename = { "E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\5.jpg" };
std::vector<std::string> GalleryImageFilename = { "E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\1.jpg","E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\2.jpg","E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\3.jpg","E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\4.jpg","E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\5.jpg","E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\6.jpg","E:\\SeetaFaceEngine2\\SeetaFace2_install\\data\\7.jpg" }; std::vector<int64_t> GalleryIndex(GalleryImageFilename.size());
for (size_t i = ; i < GalleryImageFilename.size(); ++i)
{
//register face into facedatabase
std::string &filename = GalleryImageFilename[i];
int64_t &index = GalleryIndex[i];
std::cerr << "Registering... " << filename << std::endl;
seeta::cv::ImageData image = cv::imread(filename);
auto id = engine.Register(image);
index = id;
std::cerr << "Registered id = " << id << std::endl;
}
std::map<int64_t, std::string> GalleryIndexMap;
for (size_t i = ; i < GalleryIndex.size(); ++i)
{
// save index and name pair
if (GalleryIndex[i] < ) continue;
GalleryIndexMap.insert(std::make_pair(GalleryIndex[i], GalleryImageFilename[i]));
} std::cout << "----open camera----" << std::endl;
// Open default USB camera
cv::VideoCapture capture;
capture.open(); cv::Mat frame; int width1 = ;
int height1 = ;
while (capture.isOpened())
{
capture >> frame;
if (frame.empty()) continue; width1 = frame.cols;
height1 = frame.rows;
cv::resize(frame, frame, cv::Size(width1 / , height1 / ));
seeta::cv::ImageData image = frame; // Detect all faces
std::vector<SeetaFaceInfo> faces = engine.DetectFaces(image); for (SeetaFaceInfo &face : faces)
{
// Query top 1
int64_t index = -;
float similarity = ; qDebug() << "-----------------------------------";
//auto points = engine.DetectPoints(image, face);
std::vector<SeetaPointF> points = engine.DetectPoints(image, face);
std::vector<SeetaPointF>::iterator iter_1;
for (iter_1 = points.begin(); iter_1 != points.end();++iter_1)
{
SeetaPointF sp1 = *iter_1;
qDebug() << "x:" << sp1.x << " y:" << sp1.y;
}
qDebug() << "-----------------------------------"; auto queried = engine.QueryTop(image, points.data(), , &index, &similarity); cv::rectangle(frame, cv::Rect(face.pos.x, face.pos.y, face.pos.width, face.pos.height), CV_RGB(, , ), );
for (int i = ; i < ; ++i)
{
auto &point = points[i];
cv::circle(frame, cv::Point(int(point.x), int(point.y)), , CV_RGB(, , ), -);
} // no face queried from database
if (queried < ) continue; std::cout << "similarity:" << similarity << std::endl;
// similarity greater than threshold, means recognized
if (similarity > threshold)
{
std::cout << "person:" << GalleryIndexMap[index] << std::endl;
cv::putText(frame, GalleryIndexMap[index], cv::Point(face.pos.x, face.pos.y - ), , , CV_RGB(, , )); /////////
QDateTime qdt1 = QDateTime::currentDateTime();
QString timeStr = qdt1.toString("yyyyMMddhhmmsszzz");
QString picStr = timeStr.append(".jpg"); cv::imwrite(picStr.toStdString(), frame);
}
} cv::imshow("Frame", frame); auto key = cv::waitKey();
if (key == )
{
break;
}
}
}
SeetaFaceDetection识别人脸的更多相关文章
- 转:基于开源项目OpenCV的人脸识别Demo版整理(不仅可以识别人脸,还可以识别眼睛鼻子嘴等)【模式识别中的翘楚】
文章来自于:http://blog.renren.com/share/246648717/8171467499 基于开源项目OpenCV的人脸识别Demo版整理(不仅可以识别人脸,还可以识别眼睛鼻子嘴 ...
- 写给程序员的机器学习入门 (十) - 对象识别 Faster-RCNN - 识别人脸位置与是否戴口罩
每次看到大数据人脸识别抓逃犯的新闻我都会感叹技术发展的太快了,国家治安水平也越来越好了
- 写给程序员的机器学习入门 (十一) - 对象识别 YOLO - 识别人脸位置与是否戴口罩
这篇将会介绍目前最流行的对象识别模型 YOLO,YOLO 的特征是快,识别速度非常快
- 使用Python结合Face++ API识别人脸
Face++是北京旷视科技旗下的视觉服务平台,可以进行人脸识别.检测等功能.其人脸识别技术据悉在目前准确率较高,其API非常友好,免费使用,功能众多,而且调用几乎没有限制.这里我使用了Python调用 ...
- 使用OpenCV训练好的级联分类器识别人脸
一.使用OpenCV训练好的级联分类器来识别图像中的人脸 当然还有很多其他的分类器,例如表情识别,鼻子等,具体可在这里下载: OpenCV分类器 import cv2 # 矩形颜色和描边 color ...
- 指纹识别人脸识别 iOS
//1.判断iOS8及以后的版本 if([UIDevice currentDevice].systemVersion.doubleValue >= 8.0){ //从iPhone5S开始,出现指 ...
- 用Azure上Cognitive Service的Face API识别人脸
Azure在China已经发布了Cognitive Service,包括人脸识别.计算机视觉识别和情绪识别等服务. 本文将介绍如何用Face API识别本地或URL的人脸. 一 创建Cognitive ...
- 4、基于JZ2440之编写测试代码处理(处理图片识别人脸)
1.代码如下: void detectAndDisplay(Mat image) { CascadeClassifier ccf; //创建脸部对象 //ccf.load(xmlPath); //导入 ...
- OpenCV人脸识别Eigen算法源码分析
1 理论基础 学习Eigen人脸识别算法需要了解一下它用到的几个理论基础,现总结如下: 1.1 协方差矩阵 首先需要了解一下公式: 共公式可以看出:均值描述的是样本集合的平均值,而标准差描述的则是样本 ...
随机推荐
- 简单理解和使用 C# 委托与事件
委托和事件 委托:委托是一个类,它定义了方法的类型,使得可以将方法当作另一个方法的参数来进行传递,这种将方法动态地赋给参数的做法,可以避免在程序中大量使用If-Else(Switch)语句,同时使得程 ...
- dt二次开发之-url伪静态的自定义
dt内核的方便性在于代码内核完全开源,都可以根据自身需要进行优化整改,个人在这段时间的深入研究,发现这套内核的方便性,今天继续给大家分享下DT的url伪静态如何自定义函数. url自定义文件是在api ...
- Default Trace 查找日志文件快速增长的原因
select loginname, loginsid, spid, hostname, applicationname, servername, databasename, objectname, e ...
- YAML_18 ansible 判断和循环
标准循环 模式一 - name: add several users user: name={{ item }} state=present groups=wheel with_items: - te ...
- C函数指针数组的定义和使用
1.使用函数指针数组来实现计算器 2.通过函数指针变量来调用对应的函数 #include <stdio.h> int add(int a,int b){ return a+b; } int ...
- App弱网测试与常用模拟工具
iOS平台,通过自带的开发者选项 >Network Link Conditioner, 即可简单的模拟各种速度的网络情况: 通过抓包工具,设置延迟,进行模拟不同的网络情况,比如常用的fiddle ...
- WEB甘特图(机器运行状态图)
前台框架使用BootStrap轻量级框架AdminLTE 后台框架使用的是Spring.SpringMVC 初此使用数据库SQL Server故只能用JDBC连接 请勿见怪!jsp页面重复添加元素过多 ...
- OSPF区域间+NAT详解
- 浅析HTTP/2的多路复用
HTTP/2有三大特性:头部压缩.Server Push.多路复用.前两个特性意思比较明确,也好理解,唯有多路复用不太好理解,尤其是和HTTP1.1进行对比的时候,这个问题我想了很长时间,也对比了很长 ...
- LDAP服务端 - 调研
一.服务端实现 1.OpenLdap 2.ApacheDS 二.OpenLdap 1.https://segmentfault.com/a/1190000014683418 2.https://www ...