14 #include <boost/filesystem/operations.hpp>
15 #include <boost/shared_ptr.hpp>
16 #include <boost/algorithm/string.hpp>
19 #include <pcl/recognition/face_detection/face_common.h>
20 #include <pcl/ml/dt/decision_tree_data_provider.h>
22 namespace bf = boost::filesystem;
26 namespace face_detection
28 template<
class FeatureType,
class DataSet,
class LabelType,
class ExampleIndex,
class NodeType>
33 std::vector<std::string> image_files_;
36 int patches_per_image_;
37 int min_images_per_bin_;
39 void getFilesInDirectory(bf::path & dir, std::string & rel_path_so_far, std::vector<std::string> & relative_paths, std::string & ext)
41 for (
const auto& dir_entry : bf::directory_iterator(dir))
44 if (bf::is_directory (dir_entry))
46 std::string so_far = rel_path_so_far + (dir_entry.path ().filename ()).
string () +
"/";
47 bf::path curr_path = dir_entry.path ();
48 getFilesInDirectory (curr_path, so_far, relative_paths, ext);
52 std::vector < std::string > strs;
53 std::string file = (dir_entry.path ().filename ()).
string ();
54 boost::split (strs, file, boost::is_any_of (
"."));
55 std::string extension = strs[strs.size () - 1];
59 std::string path = rel_path_so_far + (dir_entry.path ().filename ()).
string ();
60 relative_paths.push_back (path);
66 inline bool readMatrixFromFile(std::string file, Eigen::Matrix4f & matrix)
70 in.open (file.c_str (), std::ifstream::in);
77 in.getline (linebuf, 1024);
78 std::string line (linebuf);
79 std::vector < std::string > strs_2;
80 boost::split (strs_2, line, boost::is_any_of (
" "));
82 for (
int i = 0; i < 16; i++)
84 matrix (i / 4, i % 4) =
static_cast<float> (atof (strs_2[i].c_str ()));
90 bool check_inside(
int col,
int row,
int min_col,
int max_col,
int min_row,
int max_row)
92 return col >= min_col && col <= max_col && row >= min_row && row <= max_row;
95 template<
class Po
intInT>
98 cloud_out.
width = max_col - min_col + 1;
99 cloud_out.
height = max_row - min_row + 1;
101 for (
unsigned int u = 0; u < cloud_out.
width; u++)
103 for (
unsigned int v = 0; v < cloud_out.
height; v++)
105 cloud_out.
at (u, v) = cloud_in.
at (min_col + u, min_row + v);
120 USE_NORMALS_ =
false;
122 patches_per_image_ = 20;
123 min_images_per_bin_ = -1;
133 patches_per_image_ = n;
138 min_images_per_bin_ = n;
161 void getDatasetAndLabels(DataSet & data_set, std::vector<LabelType> & label_data, std::vector<ExampleIndex> & examples)
override;