Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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 ?

like image 341
Khaled Avatar asked Jan 25 '12 13:01

Khaled


People also ask

What is PCL in image processing?

The Point Cloud Library (PCL) is an open-source library of algorithms for point cloud processing tasks and 3D geometry processing, such as occur in three-dimensional computer vision.

What is lidar PCL?

A point cloud is a set of data points in space that represent a 3D object or an environment. Generally, a point cloud is generated from depth sensors, such as Kinect and LIDAR. PCL (Point Cloud Library) is a large scale, open project for 2D/3D images and point-cloud processing.


1 Answers

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

like image 61
Khaled Avatar answered Nov 15 '22 21:11

Khaled