forked from garzon/detectFace
/
system_struct.hpp
168 lines (152 loc) · 4.9 KB
/
system_struct.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
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
161
162
163
164
165
166
167
168
#ifndef SYSTEM_STRUCT_HPP
#define SYSTEM_STRUCT_HPP
/*Copyright (c) 2014, School of Computer Science, Fudan University*/
#include <opencv2/opencv.hpp>
#define REID_MAX_SCALE (10) //Person Recognize
#define MAX_BOXES (500) //Max num of boxes in one frame
enum {
TYPE_FACE=1,
TYPE_PERSON,
TYPE_TRACK
};
struct options
{
struct opt_input
{
const int jumpFrame{5};
const double mog_threshold{0.005};
const int blurRadius{5};
const int dilateRadius{20};
};
struct opt_track
{
const double sigma{0.2};
const double lambda{0.01};
const double learning_rate{0.075};
const double compression_learning_rate{0.15};
const int non_compressed_feature{1};
const int compressed_feature{2};
const int num_compressed_dim{2};
const double tol_err{45};
const double limit_scale{0.3};
const double limit_corners{0.3};
const int max_corners{40};
const int win_x{40};
const int win_y{40};
const double qlevel {0.01};
const double min_dist{0.1};
};
struct opt_face_detection
{
const std::string netParams{"data/detect.prototxt"};
const std::string netWeights{"data/cnn_iter_50"};
const std::string hog_head{"data/hog_head.xml"};
const int width{36},height{32};
};
struct opt_person_detection
{
const std::string person_model_path{"data/person_final.xml"};
CvLatentSvmDetector* detector;
const int tbbNumThreads{-1};
const double score_threshold{-1.164949};
const double score_upperbound{5.0};
const int width_thresh{50};
const int height_thresh{50};
const double scale{0.5};
};
struct opt_face_recognition
{
std::string model_address{"data/ourface_v.xml"};
const char * datadir{"data/"};
cv::Size dsize;
cv::Size dsize2;
double threshold{150.0};
double rate_threshold{0.7};
opt_face_recognition()
{
dsize = cv::Size(144, 200);
dsize2= cv::Size(80,88);
}
};
struct opt_person_recognition
{
const std::string current_path="data";
int Patch_Size{10}, Nx{30}, Ny{10}, nScale{3}, sift_nBins{4}, color_nBins{32}, color{3}, nori{8}, norm{4}, alpha{9}, num_angles{8}, h{2}, nstripe{10}, rand_neg{30}, nRank_neg{3}, naux_neg{8}, ntop{10} ;
double Epsi{1e-8}, Scale[REID_MAX_SCALE], clamp{0.2}, kstripe{0.3}, tol{0.1}, tol_confidence{0.7}, tol_threshold{0.4};
int lower_bound{15}, upper_bound{300}, seleted_level{5}, dist_threshold_KNN_for_init_cluster{2}, hierachy_level{10}, split_into{4}, dist_threshold_KNN_for_affinity{30};
double dist_threshold_KNN_rate_for_midselect{0.3}, scaling_a{1.0};
cv::Mat Sigma, Sigma_edge;
opt_person_recognition()
{
Scale[0]=0.5, Scale[1]=0.75, Scale[2]=1;
Sigma.create(1, 1, CV_64FC1), Sigma.at<double>(0, 0)=0.6;
Sigma_edge.create(1, 1, CV_64FC1), Sigma_edge.at<double>(0,0)=1;
}
};
struct opt_distinct
{
const double tol_square{0.7};
const double tol_scale{30};
};
opt_input input;
opt_track track;
opt_face_detection face_d;
opt_face_recognition face_r;
opt_person_detection person_d;
opt_person_recognition person_r;
opt_distinct distinct;
int debug_flag{0}; //0 Release, 1 Debugging
int height{480}, width{640};
};
class shared_data //one frame multi bbox
{
public:
struct info
{
time_t input_stamp; //time stamp
int input_pos; //which probe
info(time_t _stamp=0,int _pos=-1):
input_stamp(_stamp),
input_pos(_pos)
{}
};
struct bbox:public cv::Rect_<int>
{
using cv::Rect_<int>::Rect_;
std::vector<double> prob; //confidence probability 0.0~1.0
std::vector<int> result_label;//the label of this region, means which person in this region
int type_label{0};//this bbox is for 1 face, 2 person or 3 tracking, 0 init
bbox():Rect_<int>(){}
bbox(const cv::Rect_<int> &t):Rect_(t){}
bbox(cv::Rect_<int> &&t):Rect_(t){}
};
struct frame
{
cv::Mat image; // origin image
std::vector<bbox> im_ROI; //valued region
frame(const cv::Mat &_frame=cv::Mat()):
image(_frame)
{}
};
info im_info;
frame im_data;
std::vector<bbox> im_boxes;
explicit shared_data(const cv::Mat &_frame):
im_data(_frame)
{}
shared_data(shared_data &&t){
im_info=t.im_info;
im_data=t.im_data;
im_boxes=move(t.im_boxes);
}
shared_data & operator = (shared_data &&t){
im_info=t.im_info;
im_data=t.im_data;
im_boxes=move(t.im_boxes);
return *this;
}
bool empty() const{
return im_data.image.empty();
}
};
#endif // SYSTEM_STRUCT_HPP