简体   繁体   中英

PCL: How can I update the normals's cloud in pcl::visualizer?

I have a thread that visualize a pointcloud while I'm working on it. I need to visualize also the normals, how can I update them?

I cannot find anything like updateClouds for normal clouds.

void pclVisualizerThread::operator()()
{
    // 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_.get()));
        if((*update_))
        {
            // I NEED ALSO TO UPDATE THE NORMALS
            if(!viewer_->updatePointCloud(cloud_, "Triangulated points"))
            {
                viewer_->addPointCloud<pcl::PointXYZRGB>(cloud_, *rgb_, "Triangulated points");
                viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "Triangulated points");
            }

            (*update_) = false;
        }
        updateLock.unlock();

    }   
} 

Thanks in advance.

A way to do that is to remove the normal's cloud and to add it again:

void pclVisualizerThread::operator()()
{
    // 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_.get()));
        if((*update_))
        {
            if(!viewer_->updatePointCloud(cloud_, "Triangulated points"))
            {
                viewer_->addPointCloud<pcl::PointXYZRGB>(cloud_, *rgb_, "Triangulated points");
                viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "Triangulated points");
            }
            viewer_->removePointCloud("normals", 0);
            viewer_->addPointCloudNormals<pcl::PointXYZRGB, pcl::Normal> (cloud_, normals_, 150, 0.35, "normals");
            (*update_) = false;
        }
        updateLock.unlock();

    }   
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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