-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathopencvfacerecognizer.cpp
42 lines (36 loc) · 983 Bytes
/
opencvfacerecognizer.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
#include "opencvfacerecognizer.h"
#include <QFile>
const char* file = "data/a.fr";
OpencvFaceRecognizer::OpencvFaceRecognizer(QObject *parent) : QObject(parent),
m_type(FaceRecognizer_Invalid),
m_hadLoad(false)
{
}
OpencvFaceRecognizer::~OpencvFaceRecognizer()
{
if (!m_ptr.empty()) {
m_ptr->save(file);
}
}
void OpencvFaceRecognizer::loadRecognizer(FaceRecognizerType type)
{
if (m_type == FaceRecognizer_Invalid && type != FaceRecognizer_Invalid) {
switch (type) {
case FaceRecognizer_Fisher:
m_ptr = cv::createFisherFaceRecognizer();
break;
case FaceRecognizer_Eigen:
m_ptr = cv::createEigenFaceRecognizer();
break;
case FaceRecognizer_LBPH:
m_ptr = cv::createLBPHFaceRecognizer();
default:
break;
}
}
QFile f(file);
if (!m_ptr.empty() && f.exists()) {
m_ptr->load(file);
m_hadLoad = true;
}
}