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 协方差矩阵 首先需要了解一下公式: 共公式可以看出:均值描述的是样本集合的平均值,而标准差描述的则是样本 ...
随机推荐
- 1216 Vue基础
目录 前端框架 Vue 1.简介 1.1 优点 2 使用 2.1 基础 2.2 文本指令 2.3 事件指令 2.4 属性指令 JS面向对象补充 前端框架 angular ---更新程度太快,且不向下兼 ...
- 《少年先疯队》第九次团队作业:Beta冲刺第一天
1.1 今日完成任务情况 姚玉婷:酒店会员中房间管理功能的完善 马丽莎:登录功能测试文档的编写 张 琼:不同用户登录功能的测试,如管理员和会员 孙苗坤:登录功能测试用例的设计 1.2 明天任务安排 ...
- dns-prefetch应用好,网上速度能提高一半!
今天一个朋友给我说在网页上添加dns-prefetch,网页访问速度能提高,于是我百度查询关于dns-prefetch. DNS Prefetch,即DNS预获取,是前端优化的一部分.一般来说,在前端 ...
- postgresql —— 表的继承
示例: CREATE TABLE cities ( --父表 name text, population float, altitude int ); CREATE TABLE capitals ( ...
- win 10 VMware与Hyper-v共存
管理员身份运行命令提示符 cmd bcdedit /copy {current} /d "Windows10 no Hyper-V bcdedit /set {XXXXXXXX-XXXX-X ...
- 题解 UVa11388
题目大意 \(T\) 组数据,每组数据给定两个整数 \(G,L\),输出数对 \(x,y\) 满足 \(GCD(x,y)=G,LCM(x,y)=L\) 且 \(x\) 最小.若无解则输出 \(-1\) ...
- 2019-2020-1 20199312《Linux内核原理与分析》第十一周作业
实验简介 缓冲区溢出是指程序试图向缓冲区写入超出预分配固定长度数据的情况.这一漏洞可以被恶意用户利用来改变程序的流控制,甚至执行代码的任意片段.这一漏洞的出现是由于数据缓冲器和返回地址的暂时关闭,溢出 ...
- centOS下实践查询版本/CPU/内存/硬盘容量等硬件信息
更详细参考: https://blog.csdn.net/dream_broken/article/details/52883883 1.查看内存 DirectMap2M: 33544192 kB [ ...
- MongoDB 复制集监控
1.复制集状态查询:rs.status() 2.查看当前副本集oplog状态:rs.printReplicationInfo() 3.查看复制延迟:rs.printSlaveReplicationIn ...
- c语言实现杨辉三角形
#include <stdio.h> int main(void) { int a[9][9]={}; int i,j; for(i=0;i<9;i++){ for(j=0;j< ...