-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathlec10_2_normal_corner.cpp
More file actions
42 lines (34 loc) · 1.54 KB
/
Copy pathlec10_2_normal_corner.cpp
File metadata and controls
42 lines (34 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Tutorial Author: shapelim@kaist.ac.kr (임형태)
#include <pcl/point_types.h>
#include <pcl/features/normal_3d.h>
int main(int argc, char **argv) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointXYZ pt;
pt.x = 0.00; pt.y = 0.00; pt.z = 0; cloud->points.push_back(pt);
pt.x = 0.01; pt.y = 0.00; pt.z = 0; cloud->points.push_back(pt);
pt.x = 0.00; pt.y = 0.01; pt.z = 0; cloud->points.push_back(pt);
pt.x = -0.01; pt.y = 0.00; pt.z = 0; cloud->points.push_back(pt);
pt.x = 0.00; pt.y = -0.01; pt.z = 0; cloud->points.push_back(pt);
pt.x = 10.00; pt.y = 10.00; pt.z = 0; cloud->points.push_back(pt);
/**
* Main
*/
// Create the normal estimation class, and pass the input dataset to it
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
ne.setInputCloud(cloud);
// Create an empty kdtree representation, and pass it to the normal estimation object.
// Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());
ne.setSearchMethod(tree);
// Output datasets
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals(new pcl::PointCloud<pcl::Normal>);
// Use all neighbors in a sphere of radius 3cm
ne.setRadiusSearch(0.03);
ne.compute(*cloud_normals);
/** print */
for (auto const &pt: cloud_normals->points) {
std::cout << pt << std::endl;
}
return 0;
}