include
include
include
include
include
int main()
{
pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
if (pcl::io::loadPCDFile("path-to-your-point-cloud.pcd", cloud) == -1) // load the file
{
PCL_ERROR("Couldn't read file\n");
return (-1);
}
pcl::search::KdTree::Ptr tree(new pcl::search::KdTree());
tree->setInputCloud(cloud);
pcl::PointCloud::Ptr normals(new pcl::PointCloud);
pcl::NormalEstimation normalEstimation;
normalEstimation.setInputCloud(cloud);
normalEstimation.setSearchMethod(tree);
normalEstimation.setKSearch(20);
normalEstimation.compute(*normals);
for (size_t i = 0; i < normals->size(); ++i)
std::cout << "Normal " << i << ": " << normals->points[i].normal_x << " "
<< normals->points[i].normal_y << " " << normals->points[i].normal_z << std::endl;
return (0);
}