crop.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
4 
5 #include <pcl/PointIndices.h>
6 #include <pcl/common/io.h>
7 #include <pcl/point_cloud.h>
8 
9 #include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
10 
11 namespace visionx::tools
12 {
13 
14  template <typename PointCloudT>
15  pcl::PointIndices::Ptr
16  getCropIndices(const PointCloudT& inputCloud, Eigen::Vector3f min, Eigen::Vector3f max)
17  {
18  using PointT = typename PointCloudT::PointType;
19 
21  pcl::PointIndices::Ptr indices(new pcl::PointIndices);
22  for (size_t i = 0; i < inputCloud.size(); ++i)
23  {
24  const PointT& p = inputCloud[i];
25  if (aabb.is_inside(p))
26  {
27  indices->indices.push_back(int(i));
28  }
29  }
30  return indices;
31  }
32 
33  template <typename PointCloudT>
34  typename PointCloudT::Ptr
35  getCropped(const PointCloudT& inputCloud, Eigen::Vector3f min, Eigen::Vector3f max)
36  {
37  pcl::PointIndices::Ptr indices = getCropIndices(inputCloud, min, max);
38 
39  typename PointCloudT::Ptr result(new PointCloudT);
40  pcl::copyPointCloud(inputCloud, *indices, *result);
41 
42  return result;
43  }
44 
45 } // namespace visionx::tools
visionx::tools
Definition: PCLUtilities.cpp:3
visionx::armem::pointcloud::PointType
PointType
Definition: constants.h:78
armarx::aron::simox::arondto::AxisAlignedBoundingBox
::simox::arondto::AxisAlignedBoundingBox AxisAlignedBoundingBox
Definition: simox.h:14
visionx::tools::getCropIndices
pcl::PointIndices::Ptr getCropIndices(const PointCloudT &inputCloud, Eigen::Vector3f min, Eigen::Vector3f max)
Definition: crop.h:16
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
max
T max(T t1, T t2)
Definition: gdiam.h:51
armarx::PointCloudT
pcl::PointCloud< PointT > PointCloudT
Definition: Common.h:32
visionx::tools::getCropped
PointCloudT::Ptr getCropped(const PointCloudT &inputCloud, Eigen::Vector3f min, Eigen::Vector3f max)
Definition: crop.h:35
min
T min(T t1, T t2)
Definition: gdiam.h:44
visionx::PointT
pcl::PointXYZRGBA PointT
Definition: MaskRCNNPointCloudObjectLocalizer.h:77