使用PCL的Cloud Point可视化流 [英] Stream of Cloud Point Visualization using PCL
问题描述
我对RGB和深度数据进行一些处理,并构造要可视化的云点,我目前使用PCL Visualizer,它工作正常。
我想让可视化工具在不同的线程(实时,所以它将重绘全局云点,我尝试boost线程,但我得到一个运行时错误VTK坏查找表
I am doing some processing on RGB and Depth data and constructing cloud points that are to be visualized, I currently use PCL Visualizer and it works fine. I want to have the visualizer in a different thread (real time so it will redraw the global cloud point, I tried boost threads but I get a runtime error "VTK bad lookup table"
任何人都知道如何在不同的线程中可视化云点流。
Anyone knows how to visualize stream of cloud points in a different thread ?
推荐答案
它现在工作,也许我以前做错了,这里是如何使用boost线程和mutex
OK, I got it to work now, maybe I did something wrong before, here is how I did it using boost threads and mutex
bool update;
boost::mutex updateModelMutex;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
void visualize()
{
// prepare visualizer named "viewer"
while (!viewer->wasStopped ())
{
viewer->spinOnce (100);
// Get lock on the boolean update and check if cloud was updated
boost::mutex::scoped_lock updateLock(updateModelMutex);
if(update)
{
if(!viewer->updatePointCloud(cloud, "sample cloud"))
viewer->addPointCloud(cloud, colorHandler, "sample cloud");
update = false;
}
updateLock.unlock();
}
}
int main()
{
//Start visualizer thread
boost::thread workerThread(visualize);
while(notFinishedProcessing)
{
boost::mutex::scoped_lock updateLock(updateModelMutex);
update = true;
// do processing on cloud
updateLock.unlock();
}
workerThread.join();
}
UPDATE:
根据此页面,原因是将空点云添加到可视化引起事情变得疯狂所以我编辑上面的代码
According to this page The reason is that adding an empty point cloud to the visualizer causes things to go crazy so I edited the code above
这篇关于使用PCL的Cloud Point可视化流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!