forked from Cv9527/mtcnn-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmtcnn.h
160 lines (140 loc) · 3.63 KB
/
mtcnn.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef MTCNN_H
#define MTCNN_H
#include "network.h"
class Pnet
{
public:
Pnet();
~Pnet();
void run(Mat &image, float scale);
float nms_threshold;
mydataFmt Pthreshold;
bool firstFlag;
vector<struct Bbox> boundingBox_;
vector<orderScore> bboxScore_;
private:
Size imageSize;
//the image for mxnet conv
struct pBox *rgb;
struct pBox *conv1_matrix;
//the 1th layer's out conv
struct pBox *conv1;
struct pBox *maxPooling1;
struct pBox *maxPooling_matrix;
//the 3th layer's out
struct pBox *conv2;
struct pBox *conv3_matrix;
//the 4th layer's out out
struct pBox *conv3;
struct pBox *score_matrix;
//the 4th layer's out out
struct pBox *score_;
//the 4th layer's out out
struct pBox *location_matrix;
struct pBox *location_;
//Weight
struct Weight *conv1_wb;
struct pRelu *prelu_gmma1;
struct Weight *conv2_wb;
struct pRelu *prelu_gmma2;
struct Weight *conv3_wb;
struct pRelu *prelu_gmma3;
struct Weight *conv4c1_wb;
struct Weight *conv4c2_wb;
void generateBbox(const struct pBox *score, const struct pBox *location, mydataFmt scale);
};
class Rnet
{
public:
Rnet();
~Rnet();
float Rthreshold;
void run(Mat &image);
struct pBox *score_;
struct pBox *location_;
private:
struct pBox *rgb;
struct pBox *conv1_matrix;
struct pBox *conv1_out;
struct pBox *pooling1_out;
struct pBox *conv2_matrix;
struct pBox *conv2_out;
struct pBox *pooling2_out;
struct pBox *conv3_matrix;
struct pBox *conv3_out;
struct pBox *fc4_out;
//Weight
struct Weight *conv1_wb;
struct pRelu *prelu_gmma1;
struct Weight *conv2_wb;
struct pRelu *prelu_gmma2;
struct Weight *conv3_wb;
struct pRelu *prelu_gmma3;
struct Weight *fc4_wb;
struct pRelu *prelu_gmma4;
struct Weight *score_wb;
struct Weight *location_wb;
void RnetImage2MatrixInit(struct pBox *pbox);
};
class Onet
{
public:
Onet();
~Onet();
void run(Mat &image);
float Othreshold;
struct pBox *score_;
struct pBox *location_;
struct pBox *keyPoint_;
private:
struct pBox *rgb;
struct pBox *conv1_matrix;
struct pBox *conv1_out;
struct pBox *pooling1_out;
struct pBox *conv2_matrix;
struct pBox *conv2_out;
struct pBox *pooling2_out;
struct pBox *conv3_matrix;
struct pBox *conv3_out;
struct pBox *pooling3_out;
struct pBox *conv4_matrix;
struct pBox *conv4_out;
struct pBox *fc5_out;
//Weight
struct Weight *conv1_wb;
struct pRelu *prelu_gmma1;
struct Weight *conv2_wb;
struct pRelu *prelu_gmma2;
struct Weight *conv3_wb;
struct pRelu *prelu_gmma3;
struct Weight *conv4_wb;
struct pRelu *prelu_gmma4;
struct Weight *fc5_wb;
struct pRelu *prelu_gmma5;
struct Weight *score_wb;
struct Weight *location_wb;
struct Weight *keyPoint_wb;
void OnetImage2MatrixInit(struct pBox *pbox);
};
class mtcnn
{
public:
mtcnn(int row, int col, int minsize = 60);
~mtcnn();
//这里默认是提取关键点的,如果你的模型没有关键点也没关系,影响是没有的。如果有关键点,那么就提取
vector<Rect> detectObject(Mat &image, vector<vector<Point2f>>& keys = vector<vector<Point2f>>());
private:
Mat reImage;
float nms_threshold[3];
vector<float> scales_;
Pnet *simpleFace_;
vector<struct Bbox> firstBbox_;
vector<struct orderScore> firstOrderScore_;
Rnet refineNet;
vector<struct Bbox> secondBbox_;
vector<struct orderScore> secondBboxScore_;
Onet outNet;
vector<struct Bbox> thirdBbox_;
vector<struct orderScore> thirdBboxScore_;
};
#endif