44#include < pcl/features/integral_image_normal.h>
55#include < pcl/io/pcd_io.h>
66
7+ #include < random>
8+
79// Uncomment the following lines and set PCL_FACE_DETECTION_VIS_TRAINING_FDDP to 1
810// to visualize the training process and change the CMakeLists.txt accordingly.
911// #include <pcl/visualization/pcl_visualizer.h>
@@ -136,13 +138,14 @@ void pcl::face_detection::FaceDetectorDataProvider<FeatureType, DataSet, LabelTy
136138 if (min_images_per_bin_ != -1 )
137139 {
138140 std::cout << " Reducing unbalance of the dataset." << std::endl;
141+ std::mt19937 rng ((std::random_device ()()));
139142 for (int i = 0 ; i < num_yaw; i++)
140143 {
141144 for (int j = 0 ; j < num_pitch; j++)
142145 {
143146 if (yaw_pitch_bins[i][j] >= min_images_per_bin_)
144147 {
145- std::random_shuffle (image_files_per_bin[i][j].begin (), image_files_per_bin[i][j].end ());
148+ std::shuffle (image_files_per_bin[i][j].begin (), image_files_per_bin[i][j].end (), rng );
146149 image_files_per_bin[i][j].resize (min_images_per_bin_);
147150 yaw_pitch_bins[i][j] = min_images_per_bin_;
148151 }
@@ -167,8 +170,8 @@ template<class FeatureType, class DataSet, class LabelType, class ExampleIndex,
167170void pcl::face_detection::FaceDetectorDataProvider<FeatureType, DataSet, LabelType, ExampleIndex, NodeType>::getDatasetAndLabels(DataSet & data_set,
168171 std::vector<LabelType> & label_data, std::vector<ExampleIndex> & examples)
169172{
170- srand ( static_cast < unsigned int >( time ( nullptr )));
171- std::random_shuffle (image_files_.begin (), image_files_.end ());
173+ std::mt19937 rng (( std::random_device ()( )));
174+ std::shuffle (image_files_.begin (), image_files_.end (), rng );
172175 std::vector < std::string > files;
173176 files = image_files_;
174177 files.resize (std::min (num_images_, static_cast <int > (files.size ())));
@@ -393,8 +396,8 @@ void pcl::face_detection::FaceDetectorDataProvider<FeatureType, DataSet, LabelTy
393396 }
394397
395398 // shuffle and resize
396- std::random_shuffle (positive_p.begin (), positive_p.end ());
397- std::random_shuffle (negative_p.begin (), negative_p.end ());
399+ std::shuffle (positive_p.begin (), positive_p.end (), rng );
400+ std::shuffle (negative_p.begin (), negative_p.end (), rng );
398401 positive_p.resize (N_patches);
399402 negative_p.resize (N_patches);
400403
0 commit comments