30 #ifndef MCL_3DL_POINT_CLOUD_RANDOM_SAMPLER_H 31 #define MCL_3DL_POINT_CLOUD_RANDOM_SAMPLER_H 35 #include <pcl/point_types.h> 44 std::shared_ptr<std::default_random_engine>
engine_;
48 : engine_(new
std::default_random_engine(seed_gen_()))
51 template <
class POINT_TYPE>
52 typename pcl::PointCloud<POINT_TYPE>::Ptr
sample(
53 const typename pcl::PointCloud<POINT_TYPE>::ConstPtr& pc,
54 const size_t num)
const 56 typename pcl::PointCloud<POINT_TYPE>::Ptr output(
new pcl::PointCloud<POINT_TYPE>);
57 output->header = pc->header;
59 if (pc->points.size() == 0)
62 output->points.reserve(num);
63 std::uniform_int_distribution<size_t> ud(0, pc->points.size() - 1);
64 for (
size_t i = 0; i < num; i++)
66 output->push_back(pc->points[ud(*engine_)]);
74 #endif // MCL_3DL_POINT_CLOUD_RANDOM_SAMPLER_H std::shared_ptr< std::default_random_engine > engine_
PointCloudRandomSampler()
pcl::PointCloud< POINT_TYPE >::Ptr sample(const typename pcl::PointCloud< POINT_TYPE >::ConstPtr &pc, const size_t num) const
std::random_device seed_gen_