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 协方差矩阵 首先需要了解一下公式: 共公式可以看出:均值描述的是样本集合的平均值,而标准差描述的则是样本 ...
随机推荐
- 《少年先疯队》第八次团队作业:Alpha冲刺第三天
前言 第三天冲刺会议 时间:2019.6.16 地点:宿舍 3.1 今日完成任务情况以及遇到的问题. 3.1.1今日完成任务情况 姚玉婷:酒店的会员信息的管理,如会员的添加,删除 马 ...
- POJ3709 K-Anonymous Sequence
题意 Language:Default K-Anonymous Sequence Time Limit: 4000MS Memory Limit: 65536K Total Submissions: ...
- 创建型模式(三) 抽象工厂模式(Abstract Factory)
一.动机(Motivation) 在软件系统中,经常面临着“一系列相互依赖的对象”的创建工作:同时,由于需求的变化,往往存在更多系列对象的创建工作. 如何应对这种变化?如何绕过常规的对象创建方法(ne ...
- C++第三章课后作业答案及解析---指针的使用
今天继续完成上周没有完成的习题---C++第三章课后作业,本章题涉及指针的使用,有指向对象的指针做函数参数,对象的引用以及友元类的使用方法等 它们具体的使用方法在下面的题目中会有具体的解析(解析标注在 ...
- HashMap的个别方法
static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // 16 默认初始容量 16 static final int MAXIMUM_C ...
- PCL安装与配置
一.配置环境 1.win7 64位2.Visual Studio 2015 二 .准备工作 安装包准备: 移步:https://www.cnblogs.com/weiyouqing/p/8046387 ...
- 【二分答案】Expanding Rods POJ 1905
题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...
- Linux 命令-egrep
egrep 可以看着是grep的扩展,参数-e支持正则匹配 满足其中任一条件 egrep -e "tiaojian1|tiaojian2" test.txt
- Hdu 2157 How many ways??(DP||矩阵乘法)
How many ways?? Time Limit:1000 MS Memory Limit: 32768 K Problem Description 春天到了, HDU校园里开满了花, 姹紫嫣红, ...
- 9、共享变量(Broadcast Variable和Accumulator)
一.共享变量 1.共享变量工作原理 Spark一个非常重要的特性就是共享变量. 默认情况下,如果在一个算子的函数中使用到了某个外部的变量,那么这个变量的值会被拷贝到每个task中.此时每个task只能 ...