我有巨大的点云,我想在上面应用 voxelGrid。但由于点云太大,我有错误,如"[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow"
. 所以我想先从我的点云构建一个八叉树,然后在每个叶子上应用过滤器(即在具有良好索引的点云上应用过滤器)
问题出现在这里,当我应用过滤器时,PCL要我选择一个PointCloud 将保存在其中,并将原始点云替换为过滤器的结果。我想知道是否可以修改过滤器以使其不删除点,而仅将必须删除的点云中索引处的点放入(0,0,0)?
我的代码:
void Octree::applyExample(float x, float y, float z) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 100000;
cloud->height = 1;
cloud->is_dense = false;
cloud->points.resize(cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size(); ++i)
{
cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}
octree.setInputCloud(cloud);
octree.addPointsFromInputCloud();
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it;
pcl::octree::OctreePointCloud<pcl::PointXYZRGB>::LeafNodeIterator it_end = octree.leaf_end();
for (it = octree.leaf_begin(); it != it_end; ++it)
{
pcl::IndicesPtr indexVector(new vector<int>);
pcl::octree::OctreeContainerPointIndices& container = it.getLeafContainer();
container.getPointIndices(*indexVector);
FILTREexample(cloud, indexVector, x, y, z);
}
}
和过滤器:
void FILTREexample(pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud, pcl::IndicesPtr indices, float x, float y, float z) {
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(pointcloud);
sor.setIndices(indices);
sor.setLeafSize(x, y, z);
sor.filter(*pointcloud); //The problem occurs here
//Everytime, the pointcloud is substituted with the result of the filter, but I'd like to still have my "entire" pointcloud, but either with the filtered point deleted, or the filtered point put to 0,0,0.
}
有可能做这样的事情吗?