错误:
一般创建的点云数据都命名为cloud,因为我这里有两组点云数据,要区分一下,所以把点云数据命名为cloud1和cloud2,下面是cloud2的显示代码
viewer2->setRepresentationToWireframeForAllActors();
viewer2->addPointCloud(cloud2);
viewer2->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud2");
viewer2->spinOnce(1);
viewer2->removeAllPointClouds();
viewer2->removeAllShapes();
运行后的出错
[setPointCloudRenderingProperties] Could not find any PointCloud datasets with id <cloud2>!
原因:
addPointCloud()默认的点云数据标签是id=“cloud”,上面代码添加了点云数据cloud2,但没有将默认的cloud标签改为id=“cloud2”,所以找不到cloud2的点云数据
addPointCloud (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud,
const std::string &id = "cloud", int viewport = 0)
改正:
viewer2->setRepresentationToWireframeForAllActors();
viewer2->addPointCloud(cloud2,"cloud2");
viewer2->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud2");
viewer2->spinOnce(1);
viewer2->removeAllPointClouds();
viewer2->removeAllShapes();