NaN值在正常点

时间:2017-07-20 11:46:29

标签: c++ computer-vision nan point-cloud-library normals

我在验证正常点坐标中包含的值时遇到问题。最初我估计我的云的正常情况,当我检查正常的xyz坐标时,它会返回nan。

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);

// Object for normal estimation.
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normalEstimation;
normalEstimation.setInputCloud(cloud);
// For every point, use all neighbors in a radius of 3cm.
normalEstimation.setRadiusSearch(0.03);
// A kd-tree is a data structure that makes searches efficient. More about it later.
// The normal estimation object will use it to find nearest neighbors.
pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>);
normalEstimation.setSearchMethod(kdtree);

// Calculate the normals.
normalEstimation.compute(*normals);

for (size_t i = 0; i < cloud->points.size(); i++){
  std::cout << "x: " << cloud->points[i].x <<std::endl;
  std::cout << "normal x: " << normals->points[i].normal_x <<std::endl; //-nan here
}

我该如何解决?

1 个答案:

答案 0 :(得分:0)

好像输入点云有问题。确保您的点云不是平面,并确保您没有重复点。使我不舒服的是搜索半径。尝试也玩。

我刚刚用非常相似的代码遇到了类似的问题。评论非常有帮助,谢谢。这可能为时已晚,但仍可能对某人有所帮助。