1 #include <pcl/search/brute_force.h>
 2 #include <pcl/common/common.h>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 using namespace pcl;
 7 
 8 int main()
 9 {
10     pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
11 
12     // x+y+z=1平面
13     for (float x = -1.0; x <= 1.0; x += 0.5)    
14     {    
15         for (float y = -1.0; y <= 1.0; y += 0.5)    
16         {    
17             pcl::PointXYZ cloud_;    
18             cloud_.x = x;    
19             cloud_.y = y;    
20             cloud_.z = 1 - x - y;    
21             cloud->push_back(cloud_);    
22         }    
23     }   
24 
25     pcl::search::BruteForce<pcl::PointXYZ> bfsearch;
26     bfsearch.setInputCloud(cloud);
27     std::vector<int> k_indices;
28     std::vector<float> k_distances;
29     pcl::PointXYZ p(-1.0,-1.0,3.0);
30     bfsearch.nearestKSearch(p,2,k_indices,k_distances);
31 
32     return 0;
33 }
View Code

相关文章: