如何可视化“XYZL”点云?

时间:2017-08-21 14:24:38

标签: point-cloud-library point-clouds

我有一个像这样的“XYZL”点云:

pcl::PointCloud<pcl::PointXYZL>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZL>);

我想隐瞒它。通过可视化“XYZ”或“XYZRGB”点云的命令无法显示它。

现在,我想知道如何可视化这种类型的点云?

1 个答案:

答案 0 :(得分:2)

可以将PointXYZL可视化为PointXYZI云。只需在两者之间转换,然后

void displayCloud(pcl::PointCloud<pcl::PointXYZI>::Ptr cloud, const std::string& window_name)
{
    if (cloud->size() < 1)
    {
        std::cout << window_name << " display failure. Cloud contains no points\n";
        return;
    }

    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer(window_name));
    pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZI> point_cloud_color_handler(cloud, "intensity");

    viewer->addPointCloud< pcl::PointXYZI >(cloud, point_cloud_color_handler, "id");
    viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "id");

    viewer->registerKeyboardCallback(keyboardEventOccurred, (void*)viewer.get());

    while (!viewer->wasStopped() && !close_window){
        viewer->spinOnce(50);
    }
    close_window = false;
    viewer->close();
}