Point Cloud Library (PCL)  1.11.1-dev
rf_face_utils.h
1 /*
2  * fanellis_face_detector.h
3  *
4  * Created on: 22 Sep 2012
5  * Author: Aitor Aldoma
6  */
7 
8 #pragma once
9 
10 #include "pcl/recognition/face_detection/face_common.h"
11 #include <pcl/ml/feature_handler.h>
12 #include <pcl/ml/stats_estimator.h>
13 #include <pcl/ml/branch_estimator.h>
14 
15 namespace pcl
16 {
17  namespace face_detection
18  {
19  template<class FT, class DataSet, class ExampleIndex>
20  class FeatureHandlerDepthAverage: public pcl::FeatureHandler<FT, DataSet, ExampleIndex>
21  {
22 
23  private:
24  int wsize_; //size of the window
25  int max_patch_size_; //max size of the smaller patches
26  int num_channels_; //the number of feature channels
27  float min_valid_small_patch_depth_; //percentage of valid depth in a small patch
28  public:
29 
31  {
32  wsize_ = 80;
33  max_patch_size_ = 40;
34  num_channels_ = 1;
35  min_valid_small_patch_depth_ = 0.5f;
36  }
37 
38  /** \brief Sets the size of the window to extract features.
39  * \param[in] w Window size.
40  */
41  void setWSize(int w)
42  {
43  wsize_ = w;
44  }
45 
46  /** \brief Sets the number of channels a feature has (i.e. 1 - depth, 4 - depth + normals)
47  * \param[in] nf Number of channels.
48  */
49  void setNumChannels(int nf)
50  {
51  num_channels_ = nf;
52  }
53 
54  /** \brief Create a set of random tests to evaluate examples.
55  * \param[in] w Number features to generate.
56  */
57  void setMaxPatchSize(int w)
58  {
59  max_patch_size_ = w;
60  }
61 
62  /** \brief Create a set of random tests to evaluate examples.
63  * \param[in] num_of_features Number features to generated.
64  * \param[out] features Generated features.
65  */
66  /*void createRandomFeatures(const std::size_t num_of_features, std::vector<FT> & features)
67  {
68  srand (time(NULL));
69  int min_s = 10;
70  float range_d = 0.03f;
71  for (std::size_t i = 0; i < num_of_features; i++)
72  {
73  FT f;
74 
75  f.row1_ = rand () % (wsize_ - max_patch_size_ - 1);
76  f.col1_ = rand () % (wsize_ / 2 - max_patch_size_ - 1);
77  f.wsizex1_ = min_s + (rand () % (max_patch_size_ - min_s - 1));
78  f.wsizey1_ = min_s + (rand () % (max_patch_size_ - min_s - 1));
79 
80  f.row2_ = rand () % (wsize_ - max_patch_size_ - 1);
81  f.col2_ = wsize_ / 2 + rand () % (wsize_ / 2 - max_patch_size_ - 1);
82  f.wsizex2_ = min_s + (rand () % (max_patch_size_ - 1 - min_s));
83  f.wsizey2_ = min_s + (rand () % (max_patch_size_ - 1 - min_s));
84 
85  f.used_ii_ = 0;
86  if(num_channels_ > 1)
87  f.used_ii_ = rand() % num_channels_;
88 
89  f.threshold_ = -range_d + (rand () / static_cast<float> (RAND_MAX)) * (range_d * 2.f);
90  features.push_back (f);
91  }
92  }*/
93 
94  void createRandomFeatures(const std::size_t num_of_features, std::vector<FT> & features) override
95  {
96  srand (static_cast<unsigned int>(time (nullptr)));
97  int min_s = 20;
98  float range_d = 0.05f;
99  float incr_d = 0.01f;
100 
101  std::vector < FT > windows_and_functions;
102 
103  for (std::size_t i = 0; i < num_of_features; i++)
104  {
105  FT f;
106 
107  f.row1_ = rand () % (wsize_ - max_patch_size_ - 1);
108  f.col1_ = rand () % (wsize_ / 2 - max_patch_size_ - 1);
109  f.wsizex1_ = min_s + (rand () % (max_patch_size_ - min_s - 1));
110  f.wsizey1_ = min_s + (rand () % (max_patch_size_ - min_s - 1));
111 
112  f.row2_ = rand () % (wsize_ - max_patch_size_ - 1);
113  f.col2_ = wsize_ / 2 + rand () % (wsize_ / 2 - max_patch_size_ - 1);
114  f.wsizex2_ = min_s + (rand () % (max_patch_size_ - 1 - min_s));
115  f.wsizey2_ = min_s + (rand () % (max_patch_size_ - 1 - min_s));
116 
117  f.used_ii_ = 0;
118  if (num_channels_ > 1)
119  f.used_ii_ = rand () % num_channels_;
120 
121  windows_and_functions.push_back (f);
122  }
123 
124  for (std::size_t i = 0; i < windows_and_functions.size (); i++)
125  {
126  FT f = windows_and_functions[i];
127  for (std::size_t j = 0; j <= 10; j++)
128  {
129  f.threshold_ = -range_d + static_cast<float> (j) * incr_d;
130  features.push_back (f);
131  }
132  }
133  }
134 
135  /** \brief Evaluates a feature on the specified set of examples.
136  * \param[in] feature The feature to evaluate.
137  * \param[in] data_set The data set on which the feature is evaluated.
138  * \param[in] examples The set of examples of the data set the feature is evaluated on.
139  * \param[out] results The destination for the results of the feature evaluation.
140  * \param[out] flags Flags that are supplied together with the results.
141  */
142  void evaluateFeature(const FT & feature, DataSet & data_set, std::vector<ExampleIndex> & examples, std::vector<float> & results,
143  std::vector<unsigned char> & flags) const override
144  {
145  results.resize (examples.size ());
146  for (std::size_t i = 0; i < examples.size (); i++)
147  {
148  evaluateFeature (feature, data_set, examples[i], results[i], flags[i]);
149  }
150  }
151 
152  /** \brief Evaluates a feature on the specified example.
153  * \param[in] feature The feature to evaluate.
154  * \param[in] data_set The data set on which the feature is evaluated.
155  * \param[in] example The example of the data set the feature is evaluated on.
156  * \param[out] result The destination for the result of the feature evaluation.
157  * \param[out] flag Flags that are supplied together with the results.
158  */
159  void evaluateFeature(const FT & feature, DataSet & data_set, const ExampleIndex & example, float & result, unsigned char & flag) const override
160  {
161  TrainingExample te = data_set[example];
162  int el_f1 = te.iimages_[feature.used_ii_]->getFiniteElementsCount (te.col_ + feature.col1_, te.row_ + feature.row1_, feature.wsizex1_,
163  feature.wsizey1_);
164  int el_f2 = te.iimages_[feature.used_ii_]->getFiniteElementsCount (te.col_ + feature.col2_, te.row_ + feature.row2_, feature.wsizex2_,
165  feature.wsizey2_);
166 
167  float sum_f1 = static_cast<float>(te.iimages_[feature.used_ii_]->getFirstOrderSum (te.col_ + feature.col1_, te.row_ + feature.row1_, feature.wsizex1_, feature.wsizey1_));
168  float sum_f2 = static_cast<float>(te.iimages_[feature.used_ii_]->getFirstOrderSum (te.col_ + feature.col2_, te.row_ + feature.row2_, feature.wsizex2_, feature.wsizey2_));
169 
170  float f = min_valid_small_patch_depth_;
171  if (el_f1 == 0 || el_f2 == 0 || (el_f1 <= static_cast<int> (f * static_cast<float>(feature.wsizex1_ * feature.wsizey1_)))
172  || (el_f2 <= static_cast<int> (f * static_cast<float>(feature.wsizex2_ * feature.wsizey2_))))
173  {
174  result = static_cast<float> (pcl_round (static_cast<float>(rand ()) / static_cast<float> (RAND_MAX)));
175  flag = 1;
176  } else
177  {
178  result = static_cast<float> ((sum_f1 / static_cast<float>(el_f1) - sum_f2 / static_cast<float>(el_f2)) > feature.threshold_);
179  flag = 0;
180  }
181 
182  }
183 
184  /** \brief Generates evaluation code for the specified feature and writes it to the specified stream.
185  */
186  // param[in] feature The feature for which code is generated.
187  // param[out] stream The destination for the code.
188  void generateCodeForEvaluation(const FT &/*feature*/, ::std::ostream &/*stream*/) const override
189  {
190 
191  }
192  };
193 
194  /** \brief Statistics estimator for regression trees which optimizes information gain and pose parameters error. */
195  template<class LabelDataType, class NodeType, class DataSet, class ExampleIndex>
196  class PoseClassRegressionVarianceStatsEstimator: public pcl::StatsEstimator<LabelDataType, NodeType, DataSet, ExampleIndex>
197  {
198 
199  public:
200  /** \brief Constructor. */
202  branch_estimator_ (branch_estimator)
203  {
204  }
205 
206  /** \brief Destructor. */
208  {
209  }
210 
211  /** \brief Returns the number of branches the corresponding tree has. */
212  inline std::size_t getNumOfBranches() const override
213  {
214  return branch_estimator_->getNumOfBranches ();
215  }
216 
217  /** \brief Returns the label of the specified node.
218  * \param[in] node The node which label is returned.
219  */
220  inline LabelDataType getLabelOfNode(NodeType & node) const override
221  {
222  return node.value;
223  }
224 
225  /** \brief Computes the covariance matrix for translation offsets.
226  * \param[in] data_set The corresponding data set.
227  * \param[in] examples A set of examples from the dataset.
228  * \param[out] covariance_matrix The covariance matrix.
229  * \param[out] centroid The mean of the data.
230  */
231  inline unsigned int computeMeanAndCovarianceOffset(DataSet & data_set, std::vector<ExampleIndex> & examples, Eigen::Matrix3d & covariance_matrix,
232  Eigen::Vector3d & centroid) const
233  {
234  Eigen::Matrix<double, 1, 9, Eigen::RowMajor> accu = Eigen::Matrix<double, 1, 9, Eigen::RowMajor>::Zero ();
235  unsigned int point_count = static_cast<unsigned int> (examples.size ());
236 
237  for (std::size_t i = 0; i < point_count; ++i)
238  {
239  TrainingExample te = data_set[examples[i]];
240  accu[0] += te.trans_[0] * te.trans_[0];
241  accu[1] += te.trans_[0] * te.trans_[1];
242  accu[2] += te.trans_[0] * te.trans_[2];
243  accu[3] += te.trans_[1] * te.trans_[1];
244  accu[4] += te.trans_[1] * te.trans_[2];
245  accu[5] += te.trans_[2] * te.trans_[2];
246  accu[6] += te.trans_[0];
247  accu[7] += te.trans_[1];
248  accu[8] += te.trans_[2];
249  }
250 
251  if (point_count != 0)
252  {
253  accu /= static_cast<double> (point_count);
254  centroid.head<3> ().matrix () = accu.tail<3> ();
255  covariance_matrix.coeffRef (0) = accu[0] - accu[6] * accu[6];
256  covariance_matrix.coeffRef (1) = accu[1] - accu[6] * accu[7];
257  covariance_matrix.coeffRef (2) = accu[2] - accu[6] * accu[8];
258  covariance_matrix.coeffRef (4) = accu[3] - accu[7] * accu[7];
259  covariance_matrix.coeffRef (5) = accu[4] - accu[7] * accu[8];
260  covariance_matrix.coeffRef (8) = accu[5] - accu[8] * accu[8];
261  covariance_matrix.coeffRef (3) = covariance_matrix.coeff (1);
262  covariance_matrix.coeffRef (6) = covariance_matrix.coeff (2);
263  covariance_matrix.coeffRef (7) = covariance_matrix.coeff (5);
264  }
265 
266  return point_count;
267  }
268 
269  /** \brief Computes the covariance matrix for rotation values.
270  * \param[in] data_set The corresponding data set.
271  * \param[in] examples A set of examples from the dataset.
272  * \param[out] covariance_matrix The covariance matrix.
273  * \param[out] centroid The mean of the data.
274  */
275  inline unsigned int computeMeanAndCovarianceAngles(DataSet & data_set, std::vector<ExampleIndex> & examples, Eigen::Matrix3d & covariance_matrix,
276  Eigen::Vector3d & centroid) const
277  {
278  Eigen::Matrix<double, 1, 9, Eigen::RowMajor> accu = Eigen::Matrix<double, 1, 9, Eigen::RowMajor>::Zero ();
279  unsigned int point_count = static_cast<unsigned int> (examples.size ());
280 
281  for (std::size_t i = 0; i < point_count; ++i)
282  {
283  TrainingExample te = data_set[examples[i]];
284  accu[0] += te.rot_[0] * te.rot_[0];
285  accu[1] += te.rot_[0] * te.rot_[1];
286  accu[2] += te.rot_[0] * te.rot_[2];
287  accu[3] += te.rot_[1] * te.rot_[1];
288  accu[4] += te.rot_[1] * te.rot_[2];
289  accu[5] += te.rot_[2] * te.rot_[2];
290  accu[6] += te.rot_[0];
291  accu[7] += te.rot_[1];
292  accu[8] += te.rot_[2];
293  }
294 
295  if (point_count != 0)
296  {
297  accu /= static_cast<double> (point_count);
298  centroid.head<3> ().matrix () = accu.tail<3> ();
299  covariance_matrix.coeffRef (0) = accu[0] - accu[6] * accu[6];
300  covariance_matrix.coeffRef (1) = accu[1] - accu[6] * accu[7];
301  covariance_matrix.coeffRef (2) = accu[2] - accu[6] * accu[8];
302  covariance_matrix.coeffRef (4) = accu[3] - accu[7] * accu[7];
303  covariance_matrix.coeffRef (5) = accu[4] - accu[7] * accu[8];
304  covariance_matrix.coeffRef (8) = accu[5] - accu[8] * accu[8];
305  covariance_matrix.coeffRef (3) = covariance_matrix.coeff (1);
306  covariance_matrix.coeffRef (6) = covariance_matrix.coeff (2);
307  covariance_matrix.coeffRef (7) = covariance_matrix.coeff (5);
308  }
309 
310  return point_count;
311  }
312 
313  /** \brief Computes the information gain obtained by the specified threshold.
314  * \param[in] data_set The data set corresponding to the supplied result data.
315  * \param[in] examples The examples used for extracting the supplied result data.
316  * \param[in] label_data The label data corresponding to the specified examples.
317  * \param[in] results The results computed using the specified examples.
318  * \param[in] flags The flags corresponding to the results.
319  * \param[in] threshold The threshold for which the information gain is computed.
320  */
321  float computeInformationGain(DataSet & data_set, std::vector<ExampleIndex> & examples, std::vector<LabelDataType> & label_data,
322  std::vector<float> & results, std::vector<unsigned char> & flags, const float threshold) const override
323  {
324  const std::size_t num_of_examples = examples.size ();
325  const std::size_t num_of_branches = getNumOfBranches ();
326 
327  // compute variance
328  std::vector < LabelDataType > sums (num_of_branches + 1, 0.f);
329  std::vector < LabelDataType > sqr_sums (num_of_branches + 1, 0.f);
330  std::vector < std::size_t > branch_element_count (num_of_branches + 1, 0.f);
331 
332  for (std::size_t branch_index = 0; branch_index < num_of_branches; ++branch_index)
333  {
334  branch_element_count[branch_index] = 1;
335  ++branch_element_count[num_of_branches];
336  }
337 
338  for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index)
339  {
340  unsigned char branch_index;
341  computeBranchIndex (results[example_index], flags[example_index], threshold, branch_index);
342 
343  LabelDataType label = label_data[example_index];
344 
345  ++branch_element_count[branch_index];
346  ++branch_element_count[num_of_branches];
347 
348  sums[branch_index] += label;
349  sums[num_of_branches] += label;
350  }
351 
352  std::vector<float> hp (num_of_branches + 1, 0.f);
353  for (std::size_t branch_index = 0; branch_index < (num_of_branches + 1); ++branch_index)
354  {
355  float pf = sums[branch_index] / static_cast<float> (branch_element_count[branch_index]);
356  float pnf = (static_cast<LabelDataType>(branch_element_count[branch_index]) - sums[branch_index] + 1.f)
357  / static_cast<LabelDataType> (branch_element_count[branch_index]);
358  hp[branch_index] -= static_cast<float>(pf * std::log (pf) + pnf * std::log (pnf));
359  }
360 
361  //use mean of the examples as purity
362  float purity = sums[num_of_branches] / static_cast<LabelDataType>(branch_element_count[num_of_branches]);
363  float tp = 0.8f;
364 
365  if (purity >= tp)
366  {
367  //compute covariance matrices from translation offsets and angles for the whole set and children
368  //consider only positive examples...
369  std::vector < std::size_t > branch_element_count (num_of_branches + 1, 0);
370  std::vector < std::vector<ExampleIndex> > positive_examples;
371  positive_examples.resize (num_of_branches + 1);
372 
373  std::size_t pos = 0;
374  for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index)
375  {
376  unsigned char branch_index;
377  computeBranchIndex (results[example_index], flags[example_index], threshold, branch_index);
378 
379  LabelDataType label = label_data[example_index];
380 
381  if (label == 1 /*&& !flags[example_index]*/)
382  {
383  ++branch_element_count[branch_index];
384  ++branch_element_count[num_of_branches];
385 
386  positive_examples[branch_index].push_back (examples[example_index]);
387  positive_examples[num_of_branches].push_back (examples[example_index]);
388  pos++;
389  }
390  }
391 
392  //compute covariance from offsets and angles for all branchs
393  std::vector < Eigen::Matrix3d > offset_covariances;
394  std::vector < Eigen::Matrix3d > angle_covariances;
395 
396  std::vector < Eigen::Vector3d > offset_centroids;
397  std::vector < Eigen::Vector3d > angle_centroids;
398 
399  offset_covariances.resize (num_of_branches + 1);
400  angle_covariances.resize (num_of_branches + 1);
401  offset_centroids.resize (num_of_branches + 1);
402  angle_centroids.resize (num_of_branches + 1);
403 
404  for (std::size_t branch_index = 0; branch_index < (num_of_branches + 1); ++branch_index)
405  {
406  computeMeanAndCovarianceOffset (data_set, positive_examples[branch_index], offset_covariances[branch_index],
407  offset_centroids[branch_index]);
408  computeMeanAndCovarianceAngles (data_set, positive_examples[branch_index], angle_covariances[branch_index],
409  angle_centroids[branch_index]);
410  }
411 
412  //update information_gain
413  std::vector<float> hr (num_of_branches + 1, 0.f);
414  for (std::size_t branch_index = 0; branch_index < (num_of_branches + 1); ++branch_index)
415  {
416  hr[branch_index] = static_cast<float>(0.5f * std::log (std::pow (2 * M_PI, 3)
417  * offset_covariances[branch_index].determinant ())
418  + 0.5f * std::log (std::pow (2 * M_PI, 3)
419  * angle_covariances[branch_index].determinant ()));
420  }
421 
422  for (std::size_t branch_index = 0; branch_index < (num_of_branches + 1); ++branch_index)
423  {
424  hp[branch_index] += std::max (sums[branch_index] / static_cast<float> (branch_element_count[branch_index]) - tp, 0.f) * hr[branch_index];
425  }
426  }
427 
428  float information_gain = hp[num_of_branches + 1];
429  for (std::size_t branch_index = 0; branch_index < (num_of_branches); ++branch_index)
430  {
431  information_gain -= static_cast<float> (branch_element_count[branch_index]) / static_cast<float> (branch_element_count[num_of_branches])
432  * hp[branch_index];
433  }
434 
435  return information_gain;
436  }
437 
438  /** \brief Computes the branch indices for all supplied results.
439  * \param[in] results The results the branch indices will be computed for.
440  * \param[in] flags The flags corresponding to the specified results.
441  * \param[in] threshold The threshold used to compute the branch indices.
442  * \param[out] branch_indices The destination for the computed branch indices.
443  */
444  void computeBranchIndices(std::vector<float> & results, std::vector<unsigned char> & flags, const float threshold,
445  std::vector<unsigned char> & branch_indices) const override
446  {
447  const std::size_t num_of_results = results.size ();
448 
449  branch_indices.resize (num_of_results);
450  for (std::size_t result_index = 0; result_index < num_of_results; ++result_index)
451  {
452  unsigned char branch_index;
453  computeBranchIndex (results[result_index], flags[result_index], threshold, branch_index);
454  branch_indices[result_index] = branch_index;
455  }
456  }
457 
458  /** \brief Computes the branch index for the specified result.
459  * \param[in] result The result the branch index will be computed for.
460  * \param[in] flag The flag corresponding to the specified result.
461  * \param[in] threshold The threshold used to compute the branch index.
462  * \param[out] branch_index The destination for the computed branch index.
463  */
464  inline void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char & branch_index) const override
465  {
466  branch_estimator_->computeBranchIndex (result, flag, threshold, branch_index);
467  }
468 
469  /** \brief Computes and sets the statistics for a node.
470  * \param[in] data_set The data set which is evaluated.
471  * \param[in] examples The examples which define which parts of the data set are used for evaluation.
472  * \param[in] label_data The label_data corresponding to the examples.
473  * \param[out] node The destination node for the statistics.
474  */
475  void computeAndSetNodeStats(DataSet & data_set, std::vector<ExampleIndex> & examples, std::vector<LabelDataType> & label_data, NodeType & node) const override
476  {
477  const std::size_t num_of_examples = examples.size ();
478 
479  LabelDataType sum = 0.0f;
480  LabelDataType sqr_sum = 0.0f;
481  for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index)
482  {
483  const LabelDataType label = label_data[example_index];
484 
485  sum += label;
486  sqr_sum += label * label;
487  }
488 
489  sum /= static_cast<float>(num_of_examples);
490  sqr_sum /= static_cast<float>(num_of_examples);
491 
492  const float variance = sqr_sum - sum * sum;
493 
494  node.value = sum;
495  node.variance = variance;
496 
497  //set node stats regarding pose regression
498  std::vector < ExampleIndex > positive_examples;
499 
500  for (std::size_t example_index = 0; example_index < num_of_examples; ++example_index)
501  {
502  LabelDataType label = label_data[example_index];
503 
504  if (label == 1)
505  positive_examples.push_back (examples[example_index]);
506 
507  }
508 
509  //compute covariance from offsets and angles
510  computeMeanAndCovarianceOffset (data_set, positive_examples, node.covariance_trans_, node.trans_mean_);
511  computeMeanAndCovarianceAngles (data_set, positive_examples, node.covariance_rot_, node.rot_mean_);
512  }
513 
514  /** \brief Generates code for branch index computation.
515  * \param[out] stream The destination for the generated code.
516  */
517  // param[in] node The node for which code is generated.
518  void generateCodeForBranchIndexComputation(NodeType & /*node*/, std::ostream & stream) const override
519  {
520  stream << "ERROR: RegressionVarianceStatsEstimator does not implement generateCodeForBranchIndex(...)";
521  }
522 
523  /** \brief Generates code for label output.
524  * \param[out] stream The destination for the generated code.
525  */
526  // param[in] node The node for which code is generated.
527  void generateCodeForOutput(NodeType & /*node*/, std::ostream & stream) const override
528  {
529  stream << "ERROR: RegressionVarianceStatsEstimator does not implement generateCodeForBranchIndex(...)";
530  }
531 
532  private:
533  /** \brief The branch estimator. */
534  pcl::BranchEstimator * branch_estimator_;
535  };
536  }
537 }
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::generateCodeForBranchIndexComputation
void generateCodeForBranchIndexComputation(NodeType &, std::ostream &stream) const override
Generates code for branch index computation.
Definition: rf_face_utils.h:518
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::PoseClassRegressionVarianceStatsEstimator
PoseClassRegressionVarianceStatsEstimator(BranchEstimator *branch_estimator)
Constructor.
Definition: rf_face_utils.h:201
pcl
Definition: convolution.h:46
pcl::face_detection::FeatureHandlerDepthAverage::generateCodeForEvaluation
void generateCodeForEvaluation(const FT &, ::std::ostream &) const override
Generates evaluation code for the specified feature and writes it to the specified stream.
Definition: rf_face_utils.h:188
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::computeAndSetNodeStats
void computeAndSetNodeStats(DataSet &data_set, std::vector< ExampleIndex > &examples, std::vector< LabelDataType > &label_data, NodeType &node) const override
Computes and sets the statistics for a node.
Definition: rf_face_utils.h:475
pcl::BranchEstimator::getNumOfBranches
virtual std::size_t getNumOfBranches() const =0
Returns the number of branches the corresponding tree has.
pcl::face_detection::FeatureHandlerDepthAverage::evaluateFeature
void evaluateFeature(const FT &feature, DataSet &data_set, std::vector< ExampleIndex > &examples, std::vector< float > &results, std::vector< unsigned char > &flags) const override
Evaluates a feature on the specified set of examples.
Definition: rf_face_utils.h:142
pcl::face_detection::TrainingExample::row_
int row_
Definition: face_common.h:17
pcl::face_detection::TrainingExample
Definition: face_common.h:13
pcl::face_detection::TrainingExample::rot_
Eigen::Vector3f rot_
Definition: face_common.h:23
pcl::face_detection::FeatureHandlerDepthAverage::evaluateFeature
void evaluateFeature(const FT &feature, DataSet &data_set, const ExampleIndex &example, float &result, unsigned char &flag) const override
Evaluates a feature on the specified example.
Definition: rf_face_utils.h:159
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::computeMeanAndCovarianceOffset
unsigned int computeMeanAndCovarianceOffset(DataSet &data_set, std::vector< ExampleIndex > &examples, Eigen::Matrix3d &covariance_matrix, Eigen::Vector3d &centroid) const
Computes the covariance matrix for translation offsets.
Definition: rf_face_utils.h:231
pcl::BranchEstimator::computeBranchIndex
virtual void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char &branch_index) const =0
Computes the branch index for the specified result.
pcl::face_detection::TrainingExample::iimages_
std::vector< pcl::IntegralImage2D< float, 1 >::Ptr > iimages_
Definition: face_common.h:16
pcl::BranchEstimator
Interface for branch estimators.
Definition: branch_estimator.h:50
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::computeInformationGain
float computeInformationGain(DataSet &data_set, std::vector< ExampleIndex > &examples, std::vector< LabelDataType > &label_data, std::vector< float > &results, std::vector< unsigned char > &flags, const float threshold) const override
Computes the information gain obtained by the specified threshold.
Definition: rf_face_utils.h:321
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::getNumOfBranches
std::size_t getNumOfBranches() const override
Returns the number of branches the corresponding tree has.
Definition: rf_face_utils.h:212
pcl::FeatureHandler
Utility class interface which is used for creating and evaluating features.
Definition: feature_handler.h:49
pcl::face_detection::FeatureHandlerDepthAverage::FeatureHandlerDepthAverage
FeatureHandlerDepthAverage()
Definition: rf_face_utils.h:30
pcl::face_detection::FeatureHandlerDepthAverage::setMaxPatchSize
void setMaxPatchSize(int w)
Create a set of random tests to evaluate examples.
Definition: rf_face_utils.h:57
pcl::face_detection::TrainingExample::trans_
Eigen::Vector3f trans_
Definition: face_common.h:22
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator
Statistics estimator for regression trees which optimizes information gain and pose parameters error.
Definition: rf_face_utils.h:196
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::getLabelOfNode
LabelDataType getLabelOfNode(NodeType &node) const override
Returns the label of the specified node.
Definition: rf_face_utils.h:220
pcl::face_detection::FeatureHandlerDepthAverage::setNumChannels
void setNumChannels(int nf)
Sets the number of channels a feature has (i.e.
Definition: rf_face_utils.h:49
M_PI
#define M_PI
Definition: pcl_macros.h:201
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::computeBranchIndex
void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char &branch_index) const override
Computes the branch index for the specified result.
Definition: rf_face_utils.h:464
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::generateCodeForOutput
void generateCodeForOutput(NodeType &, std::ostream &stream) const override
Generates code for label output.
Definition: rf_face_utils.h:527
pcl::face_detection::FeatureHandlerDepthAverage
Definition: rf_face_utils.h:20
pcl_round
__inline double pcl_round(double number)
Win32 doesn't seem to have rounding functions.
Definition: pcl_macros.h:239
pcl::face_detection::FeatureHandlerDepthAverage::createRandomFeatures
void createRandomFeatures(const std::size_t num_of_features, std::vector< FT > &features) override
Create a set of random tests to evaluate examples.
Definition: rf_face_utils.h:94
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::~PoseClassRegressionVarianceStatsEstimator
~PoseClassRegressionVarianceStatsEstimator()
Destructor.
Definition: rf_face_utils.h:207
pcl::face_detection::FeatureHandlerDepthAverage::setWSize
void setWSize(int w)
Sets the size of the window to extract features.
Definition: rf_face_utils.h:41
pcl::face_detection::TrainingExample::col_
int col_
Definition: face_common.h:17
pcl::StatsEstimator
Class interface for gathering statistics for decision tree learning.
Definition: stats_estimator.h:49
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::computeMeanAndCovarianceAngles
unsigned int computeMeanAndCovarianceAngles(DataSet &data_set, std::vector< ExampleIndex > &examples, Eigen::Matrix3d &covariance_matrix, Eigen::Vector3d &centroid) const
Computes the covariance matrix for rotation values.
Definition: rf_face_utils.h:275
pcl::face_detection::PoseClassRegressionVarianceStatsEstimator::computeBranchIndices
void computeBranchIndices(std::vector< float > &results, std::vector< unsigned char > &flags, const float threshold, std::vector< unsigned char > &branch_indices) const override
Computes the branch indices for all supplied results.
Definition: rf_face_utils.h:444