forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathface.cpp
102 lines (67 loc) · 2.13 KB
/
face.cpp
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "face.h"
LBPHFaceRecognizer CreateLBPHFaceRecognizer() {
return new cv::Ptr<cv::face::LBPHFaceRecognizer>(cv::face::LBPHFaceRecognizer::create());
}
void LBPHFaceRecognizer_Train(LBPHFaceRecognizer fr, Mats mats, IntVector labels_in) {
std::vector<int> labels;
for (int i = 0, *v = labels_in.val; i < labels_in.length; ++v, ++i) {
labels.push_back(*v);
}
std::vector<cv::Mat> images;
for (int i = 0; i < mats.length; ++i) {
images.push_back(*mats.mats[i]);
}
(*fr)->train(images, labels);
return;
}
void LBPHFaceRecognizer_Update(LBPHFaceRecognizer fr, Mats mats, IntVector labels_in) {
std::vector<int> labels;
for (int i = 0, *v = labels_in.val; i < labels_in.length; ++v, ++i) {
labels.push_back(*v);
}
std::vector<cv::Mat> images;
for (int i = 0; i < mats.length; ++i) {
images.push_back(*mats.mats[i]);
}
(*fr)->update(images, labels);
return;
}
int LBPHFaceRecognizer_Predict(LBPHFaceRecognizer fr, Mat sample) {
int label;
label = (*fr)->predict(*sample);
return label;
}
struct PredictResponse LBPHFaceRecognizer_PredictExtended(LBPHFaceRecognizer fr, Mat sample) {
struct PredictResponse response;
int label;
double confidence;
(*fr)->predict(*sample, label, confidence);
response.label = label;
response.confidence = confidence;
return response;
}
void LBPHFaceRecognizer_SetThreshold(LBPHFaceRecognizer fr, double threshold) {
(*fr)->setThreshold(threshold);
return;
}
void LBPHFaceRecognizer_SetRadius(LBPHFaceRecognizer fr, int radius) {
(*fr)->setRadius(radius);
return;
}
void LBPHFaceRecognizer_SetNeighbors(LBPHFaceRecognizer fr, int neighbors) {
(*fr)->setNeighbors(neighbors);
return;
}
int LBPHFaceRecognizer_GetNeighbors(LBPHFaceRecognizer fr) {
int n;
n = (*fr)->getNeighbors();
return n;
}
void LBPHFaceRecognizer_SaveFile(LBPHFaceRecognizer fr, const char* filename) {
(*fr)->write(filename);
return;
}
void LBPHFaceRecognizer_LoadFile(LBPHFaceRecognizer fr, const char* filename) {
(*fr)->read(filename);
return;
}