-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeadPose.hpp
49 lines (41 loc) · 1.42 KB
/
HeadPose.hpp
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
#include <iostream>
#include <vector>
#include <opencv2/opencv.hpp>
//---------------------------------------------------------------------------
using namespace cv;
class HeadPose
{
private:
cv::CascadeClassifier face_cascade, nose_cascade, eye_cascade, left_eye_cascade, right_eye_cascade, mouth_cascade;
std::vector<CvPoint3D32f> modelPoints;
std::vector<CvPoint3D32f> axesPoints;
std::vector<CvPoint2D32f> srcImagePoints;
CvPOSITObject* positObject;
float* rotation_matrix;
float* translation_vector;
CvTermCriteria criteria;
std::vector<CvPoint2D32f> projectedPoints;
std::vector<CvPoint2D32f> projectedOriginalPoints;
CvPoint2D32f m_lastHeadPosition;
int m_FrameHeight;
int m_FrameWidth;
Mat faceTemplate, noseTemplate, leftEyeTemplate, rightEyeTemplate, mouthTemplate;
Mat lastNoseMatch, lastLeftEyeMatch, lastRightEyeMatch, lastMouthMatch;
Rect lastNoseRect, lastLeftEyeRect, lastRightEyeRect, lastMouthRect;
bool m_foundFace;
int match_method;
public:
HeadPose(void);
virtual ~HeadPose(void);
void init(void);
float* getHeadRotationMatrix(void);
float* getHeadPosition();
private:
void detectFaceFeatures(Mat &inputImage);
void trackFaceFeatures(Mat &inputImage);
Rect getMatchingRect(Mat &inputImage, Mat &templateImg);
int getDistance2(Rect &rect1, Rect &rect2);
Rect getBestMatching(Mat &inputImage, Rect &lastRect, Mat &lastMatch, Mat &oriTemplate);
public:
void process(cv::Mat &input, cv::Mat &output);
};