体素近邻搜索
std::vector<int> PclTool::octreeVoxelSearch(const pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, const pcl::PointXYZ searchPoint, const float resolution)
{pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution); octree.setInputCloud(cloud); octree.addPointsFromInputCloud(); std::vector<int> pointIdxVec; if (octree.voxelSearch(searchPoint, pointIdxVec)) {return pointIdxVec;}else{return std::vector<int>();}
}
- 分辨率为:1
k紧邻搜索
std::vector<int> PclTool::octreeKSearch(const pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, const float resolution, const pcl::PointXYZ searchPoint, const unsigned int k)
{pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution); octree.setInputCloud(cloud); octree.addPointsFromInputCloud(); std::vector<int> pointIdxNKNSearch; std::vector<float> pointNKNSquaredDistance; if (octree.nearestKSearch(searchPoint, k, pointIdxNKNSearch, pointNKNSquaredDistance) > 0){return pointIdxNKNSearch;}else{return std::vector<int>();}}
半径内近邻搜索
std::vector<int> PclTool::octreeRadiusSearch(const pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, const float resolution, const pcl::PointXYZ searchPoint, const float radius)
{pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution); octree.setInputCloud(cloud); octree.addPointsFromInputCloud(); std::vector<int> pointIdxRadiusSearch;std::vector<float> pointRadiusSquaredDistance;if (octree.radiusSearch(searchPoint, radius, pointIdxRadiusSearch, pointRadiusSquaredDistance) > 0){return pointIdxRadiusSearch;}else{return std::vector<int>();}
}