如何使用PCD文件(现有点云集)设置“ pcl :: PointIndices”

时间:2018-09-21 04:54:06

标签: point-cloud-library point-clouds

我正在尝试实现点云背景减法。 (例如,background.pcd = input.pcd-object.pcd)

我找到了以下代码

  pcl::PointCloud<pcl::PointXYZ>::Ptr p_obstacles(new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
  pcl::ExtractIndices<pcl::PointXYZ> extract;

// Insert something. 

  extract.setInputCloud(p_obstacles);
  extract.setIndices(inliers);
  extract.setNegative(true);
  extract.filter(*p_obstacles);

Removing points from a pcl::PointCloud<pcl::PointXYZRGB>

在我的低估中,从input.pcd中减去inliers (inliers = object.pcd ??)

我不知道如何用预先存在的x,y,z值(pcd)设置Inliers值

谢谢!

1 个答案:

答案 0 :(得分:0)

PCLBase类中有一个getIndices()方法:http://docs.pointclouds.org/1.8.1/classpcl_1_1_p_c_l_base.html#a058753dd4de73d3d0062fe2e452fba3c

这里是使用方法:

pcl::PCLBase<pcl::PointXYZ> base; // Instantiate the PCLBase class
base.setInputCloud(object_cloud); // Set input cloud before grabbing the indices
auto object_indices = base.getIndices();
extract.setIndices(object_indices);

您可能需要包括头文件

#include <pcl/pcl_base.h>

如果尚未从pcd文件创建点云,则可以按照以下教程进行操作: http://pointclouds.org/documentation/tutorials/reading_pcd.php