-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFace.h
83 lines (61 loc) · 1.72 KB
/
Face.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
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
//
// Face.h
// SDM
//
// Created by Oriol Martinez Pujol on 26/4/18.
// Copyright 2016 Universitat Pompeu Fabra, CMTech research group. All rights reserved.
//
#ifndef face_hpp
#define face_hpp
#include <opencv2/opencv.hpp>
#include <opencv2/objdetect.hpp>
#include <iostream>
#include <fstream>
#include <time.h>
using namespace std;
using namespace cv;
class Face {
public:
/*************/
/* VARIABLES */
vector<cv::Mat> muS, eigS, muP, omegaD, omegaT, omegaF, omega3D;
vector<cv::Point2f> meanPts;
Rect pBox, fBox;
int width, height;
std::vector<int> scale = { 8 ,8 ,6 ,6 };
vector<int> idxPts;
/***********/
/* METHODS */
// Constructor
Face(int patchsz, int descsz);
// Patch Update
void ipatch2tmplt(cv::Mat frame, cv::Mat& patch, cv::Mat& tform, cv::Mat& itform, cv::Rect origin);
void ipatch2tmpltPro(cv::Mat frame, cv::Mat& patch, cv::Mat& tform, cv::Mat& itform, vector<cv::Point2f> wPts);
// Haar face detection
void detectFaces(cv::Mat grayframe, vector<Rect>& faces);
// SDM regressors (landmarks)
float estimateLandmarks(cv::Mat patch, std::vector<cv::Point2f>& esPts, vector<cv::Mat> omega);
// Get bounding box from 2D landmarks
CvRect landmarks2rect(std::vector<cv::Point2f> esPts);
Mat procrustes(std::vector<cv::Point2f> esPts);
// Destructor
~Face();
private:
/*************/
/* VARIABLES */
// Structure variables
CascadeClassifier fd;
// Mapping variables
vector<Point2f> srcTri;
vector<Point2f> dstTri;
// HOG
// HOGDescriptor *hog;
std::vector<cv::HOGDescriptor> hogs;
std::vector<cv::Point> selPts;
Mat phi, incPts, valPts;
/***********/
/* METHODS */
// Read from binary files
bool bin2mat(std::ifstream& ifs, std::vector<cv::Mat>& in_mat);
};
#endif /* face_hpp */