下面的函数不会产生任何结果。也就是说,点云中的点数与降采样前完全相同。我尝试了从 0.01 一直到下面看到的叶子大小的各种数字,但所有这些数字都产生相同的结果。我必须记录来自的转化(如下所示)pcl::PointCloud<T>
to 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
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)