我正在研究PCL,当我按照教程时代码崩溃了。工作原理
PointCloud<PointXYZRGB>::Ptr pointCloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::visualization::CloudViewer viewer("Simple Cloud Viewer");
viewer.showCloud(pointCloud);
while (!viewer.wasStopped())
{
}
但这不起作用http://pointclouds.org/documentation/tutorials/pcl_visualizer.php我认为这可能是因为ConstPtr,但我不知道如何将Ptr更改为ConstPtr。
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
viewer = rgbVis(pointCloud);
while (!viewer->wasStopped())
{
viewer->spinOnce(100);
boost::this_thread::sleep(boost::posix_time::microseconds(100000));
}
使用下面的功能定义。
boost::shared_ptr<pcl::visualization::PCLVisualizer> rgbVis(pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud)
{
// --------------------------------------------
// -----Open 3D viewer and add point cloud-----
// --------------------------------------------
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
viewer->setBackgroundColor(0, 0, 0);
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);
viewer->addPointCloud<pcl::PointXYZRGB>(cloud, rgb, "sample cloud");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
viewer->addCoordinateSystem(1.0);
viewer->initCameraParameters();
return (viewer);
}
此行崩溃viewer->addPointCloud<pcl::PointXYZRGB>(cloud, rgb, "sample cloud");
&#34; acrt_first_block == header&#34;