@@ -26,16 +26,19 @@ class Cart {
26
26
public:
27
27
Cart ();
28
28
~Cart ();
29
- Cart (const Cart& other);
30
- Cart& operator =(const Cart& other);
29
+ // Cart(const Cart& other);
30
+ // Cart& operator=(const Cart& other);
31
31
/* *
32
32
* Initialize Cart
33
+ * :input stage: which stage this cart lie in
34
+ * :input landmark_id: which landmark this cart training for regression
33
35
*/
34
36
void Initialize (int stage, int landmark_id);
35
37
36
38
public:
37
39
/* *
38
- * Generate feature pool
40
+ * Generate feature pool, the pool size is determined by Config.feats[stage]
41
+ * :output feature_pool: feature pool
39
42
*/
40
43
void GenFeaturePool (std::vector<Feature>& feature_pool);
41
44
/* *
@@ -44,35 +47,50 @@ class Cart {
44
47
void Train (DataSet& pos, DataSet& neg);
45
48
/* *
46
49
* Split node with training data
50
+ * :input pos: positive dataset
51
+ * :input neg: negative dataset
52
+ * :input pos_idx: index of used positive dataset
53
+ * :input neg_idx: index of used negative dataset
54
+ * :input node_idx: index of current node in this cart
47
55
*/
48
56
void SplitNode (DataSet& pos, std::vector<int >& pos_idx, \
49
57
DataSet& neg, std::vector<int >& neg_idx, \
50
58
int node_idx);
51
59
/* *
52
60
* Classification
61
+ * :input pos_feature: pos feature
62
+ * :input neg_feature: neg feature
63
+ * :output feature_id: which feature we should use
64
+ * :output threshold: split threshold
53
65
*
54
66
* split node with classification, minimize binary entropy of pos and neg
55
67
* `f = argmax_{f \in F} H_{root} - (H_{left} + H_{right})`
56
68
*/
57
- void SplitNodeWithClassification (cv::Mat_<int >& pos_feature, \
58
- cv::Mat_<int >& neg_feature, \
59
- int & feature_id, int & threshold);
69
+ static void SplitNodeWithClassification (const cv::Mat_<int >& pos_feature, \
70
+ const cv::Mat_<int >& neg_feature, \
71
+ int & feature_id, int & threshold);
60
72
/* *
61
73
* Regression
74
+ * :input pos_feature: pos feature
75
+ * :input neg_feature: neg feature
76
+ * :output feature_id: which feature we should use
77
+ * :output threshold: split threshold
62
78
*
63
79
* split node with regression, minimize variance of shape_residual
64
80
* `f = argmax_{f \in F} S_{root} - (S_{left} + S_{right})`
65
81
*/
66
- void SplitNodeWithRegression (cv::Mat_<int >& pos_feature, \
67
- cv::Mat_<double >& shape_residual, \
68
- int & feature_id, int & threshold);
82
+ static void SplitNodeWithRegression (const cv::Mat_<int >& pos_feature, \
83
+ const cv::Mat_<double >& shape_residual, \
84
+ int & feature_id, int & threshold);
69
85
70
86
public:
71
87
/* *
72
88
* Forward a data point to leaf node
73
- * :return: leaf node index in this tree, start from 0
89
+ * :input img: region
90
+ * :input shape: shape
91
+ * :return: leaf node index in this tree, start from 0
74
92
*/
75
- int Forward (const cv::Mat& img, const cv::Mat_<double >& shape);
93
+ int Forward (const cv::Mat& img, const cv::Mat_<double >& shape) const ;
76
94
77
95
public:
78
96
int stage; // cascade stage
@@ -100,8 +118,8 @@ class BoostCart {
100
118
public:
101
119
BoostCart ();
102
120
~BoostCart ();
103
- BoostCart (const BoostCart& other);
104
- BoostCart& operator =(const BoostCart& other);
121
+ // BoostCart(const BoostCart& other);
122
+ // BoostCart& operator=(const BoostCart& other);
105
123
void Initialize (int stage);
106
124
107
125
public:
@@ -115,7 +133,7 @@ class BoostCart {
115
133
* we only use DataSet of pos, X = lbf, Y = shape_residual
116
134
* see more detail on paper in section 4
117
135
*/
118
- void GlobalRegression (const cv::Mat_<int >& lbf, \
136
+ void GlobalRegression (const std::vector< cv::Mat_<int > >& lbf, \
119
137
const cv::Mat_<double >& shape_residual);
120
138
/* *
121
139
* Set Join Cascador
@@ -125,20 +143,21 @@ class BoostCart {
125
143
public:
126
144
/* *
127
145
* Generate Local Binary Feature
146
+ * :input img: region
147
+ * :input shape: shape
128
148
* :return: one row of local binary feature
129
149
*/
130
- cv::Mat_<int > GenLBF (const cv::Mat& img, const cv::Mat_<double >& shape);
150
+ cv::Mat_<int > GenLBF (const cv::Mat& img, const cv::Mat_<double >& shape) const ;
131
151
/* *
132
152
* Generate delta shape with given lbf
153
+ * :input lbf: lbf generated by `GenLBF`
133
154
* :return: one row of delta shape
134
155
*/
135
- cv::Mat_<double > GenDeltaShape (const cv::Mat_<int >& lbf);
156
+ cv::Mat_<double > GenDeltaShape (const cv::Mat_<int >& lbf) const ;
136
157
137
158
public:
138
159
int K; // number of carts
139
160
int stage; // which stage this boost cart lies
140
- double tp_rate; // true positive rate
141
- double fn_rate; // false negative rate
142
161
143
162
std::vector<Cart> carts; // boosted carts
144
163
cv::Mat_<double > w; // weight of global regression
0 commit comments