1 Star 0 Fork 2

yanan/faceHttpd

forked from 樊智慧/faceHttpd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
face_container.h 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
樊智慧 提交于 2019-07-22 18:06 +08:00 . 局部调整
/*************************************************************************
> File Name: face_container.h
> Author: fanzhihui
> Mail: 953106194@qq.com
> Created Time: Fri 14 Jun 2019 05:45:23 PM CST
************************************************************************/
#ifndef __FHTTPD_FACE_CONTAINER_H__
#define __FHTTPD_FACE_CONTAINER_H__
#include<iostream>
#include <vector>
#include <map>
#include <string>
#include <memory>
#include <mutex>
#include <exception>
#include <set>
#include "face_info.h"
#include "face_serialize.h"
using namespace std;
struct kown_face_node_
{
kown_face_info_t info;
shared_ptr<kown_face_node_> next;
shared_ptr<kown_face_node_> pre;
};
typedef struct kown_face_node_ kown_face_node_t;
class KownFaceList
{
public:
KownFaceList()
{
}
~KownFaceList()
{
clear();
}
bool add(const std::string& key,const kown_face_info_t& in);
bool find(const std::string& key,kown_face_info_t& out);
bool remove(const std::string& key,kown_face_info_t& del);
bool update(const std::string& key, const kown_face_info_t& in);
void clear();
void allFace(std::vector<kown_face_info_t>& all);
inline uint32_t size(){
return mapKownFace.size();
}
void reset(){
cur = head;
}
bool next(kown_face_info_t& face){
if(cur == tail){
return false;
}
face = cur->info;
cur = cur->next;
}
private:
shared_ptr<kown_face_node_> head;
shared_ptr<kown_face_node_> tail;
std::map<std::string,/*key*/ shared_ptr<kown_face_node_> > mapKownFace;
shared_ptr<kown_face_node_> cur;
};
class FaceContainerException : public std::exception
{
public:
FaceContainerException(const std::string& message):
msg(message)
{
}
const char* what() const noexcept override {
return msg.c_str();
}
private:
std::string msg;
};
class FaceContainer
{
public:
static FaceContainer* getInstance() {
//if(!instance) {
// instance = new FaceContainer();
//}
static FaceContainer instance;
return &instance;
}
void Init(shared_ptr<FaceSerializeIf> serialize);
void AddFace(const std::string& id, const std::string& key, const std::string& image,bool overrid);
void RemoveFace(const std::string& id);
//匹配人脸,返回score
void FindFace(const std::string& image, string& face_id,string& face_key,float& score);
void ClearFace();
private:
FaceContainer();
FaceContainer(const FaceContainer&);
FaceContainer& operator=(const FaceContainer&);
std::string Key(const std::string& face_id,const std::string& face_key);
shared_ptr<FaceSerializeIf> faceSerial;
map<string,/*face id*/std::set<string> /*keys*/ > id2Keys;
KownFaceList kownFaces;
std::mutex locker;
};
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/chukin007/faceHttpd.git
git@gitee.com:chukin007/faceHttpd.git
chukin007
faceHttpd
faceHttpd
20190718

搜索帮助