pcl的ApproximateVoxelGrid类
此方法保留的是体素网格所有点的中心点坐标(平均值),但是此方法和VoxelGrid方法不同之处在于,此方法保存中心点坐标时,其表示的网格坐标并不唯一,因此会出现一个体素网格保存多个输出采样点的情况。
int ix = static_cast<int> (floor (input_->points[cp].x * inverse_leaf_size_[0]));
int iy = static_cast<int> (floor (input_->points[cp].y * inverse_leaf_size_[1]));
int iz = static_cast<int> (floor (input_->points[cp].z * inverse_leaf_size_[2]));
unsigned int hash = static_cast<unsigned int> ((ix * 7171 + iy * 3079 + iz * 4231) & (histsize_ - 1));
he *hhe = &history_[hash];
if (hhe->count && ((ix != hhe->ix) || (iy != hhe->iy) || (iz != hhe->iz)))
{
flush (output, op++, hhe, rgba_index, centroid_size);
hhe->count = 0;
hhe->centroid.setZero ();// = Eigen::VectorXf::Zero (centroid_size);
}
问题就出在这里,
(-6,36,24)的索引值为402
(1,33,24)的索引值为402
如果第一个点落在(-6,36,24),history_会保存402数据
第二个点落在(1,33,24)内,根据上述出代码的判断,符合条件,算法会将第一个点进行输出。并更新402内容。
如果此时第三个点仍然落在(-6,36,24)网格内,再次符合上述条件,算法会将第二个点进行输出,并更新402的内容。
最终会保存402网格对应的中心点。
最终的结果就是(-6,36,24)网格保存了两次。