face_common.h
#ifndef FACE_DETECTOR_COMMON_H_
#define FACE_DETECTOR_COMMON_H_
#include <pcl/features/integral_image2D.h>
namespace pcl
{
namespace face_detection
{
class TrainingExample
{
public:
std::vector<boost::shared_ptr<pcl::IntegralImage2D<float, 1> > > iimages_; //also pointer to the respective integral image
int row_, col_;
int wsize_;
int label_;
//save pose head information
Eigen::Vector3f trans_;
Eigen::Vector3f rot_;
};
class FeatureType
{
public:
int row1_, col1_;
int row2_, col2_;
int wsizex1_, wsizey1_;
int wsizex2_, wsizey2_;
float threshold_;
int used_ii_;
FeatureType()
{
used_ii_ = 0;
}
void serialize(std::ostream & stream) const
{
stream.write (reinterpret_cast<const char*> (&row1_), sizeof(row1_));
stream.write (reinterpret_cast<const char*> (&col1_), sizeof(col1_));
stream.write (reinterpret_cast<const char*> (&row2_), sizeof(row2_));
stream.write (reinterpret_cast<const char*> (&col2_), sizeof(col2_));
stream.write (reinterpret_cast<const char*> (&wsizex1_), sizeof(wsizex1_));
stream.write (reinterpret_cast<const char*> (&wsizex2_), sizeof(wsizex2_));
stream.write (reinterpret_cast<const char*> (&wsizey1_), sizeof(wsizey1_));
stream.write (reinterpret_cast<const char*> (&wsizey2_), sizeof(wsizey2_));
stream.write (reinterpret_cast<const char*> (&threshold_), sizeof(threshold_));
stream.write (reinterpret_cast<const char*> (&used_ii_), sizeof(used_ii_));
}
inline void deserialize(std::istream & stream)
{
stream.read (reinterpret_cast<char*> (&row1_), sizeof(row1_));
stream.read (reinterpret_cast<char*> (&col1_), sizeof(col1_));
stream.read (reinterpret_cast<char*> (&row2_), sizeof(row2_));
stream.read (reinterpret_cast<char*> (&col2_), sizeof(col2_));
stream.read (reinterpret_cast<char*> (&wsizex1_), sizeof(wsizex1_));
stream.read (reinterpret_cast<char*> (&wsizex2_), sizeof(wsizex2_));
stream.read (reinterpret_cast<char*> (&wsizey1_), sizeof(wsizey1_));
stream.read (reinterpret_cast<char*> (&wsizey2_), sizeof(wsizey2_));
stream.read (reinterpret_cast<char*> (&threshold_), sizeof(threshold_));
stream.read (reinterpret_cast<char*> (&used_ii_), sizeof(used_ii_));
}
};
template<class FeatureType>
class RFTreeNode
{
public:
float threshold;
FeatureType feature;
std::vector<RFTreeNode> sub_nodes;
float value;
float variance;
Eigen::Vector3d trans_mean_;
Eigen::Vector3d rot_mean_;
float purity_;
Eigen::Matrix3d covariance_trans_;
Eigen::Matrix3d covariance_rot_;
void serialize(::std::ostream & stream) const
{
const int num_of_sub_nodes = static_cast<int> (sub_nodes.size ());
stream.write (reinterpret_cast<const char*> (&num_of_sub_nodes), sizeof(num_of_sub_nodes));
if (sub_nodes.size () > 0)
{
feature.serialize (stream);
stream.write (reinterpret_cast<const char*> (&threshold), sizeof(threshold));
}
stream.write (reinterpret_cast<const char*> (&value), sizeof(value));
stream.write (reinterpret_cast<const char*> (&variance), sizeof(variance));
for (size_t i = 0; i < 3; i++)
stream.write (reinterpret_cast<const char*> (&trans_mean_[i]), sizeof(trans_mean_[i]));
for (size_t i = 0; i < 3; i++)
stream.write (reinterpret_cast<const char*> (&rot_mean_[i]), sizeof(rot_mean_[i]));
for (size_t i = 0; i < 3; i++)
for (size_t j = 0; j < 3; j++)
stream.write (reinterpret_cast<const char*> (&covariance_trans_ (i, j)), sizeof(covariance_trans_ (i, j)));
for (size_t i = 0; i < 3; i++)
for (size_t j = 0; j < 3; j++)
stream.write (reinterpret_cast<const char*> (&covariance_rot_ (i, j)), sizeof(covariance_rot_ (i, j)));
for (int sub_node_index = 0; sub_node_index < num_of_sub_nodes; ++sub_node_index)
{
sub_nodes[sub_node_index].serialize (stream);
}
}
inline void deserialize(::std::istream & stream)
{
int num_of_sub_nodes;
stream.read (reinterpret_cast<char*> (&num_of_sub_nodes), sizeof(num_of_sub_nodes));
if (num_of_sub_nodes > 0)
{
feature.deserialize (stream);
stream.read (reinterpret_cast<char*> (&threshold), sizeof(threshold));
}
stream.read (reinterpret_cast<char*> (&value), sizeof(value));
stream.read (reinterpret_cast<char*> (&variance), sizeof(variance));
for (size_t i = 0; i < 3; i++)
stream.read (reinterpret_cast<char*> (&trans_mean_[i]), sizeof(trans_mean_[i]));
for (size_t i = 0; i < 3; i++)
stream.read (reinterpret_cast<char*> (&rot_mean_[i]), sizeof(rot_mean_[i]));
for (size_t i = 0; i < 3; i++)
for (size_t j = 0; j < 3; j++)
stream.read (reinterpret_cast<char*> (&covariance_trans_ (i, j)), sizeof(covariance_trans_ (i, j)));
for (size_t i = 0; i < 3; i++)
for (size_t j = 0; j < 3; j++)
stream.read (reinterpret_cast<char*> (&covariance_rot_ (i, j)), sizeof(covariance_rot_ (i, j)));
sub_nodes.resize (num_of_sub_nodes);
if (num_of_sub_nodes > 0)
{
for (int sub_node_index = 0; sub_node_index < num_of_sub_nodes; ++sub_node_index)
{
sub_nodes[sub_node_index].deserialize (stream);
}
}
}
};
}
}
#endif /* FACE_DETECTOR_COMMON_H_ */
pcl::face_detection::RFTreeNode::trans_mean_
Eigen::Vector3d trans_mean_
Definition: face_common.h:79
pcl::face_detection::FeatureType::wsizey2_
int wsizey2_
Definition: face_common.h:30
pcl::face_detection::RFTreeNode::covariance_rot_
Eigen::Matrix3d covariance_rot_
Definition: face_common.h:84
pcl::face_detection::FeatureType::row2_
int row2_
Definition: face_common.h:27
pcl::face_detection::FeatureType::serialize
void serialize(std::ostream &stream) const
Definition: face_common.h:40
pcl::face_detection::TrainingExample::iimages_
std::vector< boost::shared_ptr< pcl::IntegralImage2D< float, 1 > > > iimages_
Definition: face_common.h:13
pcl::face_detection::FeatureType::deserialize
void deserialize(std::istream &stream)
Definition: face_common.h:54
pcl
Definition: convolution.h:45
pcl::face_detection::TrainingExample::trans_
Eigen::Vector3f trans_
Definition: face_common.h:19
pcl::face_detection::RFTreeNode::deserialize
void deserialize(::std::istream &stream)
Definition: face_common.h:121
pcl::face_detection::RFTreeNode
Definition: face_common.h:70
pcl::face_detection::FeatureType
Definition: face_common.h:23
pcl::face_detection::FeatureType::wsizey1_
int wsizey1_
Definition: face_common.h:29
pcl::face_detection::TrainingExample::col_
int col_
Definition: face_common.h:14
pcl::face_detection::RFTreeNode::rot_mean_
Eigen::Vector3d rot_mean_
Definition: face_common.h:80
pcl::face_detection::TrainingExample::rot_
Eigen::Vector3f rot_
Definition: face_common.h:20
pcl::face_detection::TrainingExample::wsize_
int wsize_
Definition: face_common.h:15
pcl::face_detection::FeatureType::used_ii_
int used_ii_
Definition: face_common.h:33
pcl::face_detection::RFTreeNode::feature
FeatureType feature
Definition: face_common.h:74
pcl::face_detection::TrainingExample
Definition: face_common.h:10
pcl::face_detection::RFTreeNode::sub_nodes
std::vector< RFTreeNode > sub_nodes
Definition: face_common.h:75
pcl::face_detection::RFTreeNode::value
float value
Definition: face_common.h:76
pcl::face_detection::RFTreeNode::variance
float variance
Definition: face_common.h:77
pcl::face_detection::FeatureType::threshold_
float threshold_
Definition: face_common.h:32
pcl::face_detection::RFTreeNode::purity_
float purity_
Definition: face_common.h:82
pcl::face_detection::TrainingExample::row_
int row_
Definition: face_common.h:14
pcl::face_detection::FeatureType::row1_
int row1_
Definition: face_common.h:26
pcl::face_detection::FeatureType::FeatureType
FeatureType()
Definition: face_common.h:35
pcl::face_detection::TrainingExample::label_
int label_
Definition: face_common.h:16
pcl::face_detection::RFTreeNode::threshold
float threshold
Definition: face_common.h:73
pcl::face_detection::RFTreeNode::serialize
void serialize(::std::ostream &stream) const
Definition: face_common.h:86
pcl::face_detection::RFTreeNode::covariance_trans_
Eigen::Matrix3d covariance_trans_
Definition: face_common.h:83