当它在sor.filter()运行时。该计划看起来像是被绞死了。 没有错误。
我认为这些是pcd文件的错误。因为它适用于PCL提供的pcd数据。我的pcd文件是从Kinect2保存的。但我无法找到它们之间的区别。
boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> > cloud(new pcl::PointCloud<pcl::PointXYZ>);
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(
new pcl::visualization::PCLVisualizer("Point Cloud Viewer"));
viewer->setCameraPosition(0.0, 0.0, -2.5, 0.0, 0.0, 0.0);
pcl::io::loadPCDFile("table_scene_lms400.pcd",*cloud);
//pcl::io::loadPCDFile("test.pcd",*cloud);
pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
sor.setMeanK(50);
sor.setStddevMulThresh(1);
pcl::PointCloud < pcl::PointXYZ >::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);
sor.setInputCloud(cloud);
sor.filter(*cloud_filtered);
viewer->addPointCloud(cloud_filtered,"cloud");
答案 0 :(得分:0)
至少,我发现有很多分数&#39;我的pcd文件中的坐标是[0,0,0]。这就是问题所在。我试图通过一个直通过滤器来移动它们。而且这种结果令人兴奋。但我希望能有更好的方法来解决这些问题。
答案 1 :(得分:0)
我使用此函数从pointclouds中删除有限点和空点,它基于PCL Conditional removal类和isFinite():
PointCloudPtr null_filter(const PointCloudPtr cloud_in)
{
PointCloudPtr cloud_out(new PointCloud);
PointCloudPtr temp(new PointCloud);
// build the condition
pcl::ConditionOr<PointT>::Ptr range_cond(new pcl::ConditionOr<PointT>());
range_cond->addComparison(pcl::FieldComparison<PointT>::ConstPtr(new pcl::FieldComparison<PointT>("x", pcl::ComparisonOps::GT, 0.0)));
range_cond->addComparison(pcl::FieldComparison<PointT>::ConstPtr(new pcl::FieldComparison<PointT>("x", pcl::ComparisonOps::LT, 0.0)));
range_cond->addComparison(pcl::FieldComparison<PointT>::ConstPtr(new pcl::FieldComparison<PointT>("y", pcl::ComparisonOps::GT, 0.0)));
range_cond->addComparison(pcl::FieldComparison<PointT>::ConstPtr(new pcl::FieldComparison<PointT>("y", pcl::ComparisonOps::LT, 0.0)));
range_cond->addComparison(pcl::FieldComparison<PointT>::ConstPtr(new pcl::FieldComparison<PointT>("z", pcl::ComparisonOps::GT, 0.0)));
range_cond->addComparison(pcl::FieldComparison<PointT>::ConstPtr(new pcl::FieldComparison<PointT>("z", pcl::ComparisonOps::LT, 0.0)));
// build the filter
pcl::ConditionalRemoval<PointT> condrem;
condrem.setCondition(range_cond);
condrem.setInputCloud(cloud_in);
// apply filter
condrem.filter(*cloud_out);
pcl::PointCloud<PointT>::iterator del = cloud_out->points.begin();
for (int i = 0; i < cloud_out->points.size(); i++)
{
if (!pcl::isFinite<PointT>(cloud_out->points[i]))
{
// PCL_WARN("normals[%d] is not finite\n", i);
cloud_out->points.erase(del + i);
}
}
std::vector<int> indices;
pcl::removeNaNFromPointCloud(*cloud_out, *temp, indices);
return temp;
}