-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathopencvfacerecognizer.h
More file actions
74 lines (58 loc) · 1.46 KB
/
Copy pathopencvfacerecognizer.h
File metadata and controls
74 lines (58 loc) · 1.46 KB
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
#ifndef OPENCVFACERECOGNIZER_H
#define OPENCVFACERECOGNIZER_H
#include <QObject>
#include <vector>
#include <string>
#include "typedef.h"
class OpencvFaceRecognizer : public QObject
{
Q_OBJECT
public:
typedef enum {
FaceRecognizer_Invalid,
FaceRecognizer_Fisher,
FaceRecognizer_Eigen,
FaceRecognizer_LBPH
} FaceRecognizerType;
explicit OpencvFaceRecognizer(QObject *parent = 0);
~OpencvFaceRecognizer();
void loadRecognizer(FaceRecognizerType type = FaceRecognizer_Eigen);
public slots:
void train(Mats src, Ints labels) {
if (!m_ptr.empty()) {
m_ptr->train(src, labels);
m_hadLoad = true;
}
}
void update(Mats src, Ints labels) {
if (!m_ptr.empty()) {
m_ptr->update(src, labels);
m_hadLoad = true;
}
}
int predict(cv::Mat src) const {
int re = -1;
if (!m_ptr.empty() && m_hadLoad) {
re = m_ptr->predict(src);
emit who(re);
}
return re;
}
void save(const std::string& filename) const {
if (!m_ptr.empty()) {
m_ptr->save(filename);
}
}
void load(const std::string& filename) {
if (!m_ptr.empty()) {
m_ptr->load(filename);
}
}
signals:
void who(int i) const;
private:
FaceRecognizerType m_type;
bool m_hadLoad;
cv::Ptr<cv::FaceRecognizer> m_ptr;
};
#endif // OPENCVFACERECOGNIZER_H