-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetector.h
53 lines (47 loc) · 1.34 KB
/
detector.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
#ifndef DETECTOR_H
#define DETECTOR_H
#include "cv.h"
#include "highgui.h"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
class Detector
{
//variables
private:
Mat image, spectacles;
Mat specMask;
string imageSrc, spectaclesSrc;
string pathToModels;
bool debug;
CascadeClassifier faceCascade;
CascadeClassifier eyesCascade;
string faceCascadeName;
string eyesCascadeName;
public:
enum Status {
StatusOK = 0,
StatusNoImage = -1,
StatusNoSpectacles = -2,
StatusNoModel = -3,
StatusNotLoaded = -4,
StatusError = -100
};
//methods
private:
Status doLoadImage(const string path, Mat& dest, const string windowName = "");
void doThreshold(const Mat& source, Mat& dest, double thresholdvalue, double maxvalue, int type, bool adaptive = false);
void doMarkObjects(const vector<Rect>& objects, const Scalar color);
void doPutSpectaclesOnFace(const Rect face, vector<Rect>::const_iterator eye);
public:
Detector(bool debug = false);
~Detector();
Status loadImage(const string path);
Status loadSpectacles(const string path);
Status loadModels(const string path);
Status detectAndDraw();
bool isReady();
};
#endif // DETECTOR_H