I just started to use the great point cloud library and wanted to display two point clouds within one viewer but each in a different colour.
When I use one point cloud object (pointer?!) it works just fine but if I want to add a second one, only the second one will be displayed in the viewer.
I'm using pcl version 1.6 and did it pretty much like in this tutorial.
Maybe you guys have a suggetion.
The relevant code snippet is below. Thanks in advance!!!
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer_two_clouds (new pcl::visualization::PCLVisualizer("3D Viewer"));
viewer_two_clouds->setBackgroundColor(0,0,0);
// cloud: green / cloud2: red
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZRGB> single_color1 (cloud, 0, 255, 0);
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZRGB> single_color2 (cloud2, 255, 0, 0);
//add both
viewer_two_clouds->addPointCloud<pcl::PointXYZRGB> (cloud, single_color1, "sample_cloud_1");
viewer_two_clouds->addPointCloud<pcl::PointXYZRGB> (cloud2, single_color2, "sample_cloud_2");
// set coordinateSystem and init camera
viewer_two_clouds->addCoordinateSystem(1.0);
viewer_two_clouds->initCameraParameters();
while(!viewer_two_clouds->wasStopped())
{
viewer_two_clouds->spinOnce();
boost::this_thread::sleep (boost::posix_time::microseconds(100000));
}
viewer_two_clouds->close();
PCD
? – Acrolith