I am trying to visualize pointclouds on my qt widget.Following is a snippet of my code.This code can display the point clouds from a .pcd file. I am looking to visualize real time point clouds on qt
void MainWindow::imageShowLIDAR()
{
//std::cout << "carico file" << std::endl;
std::cout << "imageshow lidar initiated" << std::endl;
cloud_pcl.reset (new PointCloudT);
cloud_pcl->resize (200);
red = 128;
green = 128;
blue = 128;
pcl::io::loadPCDFile("/home/pcl1.pcd", *cloud_pcl);
for (auto& point: *cloud_pcl)
{
//point.x = 1024 * rand () / (RAND_MAX + 1.0f);
//point.y = 1024 * rand () / (RAND_MAX + 1.0f);
//point.z = 1024 * rand () / (RAND_MAX + 1.0f);
point.r = red;
point.g = green;
point.b = blue;
}
viewer_pcl.reset(new pcl::visualization::PCLVisualizer("viewer_pcl", false));
//Set viewer settings
viewer_pcl->addCoordinateSystem(3.0, "coordinate");
viewer_pcl->setShowFPS(false);
viewer_pcl->setBackgroundColor(0.0, 0.0, 0.0, 0);
//viewer_pcl->setCameraPosition(0.0, 0.0, 30.0, 0.0, 1.0, 0.0, 0);
ui.LIDAR_Widget->SetRenderWindow(viewer_pcl->getRenderWindow());
viewer_pcl->setupInteractor(ui.LIDAR_Widget->GetInteractor(), ui.LIDAR_Widget->GetRenderWindow());
viewer_pcl->addPointCloud (cloud_pcl, "cloud");
viewer_pcl->resetCamera ();
ui.LIDAR_Widget->update();
}
I have succedded in displaying a .pcd file but i would like to stream real time pointclouds on my widgets. I am new to this and moving ahead very gradually. Will highly appreciate any sort of suggestions. Thank you.
So, your point cloud should be generated outside of the visualization function and then you can give a point cloud object as parameter to function to be shown. I am not familiar with pcl framework, but you can get a simple idea.
This function should take a point cloud object then visualize it. Now the stream part starts;