| 98 | } |
| 99 | |
| 100 | void |
| 101 | compute (const CloudT::Ptr &cloud, |
| 102 | const CloudLT::Ptr &anno, |
| 103 | float normal_radius_search, |
| 104 | float leaf_x, float leaf_y, float leaf_z, |
| 105 | CloudLT::Ptr &out) |
| 106 | { |
| 107 | TicToc tt; |
| 108 | tt.tic (); |
| 109 | |
| 110 | print_highlight ("Computing "); |
| 111 | |
| 112 | pcl::PointCloud<pcl::PointNormal>::Ptr cloud_normals (new pcl::PointCloud<pcl::PointNormal>); |
| 113 | cloud_normals->width = cloud->width; |
| 114 | cloud_normals->height = cloud->height; |
| 115 | cloud_normals->points.resize (cloud->size ()); |
| 116 | for (std::size_t i = 0; i < cloud->size (); i++) |
| 117 | { |
| 118 | (*cloud_normals)[i].x = (*cloud)[i].x; |
| 119 | (*cloud_normals)[i].y = (*cloud)[i].y; |
| 120 | (*cloud_normals)[i].z = (*cloud)[i].z; |
| 121 | } |
| 122 | |
| 123 | // estimate surface normals |
| 124 | pcl::NormalEstimation<PointT, pcl::PointNormal> ne; |
| 125 | pcl::search::KdTree<PointT>::Ptr tree (new pcl::search::KdTree<PointT> ()); |
| 126 | ne.setSearchMethod (tree); |
| 127 | ne.setInputCloud (cloud); |
| 128 | ne.setRadiusSearch (normal_radius_search); |
| 129 | ne.compute (*cloud_normals); |
| 130 | |
| 131 | pcl::CrfSegmentation<PointT> crf; |
| 132 | crf.setInputCloud (cloud); |
| 133 | crf.setNormalCloud (cloud_normals); |
| 134 | crf.setAnnotatedCloud (anno); |
| 135 | crf.setVoxelGridLeafSize (leaf_x, leaf_y, leaf_z); |
| 136 | crf.setSmoothnessKernelParameters (3, 3, 3, 1.0); |
| 137 | crf.setAppearanceKernelParameters (30, 30, 30, 20, 20, 20, 3.5); |
| 138 | crf.setSurfaceKernelParameters (20, 20, 20, 0.3f, 0.3f, 0.3f, 8.5); |
| 139 | //crf.setSurfaceKernelParameters (20, 20, 20, 0.3, 0.3, 0.3, 0.0); |
| 140 | crf.setNumberOfIterations (10); |
| 141 | crf.segmentPoints (*out); |
| 142 | |
| 143 | print_info ("[done, "); |
| 144 | print_value ("%g", tt.toc ()); |
| 145 | print_info (" ms : "); print_value ("%d", out->width * out->height); |
| 146 | print_info (" points]\n"); |
| 147 | } |
| 148 | |
| 149 | void |
| 150 | saveCloud (const std::string &filename, CloudLT::Ptr &output) |
no test coverage detected