使用 PCL 的浊点可视化流

Stream of Cloud Point Visualization using PCL(使用 PCL 的浊点可视化流)
本文介绍了使用 PCL 的浊点可视化流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对 RGB 和深度数据进行一些处理并构建要可视化的云点,我目前使用 PCL Visualizer,它工作正常.我想将可视化器放在不同的线程中(实时,因此它会重绘全局云点,我尝试了 boost 线程,但出现运行时错误VTK bad lookup table"

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 线程和互斥锁的方法

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();  
    }

更新:

根据这个页面的原因是向可视化器添加一个空点云会导致事情变得疯狂,所以我编辑了上面的代码

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 的浊点可视化流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)