Stream of Cloud Point Visualization using PCL

后端 未结 1 971
抹茶落季
抹茶落季 2020-12-25 08:45

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 th

相关标签:
1条回答
  • 2020-12-25 09:35

    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

    0 讨论(0)
提交回复
热议问题