Point Cloud Library (PCL)  1.9.1-dev
face_common.h
1 #pragma once
2 
3 #include <pcl/features/integral_image2D.h>
4 #include <pcl/pcl_macros.h>
5 
6 #include <Eigen/Core>
7 
8 namespace pcl
9 {
10  namespace face_detection
11  {
13  {
14  public:
15  std::vector<pcl::IntegralImage2D<float, 1>::Ptr> iimages_; //also pointer to the respective integral image
16  int row_, col_;
17  int wsize_;
18  int label_;
19 
20  //save pose head information
21  Eigen::Vector3f trans_;
22  Eigen::Vector3f rot_;
24  };
25 
27  {
28  public:
29  int row1_, col1_;
30  int row2_, col2_;
31 
32  int wsizex1_, wsizey1_;
33  int wsizex2_, wsizey2_;
34 
35  float threshold_;
36  int used_ii_;
37 
39  {
40  used_ii_ = 0;
41  }
42 
43  void serialize(std::ostream & stream) const
44  {
45  stream.write (reinterpret_cast<const char*> (&row1_), sizeof(row1_));
46  stream.write (reinterpret_cast<const char*> (&col1_), sizeof(col1_));
47  stream.write (reinterpret_cast<const char*> (&row2_), sizeof(row2_));
48  stream.write (reinterpret_cast<const char*> (&col2_), sizeof(col2_));
49  stream.write (reinterpret_cast<const char*> (&wsizex1_), sizeof(wsizex1_));
50  stream.write (reinterpret_cast<const char*> (&wsizex2_), sizeof(wsizex2_));
51  stream.write (reinterpret_cast<const char*> (&wsizey1_), sizeof(wsizey1_));
52  stream.write (reinterpret_cast<const char*> (&wsizey2_), sizeof(wsizey2_));
53  stream.write (reinterpret_cast<const char*> (&threshold_), sizeof(threshold_));
54  stream.write (reinterpret_cast<const char*> (&used_ii_), sizeof(used_ii_));
55  }
56 
57  inline void deserialize(std::istream & stream)
58  {
59  stream.read (reinterpret_cast<char*> (&row1_), sizeof(row1_));
60  stream.read (reinterpret_cast<char*> (&col1_), sizeof(col1_));
61  stream.read (reinterpret_cast<char*> (&row2_), sizeof(row2_));
62  stream.read (reinterpret_cast<char*> (&col2_), sizeof(col2_));
63  stream.read (reinterpret_cast<char*> (&wsizex1_), sizeof(wsizex1_));
64  stream.read (reinterpret_cast<char*> (&wsizex2_), sizeof(wsizex2_));
65  stream.read (reinterpret_cast<char*> (&wsizey1_), sizeof(wsizey1_));
66  stream.read (reinterpret_cast<char*> (&wsizey2_), sizeof(wsizey2_));
67  stream.read (reinterpret_cast<char*> (&threshold_), sizeof(threshold_));
68  stream.read (reinterpret_cast<char*> (&used_ii_), sizeof(used_ii_));
69  }
70  };
71 
72  template<class FeatureType>
73  class RFTreeNode
74  {
75  public:
76  float threshold;
78  std::vector<RFTreeNode> sub_nodes;
79  float value;
80  float variance;
81 
82  Eigen::Vector3d trans_mean_;
83  Eigen::Vector3d rot_mean_;
84 
85  float purity_;
86  Eigen::Matrix3d covariance_trans_;
87  Eigen::Matrix3d covariance_rot_;
88 
90 
91  void serialize(::std::ostream & stream) const
92  {
93 
94  const int num_of_sub_nodes = static_cast<int> (sub_nodes.size ());
95  stream.write (reinterpret_cast<const char*> (&num_of_sub_nodes), sizeof(num_of_sub_nodes));
96 
97  if (!sub_nodes.empty ())
98  {
99  feature.serialize (stream);
100  stream.write (reinterpret_cast<const char*> (&threshold), sizeof(threshold));
101  }
102 
103  stream.write (reinterpret_cast<const char*> (&value), sizeof(value));
104  stream.write (reinterpret_cast<const char*> (&variance), sizeof(variance));
105 
106  for (std::size_t i = 0; i < 3; i++)
107  stream.write (reinterpret_cast<const char*> (&trans_mean_[i]), sizeof(trans_mean_[i]));
108 
109  for (std::size_t i = 0; i < 3; i++)
110  stream.write (reinterpret_cast<const char*> (&rot_mean_[i]), sizeof(rot_mean_[i]));
111 
112  for (std::size_t i = 0; i < 3; i++)
113  for (std::size_t j = 0; j < 3; j++)
114  stream.write (reinterpret_cast<const char*> (&covariance_trans_ (i, j)), sizeof(covariance_trans_ (i, j)));
115 
116  for (std::size_t i = 0; i < 3; i++)
117  for (std::size_t j = 0; j < 3; j++)
118  stream.write (reinterpret_cast<const char*> (&covariance_rot_ (i, j)), sizeof(covariance_rot_ (i, j)));
119 
120  for (int sub_node_index = 0; sub_node_index < num_of_sub_nodes; ++sub_node_index)
121  {
122  sub_nodes[sub_node_index].serialize (stream);
123  }
124  }
125 
126  inline void deserialize(::std::istream & stream)
127  {
128  int num_of_sub_nodes;
129  stream.read (reinterpret_cast<char*> (&num_of_sub_nodes), sizeof(num_of_sub_nodes));
130 
131  if (num_of_sub_nodes > 0)
132  {
133  feature.deserialize (stream);
134  stream.read (reinterpret_cast<char*> (&threshold), sizeof(threshold));
135  }
136 
137  stream.read (reinterpret_cast<char*> (&value), sizeof(value));
138  stream.read (reinterpret_cast<char*> (&variance), sizeof(variance));
139 
140  for (std::size_t i = 0; i < 3; i++)
141  stream.read (reinterpret_cast<char*> (&trans_mean_[i]), sizeof(trans_mean_[i]));
142 
143  for (std::size_t i = 0; i < 3; i++)
144  stream.read (reinterpret_cast<char*> (&rot_mean_[i]), sizeof(rot_mean_[i]));
145 
146  for (std::size_t i = 0; i < 3; i++)
147  for (std::size_t j = 0; j < 3; j++)
148  stream.read (reinterpret_cast<char*> (&covariance_trans_ (i, j)), sizeof(covariance_trans_ (i, j)));
149 
150  for (std::size_t i = 0; i < 3; i++)
151  for (std::size_t j = 0; j < 3; j++)
152  stream.read (reinterpret_cast<char*> (&covariance_rot_ (i, j)), sizeof(covariance_rot_ (i, j)));
153 
154  sub_nodes.resize (num_of_sub_nodes);
155 
156  if (num_of_sub_nodes > 0)
157  {
158  for (int sub_node_index = 0; sub_node_index < num_of_sub_nodes; ++sub_node_index)
159  {
160  sub_nodes[sub_node_index].deserialize (stream);
161  }
162  }
163  }
164  };
165  }
166 }
std::vector< pcl::IntegralImage2D< float, 1 >::Ptr > iimages_
Definition: face_common.h:15
Eigen::Matrix3d covariance_rot_
Definition: face_common.h:87
void serialize(std::ostream &stream) const
Definition: face_common.h:43
void deserialize(std::istream &stream)
Definition: face_common.h:57
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
void deserialize(::std::istream &stream)
Definition: face_common.h:126
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: pcl_macros.h:359
std::vector< RFTreeNode > sub_nodes
Definition: face_common.h:78
PCL_MAKE_ALIGNED_OPERATOR_NEW void serialize(::std::ostream &stream) const
Definition: face_common.h:91
Defines all the PCL and non-PCL macros used.
Eigen::Matrix3d covariance_trans_
Definition: face_common.h:86