Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to visualize "XYZL" point cloud?

I have a "XYZL" point cloud like this:

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

and I want to visulize it. It is not visualizable by commands that visualize "XYZ" or "XYZRGB" point clouds.

Now, I am wondering how can I visualize this type of point cloud?

like image 421
Taraneh Avatar asked Oct 17 '22 07:10

Taraneh


1 Answers

A PointXYZL could be visualized as a PointXYZI cloud. Just convert between the two, and then

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();
}
like image 96
brad Avatar answered Oct 21 '22 05:10

brad