| 19 | constexpr float normal_estimation_search_radius = 0.05f; |
| 20 | |
| 21 | PointCloud<PointNormal>::Ptr |
| 22 | subsampleAndCalculateNormals(const PointCloud<PointXYZ>::Ptr& cloud) |
| 23 | { |
| 24 | PointCloud<PointXYZ>::Ptr cloud_subsampled(new PointCloud<PointXYZ>()); |
| 25 | VoxelGrid<PointXYZ> subsampling_filter; |
| 26 | subsampling_filter.setInputCloud(cloud); |
| 27 | subsampling_filter.setLeafSize(subsampling_leaf_size); |
| 28 | subsampling_filter.filter(*cloud_subsampled); |
| 29 | |
| 30 | PointCloud<Normal>::Ptr cloud_subsampled_normals(new PointCloud<Normal>()); |
| 31 | NormalEstimation<PointXYZ, Normal> normal_estimation_filter; |
| 32 | normal_estimation_filter.setInputCloud(cloud_subsampled); |
| 33 | search::KdTree<PointXYZ>::Ptr search_tree(new search::KdTree<PointXYZ>); |
| 34 | normal_estimation_filter.setSearchMethod(search_tree); |
| 35 | normal_estimation_filter.setRadiusSearch(normal_estimation_search_radius); |
| 36 | normal_estimation_filter.compute(*cloud_subsampled_normals); |
| 37 | |
| 38 | PointCloud<PointNormal>::Ptr cloud_subsampled_with_normals( |
| 39 | new PointCloud<PointNormal>()); |
| 40 | concatenateFields( |
| 41 | *cloud_subsampled, *cloud_subsampled_normals, *cloud_subsampled_with_normals); |
| 42 | |
| 43 | PCL_INFO("Cloud dimensions before / after subsampling: %zu / %zu\n", |
| 44 | static_cast<std::size_t>(cloud->size()), |
| 45 | static_cast<std::size_t>(cloud_subsampled->size())); |
| 46 | return cloud_subsampled_with_normals; |
| 47 | } |
| 48 | |
| 49 | int |
| 50 | main(int argc, char** argv) |
no test coverage detected