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 
6 namespace 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
visionx::tools
Definition: PCLUtilities.cpp:3
visionx::armem::pointcloud::PointType
PointType
Definition: constants.h:78
detail
Definition: OpenCVUtil.cpp:128
pcl::graph::indices
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
Definition: point_cloud_graph.h:717
armarx::PointCloudT
pcl::PointCloud< PointT > PointCloudT
Definition: Common.h:32
visionx::tools::downsampleByVoxelGrid
PointCloudT::Ptr downsampleByVoxelGrid(typename PointCloudT::ConstPtr inputCloud, float leafSize=5.0, pcl::IndicesConstPtr indices=nullptr)
Definition: downsampling_voxelgrid.hpp:39
visionx::tools::detail::downsampleByVoxelGrid
PointCloudT::Ptr downsampleByVoxelGrid(typename PointCloudT::ConstPtr inputCloud, float leafSize=5.0, const IndicesPtrT &indices=nullptr)
Definition: downsampling_voxelgrid.hpp:14
visionx::PointT
pcl::PointXYZRGBA PointT
Definition: MaskRCNNPointCloudObjectLocalizer.h:77