gpt4 book ai didi

c++ - 使用 pcl::VoxelGrid 的 PCL 下采样

转载 作者:行者123 更新时间:2023-11-30 02:26:09 38 4
gpt4 key购买 nike

下面的函数没有产生结果。换句话说,点云中的点数与降采样前完全相同。我尝试了从 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;
}

最佳答案

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

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
}

关于c++ - 使用 pcl::VoxelGrid 的 PCL 下采样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43245726/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com