| 70 | } |
| 71 | |
| 72 | int |
| 73 | main(int argc, char** argv) |
| 74 | { |
| 75 | if (argc != 2) { |
| 76 | PCL_ERROR("Syntax: ./multiscale_feature_persistence_example [path_to_cloud.pcl]\n"); |
| 77 | return -1; |
| 78 | } |
| 79 | |
| 80 | PointCloud<PointXYZ>::Ptr cloud_scene(new PointCloud<PointXYZ>()); |
| 81 | PCDReader reader; |
| 82 | reader.read(argv[1], *cloud_scene); |
| 83 | |
| 84 | PointCloud<PointXYZ>::Ptr cloud_subsampled; |
| 85 | PointCloud<Normal>::Ptr cloud_subsampled_normals; |
| 86 | subsampleAndCalculateNormals(cloud_scene, cloud_subsampled, cloud_subsampled_normals); |
| 87 | |
| 88 | PCL_INFO("STATS:\ninitial point cloud size: %zu\nsubsampled point cloud size: %zu\n", |
| 89 | static_cast<std::size_t>(cloud_scene->size()), |
| 90 | static_cast<std::size_t>(cloud_subsampled->size())); |
| 91 | visualization::CloudViewer viewer( |
| 92 | "Multiscale Feature Persistence Example Visualization"); |
| 93 | viewer.showCloud(cloud_scene, "scene"); |
| 94 | |
| 95 | MultiscaleFeaturePersistence<PointXYZ, FPFHSignature33> feature_persistence; |
| 96 | std::vector<float> scale_values; |
| 97 | for (float x = 2.0f; x < 3.6f; x += 0.35f) |
| 98 | scale_values.push_back(x / 100.0f); |
| 99 | feature_persistence.setScalesVector(scale_values); |
| 100 | feature_persistence.setAlpha(1.3f); |
| 101 | FPFHEstimation<PointXYZ, Normal, FPFHSignature33>::Ptr fpfh_estimation( |
| 102 | new FPFHEstimation<PointXYZ, Normal, FPFHSignature33>()); |
| 103 | fpfh_estimation->setInputCloud(cloud_subsampled); |
| 104 | fpfh_estimation->setInputNormals(cloud_subsampled_normals); |
| 105 | pcl::search::KdTree<PointXYZ>::Ptr tree(new pcl::search::KdTree<PointXYZ>()); |
| 106 | fpfh_estimation->setSearchMethod(tree); |
| 107 | feature_persistence.setFeatureEstimator(fpfh_estimation); |
| 108 | feature_persistence.setDistanceMetric(pcl::CS); |
| 109 | |
| 110 | PointCloud<FPFHSignature33>::Ptr output_features(new PointCloud<FPFHSignature33>()); |
| 111 | auto output_indices = pcl::make_shared<pcl::Indices>(); |
| 112 | feature_persistence.determinePersistentFeatures(*output_features, output_indices); |
| 113 | |
| 114 | PCL_INFO("persistent features cloud size: %zu\n", |
| 115 | static_cast<std::size_t>(output_features->size())); |
| 116 | |
| 117 | ExtractIndices<PointXYZ> extract_indices_filter; |
| 118 | extract_indices_filter.setInputCloud(cloud_subsampled); |
| 119 | extract_indices_filter.setIndices(output_indices); |
| 120 | PointCloud<PointXYZ>::Ptr persistent_features_locations(new PointCloud<PointXYZ>()); |
| 121 | extract_indices_filter.filter(*persistent_features_locations); |
| 122 | |
| 123 | viewer.showCloud(persistent_features_locations, "persistent features"); |
| 124 | PCL_INFO("Persistent features have been computed. Waiting for the user to quit the " |
| 125 | "visualization window.\n"); |
| 126 | |
| 127 | while (!viewer.wasStopped(50)) { |
| 128 | } |
| 129 |
nothing calls this directly
no test coverage detected