【问题标题】:PCL downsample with pcl::VoxelGrid使用 pcl::VoxelGrid 进行 PCL 下采样
【发布时间】:2017-04-18 21:10:49
【问题描述】:

下面的函数不会产生任何结果。换句话说,点云中的点数与下采样前完全相同。我尝试了从 0.01 到您在下面看到的叶子大小的各种数字,但它们都产生相同的结果。我不得不从pcl::PointCloud<T>pcl::PCLPointCloud2 进行转换(如下所示),所以我怀疑它们可能是这里的问题。

如果您有类似的问题并解决了,请告诉我。 谢谢。

typedef pcl::PointCloud<pcl::PointXYZ>::Ptr PointCloudPtr;

void PlantVis::downsample(PointCloudPtr cloud) {
    pcl::PCLPointCloud2::Ptr cloud2(new pcl::PCLPointCloud2());
    pcl::toPCLPointCloud2(*cloud, *cloud2);

    pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2());

    pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
    sor.setInputCloud(cloud2);
    sor.setLeafSize(500000000.01f, 500000000.01f, 500000000.01f);
    sor.filter(*cloud_filtered);

    pcl::PointCloud<pcl::PointXYZ>::Ptr m_cloud(new pcl::PointCloud<pcl::PointXYZ>);
    pcl::fromPCLPointCloud2(*cloud_filtered, *m_cloud);
    cloud = m_cloud;
}

【问题讨论】:

    标签: c++ point-cloud-library


    【解决方案1】:

    为什么需要所有的转换?试试这个:

    void PlantVis::downsample(PointCloudPtr cloud) {
        PointCloudPtr output(new pcl::PointCloud<pcl::PointXYZ>);
        pcl::VoxelGrid<pcl::PointXYZ> sor;
        sor.setInputCloud(input_cloud);
        sor.setLeafSize(0.001f, 0.001f, 0.001f);
        sor.filter(*output);
    
        //display or do something else with output
    }
    

    【讨论】:

    • 谢谢。您的代码显示了我之前忽略的内容。
    • 如果是pcl::PCLPointCloud2,即pcl::VoxelGrid&lt;pcl::PCLPointCloud2&gt; sor,我们可以直接传递一个点云,或者我们必须传递一个点,即pcl::VoxelGrid&lt;pcl::PointXYZ&gt; sor,这不是很不直观吗?有什么想法,为什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 2019-06-26
    • 2020-11-23
    相关资源
    最近更新 更多