【问题标题】:pcl::PointCloud<pcl::PointXYZ> to pcl::PointCloud<pcl::PointXYZ>::Ptr (Covert poincloud to ptr)pcl::PointCloud<pcl::PointXYZ> 到 pcl::PointCloud<pcl::PointXYZ>::Ptr(将 poincloud 隐蔽到 ptr)
【发布时间】:2020-12-02 18:06:25
【问题描述】:

我正在使用 PCL 1.3。是否有任何函数可以将点云转换为点云::ptr。我是 PCL 图书馆的新手。我有一个订阅 sensor_msgs/PoinCloud2 主题的 ROS 节点,然后我将其转换为 pcl::Poincloud,现在我想做 pcl::StatisticalOutlierRemoval。异常值删除函数接收指针,而不是 Poincloud 本身(这就是我所理解的)。所以为了这个目的,我想知道如何在它们之间转换的解决方案?

pcl::PointCloud<pcl::PointXYZ> point_cloud
pcl::fromPCLPointCloud2(cloud_filtered, point_cloud);


pcl::removeNaNFromPointCloud(point_cloud, point_cloud, nan_idx);

pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
sor.setInputCloud (point_cloud);
sor.setMeanK (50);
sor.setStddevMulThresh (1.0);
sor.filter (*point_cloud);

错误:没有匹配函数调用‘pcl::StatisticalOutlierRemovalpcl::PointXYZ::setInputCloud(**pcl::PointCloudpcl::PointXYZ**&)’

注意:候选人:void pcl::PCLBase::setInputCloud(const PointCloudConstPtr&) [with PointT = pcl::PointXYZ; pcl::PCLBase::PointCloudConstPtr = boost::shared_ptr]

【问题讨论】:

  • 请出示一些代码。

标签: pointers shared-ptr point-cloud-library point-clouds outliers


【解决方案1】:

pcl::PointCloud&lt;pcl::PointXYZ&gt;::Ptr 是一个shared_ptr - 所以,简单地说,它是一个围绕一个 pointer 的包装器,用于管理它的生命周期(在我们的例子中,它是一个围绕指向 pcl::PointCloud&lt;pcl::PointXYZ&gt; 的指针的包装器)。

您通过传递一个指针来实例化它,例如来自new 的那个: pcl::PointCloud&lt;pcl::PointXYZ&gt;::Ptr point_cloud(new pcl::PointCloud&lt; pcl::PointXYZ&gt;);

由于pcl::fromPCLPointCloud2 需要pcl::PointCloud&lt;pcl::PointXYZ&gt;,因此您需要dereferencingpcl::fromPCLPointCloud2(cloud_filtered, *point_cloud);

【讨论】:

  • 非常感谢。你的解决方案奏效了。感谢您的详细解释。
猜你喜欢
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
  • 1970-01-01
  • 2012-05-25
  • 2020-07-31
  • 2015-03-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多