显示点云的方法有两种,不过本人更倾向第一种,
理由是:
1、第一个方法中的点云支持鼠标滚动放大对点云的显示
2、方法二种的显示效果见图2,想放大看细节看不了
方法一
//可视化窗口
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer
(new pcl::visualization::PCLVisualizer("MaxCurvature"));
viewer->addCoordinateSystem(0.2); // 读取的点云单位是什么,这个单位就是什么
viewer->setBackgroundColor(0.2, 0.2, 0.2);
viewer->addPointCloud<pcl::PointXYZ>(cloud, "cloud");
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> color(cloud_MaxCurvature, 255, 0, 0);
viewer->addPointCloud<pcl::PointXYZ>(cloud_MaxCurvature, color, "cloud_MaxCurvature");
//将得到的结果保存出来
pcl::io::savePCDFileASCII("qulv.pcd", *cloud_MaxCurvature);
//窗口中添加文字
//viewer->addText("table", 180, 180);
viewer->spin();
方法一显示的点云
方法二
pcl::visualization::PCLVisualizer viewer("PCLVisualizer");
viewer.initCameraParameters();
viewer.setBackgroundColor(8.0 / 255.0, 79.0 / 255.0, 117.0 / 255.0);
viewer.addPointCloud<pcl::PointXYZ>(cloud, "cloud");
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> color(cloud_MaxCurvature, 255, 0, 0);
viewer.addPointCloud<pcl::PointXYZ>(cloud_MaxCurvature, color, "cloud_MaxCurvature");
//将得到的结果保存出来
pcl::io::savePCDFileASCII("qulv.pcd", *cloud_MaxCurvature);
while (!viewer.wasStopped())
{
viewer.spinOnce(100);
boost::this_thread::sleep(boost::posix_time::microseconds(100000));
}
方法二显示的点云