00001 #include <pcl/visualization/cloud_viewer.h> 00002 #include <iostream> 00003 #include <pcl/io/io.h> 00004 #include <pcl/io/pcd_io.h> 00005 #include <pcl/features/integral_image_normal.h> 00006 00007 int 00008 main () 00009 { 00010 // load point cloud 00011 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); 00012 pcl::io::loadPCDFile ("table_scene_mug_stereo_textured.pcd", *cloud); 00013 00014 // estimate normals 00015 pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>); 00016 00017 pcl::IntegralImageNormalEstimation<pcl::PointXYZ, pcl::Normal> ne; 00018 ne.setNormalEstimationMethod (ne.AVERAGE_3D_GRADIENT); 00019 ne.setMaxDepthChangeFactor(0.02f); 00020 ne.setNormalSmoothingSize(10.0f); 00021 ne.setInputCloud(cloud); 00022 ne.compute(*normals); 00023 00024 // visualize normals 00025 pcl::visualization::PCLVisualizer viewer("PCL Viewer"); 00026 viewer.setBackgroundColor (0.0, 0.0, 0.5); 00027 viewer.addPointCloudNormals<pcl::PointXYZ,pcl::Normal>(cloud, normals); 00028 00029 while (!viewer.wasStopped ()) 00030 { 00031 viewer.spinOnce (); 00032 } 00033 return 0; 00034 }