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