-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithms.h
More file actions
136 lines (99 loc) · 3.81 KB
/
algorithms.h
File metadata and controls
136 lines (99 loc) · 3.81 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*! \file algorithms.h
\brief Computer vision algorithms for eyes tracking and image computing.
This file containe original computer vision algorithms for eyes tracking and image computing
on the base of OpenCV.
*/
#ifndef ALGORITHMS_H
#define ALGORITHMS_H
#include <iostream>
#include <vector>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;
/*! \var CvHaarClassifierCascade* face_cascade
\brief Contains the haar cascade to detect the face.
*/
extern CvHaarClassifierCascade *face_cascade;
/*! \var CvHaarClassifierCascade* left_eye_cascade
\brief Contains the haar cascade to detect the left eye.
*/
extern CvHaarClassifierCascade *left_eye_cascade;
/*! \var CvHaarClassifierCascade* right_eye_cascade
\brief Contains the haar cascade to detect the right eye.
*/
extern CvHaarClassifierCascade *right_eye_cascade;
/*! \enum OBJECT
\brief Is used for specify, face or one of eyes will be used.
*/
enum OBJECT {
FACE,
LEFT_EYE,
RIGHT_EYE
};
struct edge {
int index;
int square;
edge(int i, int s) : index(i), square(s) { }
bool operator<(const edge &str) const {
return (square > str.square);
}
};
/*! \fn void DrawRect(CvRect rect, int r, int g, int b, IplImage* &frame)
\brief Draws a rectangle on an image.
\param rect Rectangle to draw.
\param r Red component of the lines color.
\param g Green component of the lines color.
\param b Blue component of the lines color.
\param frame Image to draw on.
*/
void DrawRect(CvRect rect, int r, int g, int b, IplImage *&frame);
void DrawRhombus(int* params, int r, int g, int b, int height, int width, IplImage* &frame);
/*! \fn void InitCascades()
\brief Initialize haar cascades.
*/
void InitCascades();
/*! \fn CvRect Find(OBJECT obj,IplImage* frame,bool &status,CvRect* area=0)
\brief Find an object on an image.
\param obj Object to find.
\param frame Image to draw on.
\param status Parametr is set "true", when function ends succesfully, or "false" in other case.
\param area Specify area to find on.
*/
CvRect Find(OBJECT obj, IplImage *frame, bool &status, CvRect *area = 0, float resize_koeff = 1);
/*! \fn CvRect ClarifyArea(OBJECT obj,CvRect* area)
\brief Adapts face area to find one of the eyes.
\param obj Object to find.
\param frame Image to draw on.
\param status Parametr is set "true", when function ends succesfully, or "false" in other case.
\param area Specify area to find on.
*/
CvRect ClarifyArea(OBJECT obj, CvRect *area);
/*! \fn void ExpandArea(CvRect &area,float koeff)
\brief Expands the area.
\param area Area to expand.
\param koeff Expanding coefficient.
*/
void ExpandArea(CvRect &area, float koeff);
/*! \fn bool EyesCorrect(CvRect left_eye, CvRect right_eye, IplImage *frame)
\brief Returns "true" when found eyes seem to be correct, or "false" in other case.
\param left_eye Left eye area.
\param right_eye Right eye area.
\param frame Image where eye were found.
*/
bool EyesCorrect(CvRect left_eye, CvRect right_eye, IplImage *frame);
float DistanceToMonitor(CvRect left_eye, CvRect right_eye, int centers_coeff, IplImage *frame);
int CalcEdgeSquare(int **mass, int i, int j, int z);
/*! \fn int GetEyeDist(IplImage* frame)
\brief Gets distanse between eyelids.
\param frame Image where eye were found.
*/
int *GetEyeDist(IplImage *frame);
CvPoint GetEyesCenter(CvRect left_eye, CvRect right_eye);
float GetDistanceBetweenEyes(CvRect left_eye, CvRect right_eye);
CvRect BuildFace(float cur_face_up_koeff, float cur_face_down_koeff, float cur_face_side_koeff, CvRect left_eye,
CvRect right_eye);
#endif // ALGORITHMS_H