如何正确使用 PCL 的阴影点类

how to properly use PCL's ShadowPoints class

本文关键字:阴影 PCL 何正确      更新时间:2023-10-16

我正在使用点云库(PCL),并试图从点云中删除阴影点。

为了做到这一点,我使用ShadowPoints过滤器类。出于某种原因,它从我的点云中过滤掉了所有点,无论我使用的阈值如何(在附加的代码中,我使用的是默认阈值,但我尝试使用各种阈值运行此代码)。

我在网上搜索了相关数据,但找不到问题的答案。 我在这里错过了什么?

//input point cloud.
pcl::PointCloud<pcl::PointXYZRGB>::Ptr sourceCloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZ>::Ptr sourceCloudBasic(new pcl::PointCloud<pcl::PointXYZ>);
/* code for filling sourceCloud and sourceCloudBasic*/
...
//output point cloud 
pcl::PointCloud<pcl::PointXYZRGB>::Ptr outCloud(new pcl::PointCloud<pcl::PointXYZRGB>());
//filter object
pcl::ShadowPoints<pcl::PointXYZRGB, pcl::Normal> shadowfilters(true);
//sets the source point cloud
shadowfilters.setInputCloud(sourceCloud);
//calculates normals
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
ne.setInputCloud(sourceCloudBasic);
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());
ne.setSearchMethod(tree);
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals(new pcl::PointCloud<pcl::Normal>);
double normalsThreshold = 0.3;
ne.setRadiusSearch(normalsThreshold);
ne.compute(*cloud_normals);
//sets normals into shadowfilters
shadowfilters.setNormals(cloud_normals);
//sets threshold
double shadowThreshold = 0.1;
shadowfilters.setThreshold(shadowThreshold);
//filters
shadowfilters.filter(*outCloud);

非常感谢!

问题解决了。网格是从嘈杂的深度图像创建的 - 因此法线也不准确。它使阴影过滤器将所有内容标记为阴影。扩大法线计算的半径搜索可改进法线贴图,从而使阴影过滤器正常工作。