downsampling_voxelgrid.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pcl/filters/voxel_grid.h>
4#include <pcl/point_cloud.h>
5
6namespace visionx::tools
7{
8
9 namespace detail
10 {
11
12 template <typename PointCloudT, typename IndicesPtrT = pcl::IndicesConstPtr>
13 typename PointCloudT::Ptr
14 downsampleByVoxelGrid(typename PointCloudT::ConstPtr inputCloud,
15 float leafSize = 5.0,
16 const IndicesPtrT& indices = nullptr)
17 {
18 using PointT = typename PointCloudT::PointType;
19
20 pcl::VoxelGrid<PointT> vg;
21
22 vg.setLeafSize(leafSize, leafSize, leafSize);
23
24 vg.setInputCloud(inputCloud);
25 if (indices)
26 {
27 vg.setIndices(indices);
28 }
29
30 typename PointCloudT::Ptr output(new PointCloudT);
31 vg.filter(*output);
32 return output;
33 }
34
35 } // namespace detail
36
37 template <typename PointCloudT>
38 typename PointCloudT::Ptr
39 downsampleByVoxelGrid(typename PointCloudT::ConstPtr inputCloud,
40 float leafSize = 5.0,
41 pcl::IndicesConstPtr indices = nullptr)
42 {
43 return detail::downsampleByVoxelGrid<PointCloudT>(inputCloud, leafSize, indices);
44 }
45
46 template <typename PointCloudT>
47 typename PointCloudT::Ptr
48 downsampleByVoxelGrid(typename PointCloudT::ConstPtr inputCloud,
49 float leafSize = 5.0,
50 pcl::PointIndicesConstPtr indices = nullptr)
51 {
52 return detail::downsampleByVoxelGrid<PointCloudT>(inputCloud, leafSize, indices);
53 }
54
55} // namespace visionx::tools
PointCloudT::Ptr downsampleByVoxelGrid(typename PointCloudT::ConstPtr inputCloud, float leafSize=5.0, const IndicesPtrT &indices=nullptr)
PointCloudT::Ptr downsampleByVoxelGrid(typename PointCloudT::ConstPtr inputCloud, float leafSize=5.0, pcl::IndicesConstPtr indices=nullptr)