【发布时间】:2019-01-21 10:45:02
【问题描述】:
我一直在尝试根据 PCL 网站上的this tutorial 使用 PCL Visualizer,并使用以下方法来可视化点云:
boost::shared_ptr<pcl::visualization::PCLVisualizer> createViewer (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud, std::string& viewerName)
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer (viewerName));
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, viewerName);
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, viewerName);
viewer->addCoordinateSystem (1.0);
viewer->initCameraParameters ();
return viewer;
}
void visualizePointCloud (pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
{
std::string viewerName = "3D Viewer: Cloud";
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
viewer = createViewer(cloud, viewerName);
while (!viewer->wasStopped())
{
viewer->spinOnce(100);
boost::this_thread::sleep (boost::posix_time::microseconds (100000));
}
}
一切都很好,但我似乎无法摆脱循环!
如果您通过单击“x”关闭查看器窗口,则没有任何反应,wasStopped() 仍然返回false,程序卡住了。
有人知道如何正确终止查看器,以便程序可以继续执行其余代码吗?我只是愚蠢吗? 提前谢谢了!
P.S.:我在 Mac OS 10.13.6 上使用 PCL 1.8.1(通过 Homebrew 安装)。
【问题讨论】:
标签: c++ visualization point-cloud-library