说明
本文记录几种使用pcl配准库时,该库使用了KdTree方法,运行中的报错如 Assertion point_representation_->isValid (point)、Assertion
index > 0 && index < count’ failed.等, 以及解决方法。
报错信息一
normal_distributions_transform: /build/pcl-OilVEB/pcl-1.8.1+dfsg1/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp:172: int pcl::KdTreeFLANN<PointT, Dist>::radiusSearch(const PointT&, double, std::vector&, std::vector&, unsigned int) const [with PointT = pcl::PointXYZ; Dist = flann::L2_Simple]: Assertion `point_representation_->isValid (point) && “Invalid (NaN, Inf) point coordinates given to radiusSearch!”’ failed.
报错信息二
normal_distributions_transform: /usr/include/flann/algorithms/kdtree_single_index.h:492:
eeSingleIndex<flann::L2_Simple >::Interval> >]: Assertion `index > 0 && index < count’ failed.
Aborted (core dumped)
原因和解决办法
一般是点云中存在异常值导致,可以使用pcl库中自带的removeNan函数来解决。
//将自己的cloud在这里设置好
std::vector<int> indices;
pcl::removeNaNFromPointCloud(*cloud, *cloud, indices);
std::cout << "After remove nan, left " << cloud->size() << " data points ."<< std::endl;