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 协方差矩阵 首先需要了解一下公式: 共公式可以看出:均值描述的是样本集合的平均值,而标准差描述的则是样本 ...
随机推荐
- 大数据之路week07--day06 (Sqoop 的安装及配置)
Sqoop 的安装配置比较简单. 提供安装需要的安装包和连接mysql的驱动的百度云链接: 链接:https://pan.baidu.com/s/1pdFj0u2lZVFasgoSyhz-yQ 提取码 ...
- 找回IntelliJ IDEA中丢失的Run Dashboard视图
一般项目中包含多个springboot项目的时候都会出现run dashboard视图,但如果一开始它提示的时候,不点击展示,就再也找不到这个视图了,给我们后续启动一个一个的启动项目带来了很大的不便, ...
- webpack起服务器报JavaScript heap out of memory
配置如下: { "scripts": { "start": "node --max_old_space_size=4096 node_modules/ ...
- 【DP】 路面修整 usaco 2008 feb_gold
题目描述: ``` FJ打算好好修一下农场中某条凹凸不平的土路.按奶牛们的要求,修好后的路面高度应当单调上升或单调下降,也就是说,高度上升与高度下降的路段不能同时出现在修好的路中. 整条路被分成了N段 ...
- postgresql分布式集群之citus简介(转载)
一.Citus是什么 citus是PG的一个sharding插件,可以把PG变成一个分布式数据库.目前在苏宁有大量的生产应用跑在citus+pg的环境中.大家可以看it大咖视频. citus是一款基于 ...
- Js验证正则表达式
//验证是否手机 var base = Objcet();base.isPhone = function(num) { var preg = /^1[3-7,8]{1}[0-9]{9}$/; retu ...
- 11、spark内核架构剖析与宽窄依赖
一.内核剖析 1.内核模块 1.Application 2.spark-submit 3.Driver 4.SparkContext 5.Master 6.Worker 7.Executor 8.Jo ...
- OpenStack RPC框架解析
1 消息队列Rabbitmq介绍 Rabbitmq的整体架构图 (1)Rabbitmq Server:中间那部分就是Rabbitmq Server,也叫broken server,主要是负责消息的传 ...
- 如何解决金蝶IKernel.exe报错 Windows Installer 错误 重新安装、无法卸载
如何解决金蝶IKernel.exe报错 Windows Installer 错误 金蝶这个小婊子,就是这么贱. 卸载了高版本的,再安装低版本就不能安装上,死活都不能安装. 请手动启动一下Install ...
- android studio 使用第三方模拟器连接方法
安装完模拟器后,要使用adb命令Android studio才能识别出来: 打开cmd,输入:adb connect 127.0.0.1:26944.如下: 海马玩模拟器的端口号是26944. 逍遥安 ...