如何使用“ OctreePointCloudAdjacency”获取相邻体素的列表

时间:2018-12-27 20:44:13

标签: c++ point-cloud-library

我可以成功创建八叉树数据结构。然后,我必须为八叉树中的每个体素获取相邻的体素列表。我尝试使用OctreePointCloudAdjacency,但是返回的indexVector的大小为0。请帮助我获取相邻体素列表吗? 我期待着您的回音 预先感谢

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new   pcl::PointCloud<pcl::PointXYZ>);
//read pcd file
pcl::io::loadPCDFile<pcl::PointXYZ>("FARO_SCAN010203_SEMI_DIAGONAL - Cloud.pcd", *cloud);
//voxel dimension
float resolution;
std::cout << "Voxel buyuklugu m cinsinden girin." << std::endl;
std::cin >> resolution;
pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution);
octree.setInputCloud(cloud);

octree.setInputCloud(cloud);
octree.addPointsFromInputCloud();
std::cout << "Number of voxels: " << octree.getLeafCount() << std::endl;

std::vector<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ>> pointGrid;
octree.getOccupiedVoxelCenters(pointGrid);

//get adjacent voxels of a voxel
pcl::octree::OctreePointCloudAdjacency<pcl::PointXYZ > deneme(resolution);
deneme.setInputCloud(cloud);
deneme.addPointsFromInputCloud();
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ> *leaf_container;
leaf_container = deneme.getLeafContainerAtPoint(cloud->points[1000]);

std::cout << "leaf container size =" << leaf_container->size() << std::endl;
std::cout << "leaf_container number of meighbors =" << leaf_container->getNumNeighbors() << std::endl;
std::cout << "leaf container point counter =" << leaf_container->getPointCounter() << std::endl;
std::cout << "leaf container size2 =" << leaf_container->getSize() << std::endl;
pcl::IndicesPtr indexVectorXX(new std::vector <int>);
leaf_container->getPointIndices(*indexVectorXX);
std::cout << "index vector size =" << indexVectorXX->size() << std::endl;

0 个答案:

没有答案