我剛開始使用偉大的點雲庫,並希望在一個查看器中顯示兩個點雲,但每個都以不同的顏色顯示。將兩個不同的點雲添加到查看器(點雲庫(PCL))
當我使用一個點雲對象(指針?!)時,它工作得很好,但如果我想添加第二個,只有第二個會在查看器中顯示。
我正在使用pcl版本1.6,並且做得很像這個tutorial。
也許你們有一個暗示。
相關的代碼片段如下。提前致謝!!!
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'? –
我實際上只加載一個pcd,但是我將它複製並將它從其他點雲移動10米。 copyPointCloud(* cloud,* cloud2); /複製後我做cloud2-> sensor_origin_ = p; – GeoGecco
好的。然後,嘗試加載文件兩次,而不是複製。我不認爲這會解決它,但以防萬一...... –