| 14 | using pcl::KdTreeFLANN; |
| 15 | |
| 16 | int |
| 17 | main (int argc, char **argv) |
| 18 | { |
| 19 | srand (time (0)); |
| 20 | |
| 21 | PointCloud<PointXYZRGB>::Ptr cloud (new PointCloud<PointXYZRGB>); |
| 22 | |
| 23 | PCDReader pcd; |
| 24 | if (pcd.read (argv[1], *cloud) == -1) |
| 25 | return (-1); |
| 26 | |
| 27 | // Filter the data |
| 28 | std::cerr << "Filtering..." << std::endl; |
| 29 | PassThrough<PointXYZRGB> pass; |
| 30 | pass.setInputCloud (cloud); |
| 31 | PointCloud<PointXYZRGB>::Ptr cloud_filtered (new PointCloud<PointXYZRGB>); |
| 32 | pass.filter (*cloud_filtered); |
| 33 | |
| 34 | // Estimate surface normals |
| 35 | std::cerr << "Estimating normals..." << std::endl; |
| 36 | NormalEstimation<PointXYZRGB, Normal> ne; |
| 37 | ne.setInputCloud (cloud_filtered); |
| 38 | ne.setKSearch (20); |
| 39 | KdTreeFLANN<PointXYZRGB>::Ptr tree (new KdTreeFLANN<PointXYZRGB>); |
| 40 | ne.setSearchMethod (tree); |
| 41 | PointCloud<Normal> normals; |
| 42 | ne.compute (normals); |
| 43 | |
| 44 | // Concatenate points and normals |
| 45 | PointCloud<PointXYZRGBNormal> cloud_normals; |
| 46 | pcl::concatenateFields (cloud_filtered, normals, cloud_normals); |
| 47 | |
| 48 | // Start the visualizer |
| 49 | pcl::visualization::PCLVisualizer p ("test"); |
| 50 | p.setBackgroundColor (1, 1, 1); |
| 51 | p.addCoordinateSystem (0.1); |
| 52 | |
| 53 | pcl::visualization::PointCloudColorHandlerRGBField<PointXYZRGBNormal> color_handler (cloud_normals); |
| 54 | // Geometry handler demo |
| 55 | { |
| 56 | std::cerr << "PointCloudGeometryHandlerSurfaceNormal demo." << std::endl; |
| 57 | pcl::visualization::PointCloudGeometryHandlerSurfaceNormal<PointXYZRGBNormal> geometry_handler (cloud_normals); |
| 58 | p.addPointCloud (cloud_normals, geometry_handler, "cloud_normal"); |
| 59 | p.spin (); |
| 60 | p.removePointCloud ("cloud_normal"); |
| 61 | |
| 62 | p.addPointCloud (cloud_normals, color_handler, geometry_handler, "cloud_normal"); |
| 63 | p.spin (); |
| 64 | p.removePointCloud ("cloud_normal"); |
| 65 | } |
| 66 | |
| 67 | { |
| 68 | std::cerr << "PointCloudGeometryHandlerXYZ demo." << std::endl; |
| 69 | pcl::visualization::PointCloudGeometryHandlerXYZ<PointXYZRGBNormal> geometry_handler (cloud_normals); |
| 70 | p.addPointCloud (cloud_normals, color_handler, geometry_handler, "cloud_xyz"); |
| 71 | p.spin (); |
| 72 | p.removePointCloud ("cloud_xyz"); |
| 73 | } |
nothing calls this directly
no test coverage detected