forked from Kagami/go-face
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacerec.h
73 lines (56 loc) · 1.66 KB
/
facerec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#ifndef FACEREC_H
#define FACEREC_H
#ifdef __cplusplus
#include <shared_mutex>
#include <dlib/dnn.h>
#include <dlib/image_loader/image_loader.h>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/graph_utils.h>
#include "wrapper.h"
#include "classify.h"
#include "template.h"
typedef matrix<rgb_pixel> image_t;
class FaceRec {
private:
std::mutex detector_mutex_;
std::mutex net_mutex_;
std::shared_mutex samples_mutex_;
dlib::frontal_face_detector detector_;
dlib::shape_predictor sp_;
anet_type net_;
cnn_anet_type cnn_net_;
custom_anet_type custom_cnn_net_;
agender_type gender_net_;
apredictor_t age_net_;
softmax<apredictor_t::subnet_type> snet;
std::vector<descriptor> samples_;
std::vector<int> cats_;
int jittering = 0;
unsigned long size = 150;
double padding = 0.25;
int min_image_size = 0;
public:
FaceRec();
void setCNN(const char*);
void setCustom(const char*);
void setShape(const char*);
void setDescriptor(const char*);
void setGender(const char*);
void setAge(const char* age_path);
void setSize(unsigned long);
void setPadding(double);
void setJittering(int);
void setMinImageSize(int);
facesret* detect(facesret *, image_t &, int);
std::tuple<descriptor, full_object_detection> recognize(image_pointer *);
int gender(image_pointer *);
int age(image_pointer *);
void setSamples(std::vector<descriptor>&&, std::vector<int>&&);
int classify(const descriptor&, float);
};
facesret* facerec_detect(facesret*, facerec*, image_t&, int);
#else
typedef void *image_t;
#endif
#endif /* FACEREC_H */