简体   繁体   English

使用PCL的Cloud Point可视化流

[英]Stream of Cloud Point Visualization using PCL

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. 我正在对RGB和深度数据进行一些处理并构建可视化的云点,我目前使用PCL Visualizer并且它工作正常。 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" 我希望将可视化工具放在不同的线程中(实时,因此它将重绘全局云点,我尝试了提升线程,但我得到了运行时错误“VTK坏查找表”

Anyone knows how to visualize stream of cloud points in a different thread ? 任何人都知道如何在不同的线程中可视化云点流?

OK, I got it to work now, maybe I did something wrong before, here is how I did it using boost threads and mutex 好吧,我现在就开始工作了,也许我之前做错了,这就是我使用boost thread和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 根据这个页面 ,原因是向可视化器添加一个空点云会导致事情变得疯狂,所以我编辑了上面的代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM