-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathLBFRegressor.h
120 lines (111 loc) · 5.35 KB
/
LBFRegressor.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
#ifndef __myopencv__LBFRegressor__
#define __myopencv__LBFRegressor__
#include "RandomForest.h"
#include "liblinear/linear.h"
class LBFRegressor{
public:
std::vector<RandomForest> RandomForest_;
std::vector<std::vector<struct model*> > Models_;
cv::Mat_<float> mean_shape_;
std::vector<cv::Mat_<float> > shapes_residual_;
int max_numstage_;
public:
LBFRegressor(){
max_numstage_ = global_params.max_numstage;
RandomForest_.resize(max_numstage_);
Models_.resize(max_numstage_);
}
~LBFRegressor(){
}
void Read(std::ifstream& fin);
void Write(std::ofstream& fout);
void Load(std::string path);
void Save(std::string path);
struct feature_node ** DeriveBinaryFeat(const RandomForest& randf,
const std::vector<cv::Mat_<uchar> >& images,
const std::vector<int>& augmented_images,
const std::vector<cv::Mat_<float> >& current_shapes,
const std::vector<BoundingBox> & bounding_boxs);
struct feature_node ** DeriveBinaryFeat3(const RandomForest& randf,
const std::vector<cv::Mat_<uchar> >& images,
const std::vector<int>& augmented_images,
const std::vector<cv::Mat_<float> >& current_shapes,
const std::vector<int >& ground_truth_faces,
const std::vector<BoundingBox> & bounding_boxs);
struct feature_node ** DeriveBinaryFeat2(const RandomForest& randf,
const std::vector<cv::Mat_<uchar> >& images,
const std::vector<int>& augmented_images,
const std::vector<cv::Mat_<float> >& current_shapes,
const std::vector<BoundingBox> & bounding_boxs,std::vector<bool> & result_face,float& score,int& fcount,bool& fface);
void ReleaseFeatureSpace(struct feature_node ** binfeatures,
int num_train_sample);
int GetCodefromTree(const Tree& tree,
const cv::Mat_<uchar>& image,
const cv::Mat_<float>& shapes,
const BoundingBox& bounding_box,
const cv::Mat_<float>& rotation,
const float scale);
void GetCodefromRandomForest(struct feature_node *binfeature,
const int index,
const std::vector <Tree>& rand_forest,
const cv::Mat_<uchar>& image,
const cv::Mat_<float>& shape,
const BoundingBox& bounding_box,
const cv::Mat_<float>& rotation,
const float scale);
bool GetCodefromRandomForest2(struct feature_node *binfeature,
const int index,
const std::vector<Tree>& rand_forest,
const cv::Mat_<uchar>& image,
const cv::Mat_<float>& shape,
const BoundingBox& bounding_box,
const cv::Mat_<float>& rotation,
const float scale,float& score,int& fcount,bool& fface);
void GlobalRegression(struct feature_node **binfeatures,
const std::vector<cv::Mat_<float> >& shapes_residual,
std::vector<cv::Mat_<float> >& current_shapes,
const std::vector<BoundingBox> & bounding_boxs,
const cv::Mat_<float>& mean_shape,
//Mat_<float>& W,
std::vector<struct model*>& models,
int num_feature,
int num_train_sample,
int stage);
void GlobalRegression2(struct feature_node **binfeatures,
const std::vector<cv::Mat_<float> >& shapes_residual,
std::vector<cv::Mat_<float> >& current_shapes,
const std::vector<BoundingBox> & bounding_boxs,
const cv::Mat_<float>& mean_shape,
//Mat_<float>& W,
std::vector<struct model*>& models,
int num_feature,
const std::vector<int> & augmented_images,
const std::vector<int> & ground_truth_faces,
int stage);
void GlobalPrediction(struct feature_node**,
std::vector<cv::Mat_<float> >& current_shapes,
const std::vector<BoundingBox> & bounding_boxs,
int stage);
void Train( std::vector<cv::Mat_<uchar> >& images,
std::vector<cv::Mat_<float> >& ground_truth_shapes,
std::vector<int>& ground_truth_faces,
std::vector<BoundingBox> & bounding_boxs, int posLenth);
std::vector<cv::Mat_<float> > Predict( const std::vector<cv::Mat_<uchar> >& images,
const std::vector<BoundingBox>& bounding_boxs,
const std::vector<cv::Mat_<float> >& ground_truth_shapes,
int initial_num,std::vector<bool>& result_face);
cv::Mat_<float> Predict(const cv::Mat_<uchar>& image,
const BoundingBox& bounding_box,
int initial_num, bool& isface,int& fcount);
void WriteGlobalParam(std::ofstream& fout);
void ReadGlobalParam(std::ifstream& fin);
void WriteRegressor(std::ofstream& fout);
void ReadRegressor(std::ifstream& fin);
};
void GetResultfromTree(const Tree& tree,
const cv::Mat_<uchar>& image,
const cv::Mat_<float>& shapes,
const BoundingBox& bounding_box,
const cv::Mat_<float>& rotation,
const float scale,int* bincode,float* score);
#endif