MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / compute

Function compute

tools/crf_segmentation.cpp:100–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void
101compute (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
149void
150saveCloud (const std::string &filename, CloudLT::Ptr &output)

Callers 1

mainFunction · 0.70

Calls 15

print_valueFunction · 0.85
ticMethod · 0.80
setAnnotatedCloudMethod · 0.80
setVoxelGridLeafSizeMethod · 0.80
tocMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
setSearchMethodMethod · 0.45
setInputCloudMethod · 0.45

Tested by

no test coverage detected