forked from guanghaoyin/face_asm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodelimage.h
106 lines (81 loc) · 3 KB
/
modelimage.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#pragma execution_character_set("utf-8")
#ifndef MODELIMAGE_H
#define MODELIMAGE_H
#include "shape_vec.h"
#include "shapeinfo.h"
#include <string>
#include <vector>
namespace modelshare {
//! Image and image related operations.
class ModelImage {
protected:
// The number of landmark points.
int nMarkPoints;
// Optional 'host image' filename including full path.
string hostImageName;
// the training image
Mat imgdata;
// Image pyramid
vector< Mat > imgPyramid;
vector< Mat_<double> > imgPyrGrayDeriv;
vector< Mat_<uchar> > imgPyrGray;
// Is the image loaded?
bool imgLoaded;
// Information about shapes and paths.
ShapeInfo *shapeInfo;
public:
ModelImage();
// Landmark points
vector< Point_< int > > points;
// Shape vectors
ShapeVec shapeVec;
// Load training image from saved host image
bool loadTrainImage();
// Load training image
bool loadTrainImage(const Mat &img);
void setShapeInfo(ShapeInfo *si) { shapeInfo = si; }
// Release Training Image
bool releaseTrainImage();
// Get local structure
/*!将得到的-k到k个点转换为2k*1矩阵,并归一化
\param pId id of the point
\param k how many points to get on either direction
\param level position in the pyramid level
\param step VERY IMPORTANT, for a image with area of 10000, 1.0 may be a good choice
*/
Mat_< double > getLocalStruct(int pId, int k, int level, double step);
// Get the coordinates of points at normal direction of a landmark point
/*!搜索在前后点连线过的法线过当前点方向-k到k个点保存在v中
\param pId id of the point
\param k how many points to get on either direction
\param level position in the pyramid level
\param V the vector that save results.
\param step VERY IMPORTANT, for a image with area of 10000, 1.0 may be a good choice
\param pOffset when searching for best points, use the p'th point along the profile as the center
*/
void getPointsOnNorm(int pId, int k, int level,
vector< Point_< int > > &V,
double step, int pOffset = 0);
//! Get the image saved at specified level
Mat & getTrainImage(int level = 0, bool gray = false);
// Return the derivative image at specified level;
Mat & getDerivImage(int level) { return imgPyrGrayDeriv[level]; }
// Host image (if any).
inline const string &HostImage() const { return hostImageName; }
void buildFromShapeVec(simtrans &trans);
// Read mark points information from a PTS file
bool readPTS(const char * filename);
// Set mark points information from a vector of points
void initPointsByVector(const vector< cv::Point2i > &V);
//获取protected成员
void setHostImage(const char * hostImageFilename) {
hostImageName = hostImageFilename;
}
// The number of shape points.
inline int NPoints() const { return nMarkPoints; }
//! Show the image interactively
Mat show(int level = 0, int pId = -1, bool showInWin = true, int highLight = 0);
};
}
#endif // !MODELIMAGE_H