在PCL中可视化PointNormal点云的法线 [英] Visualise normals of PointNormal point cloud in PCL

查看:3204
本文介绍了在PCL中可视化PointNormal点云的法线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试可视化pcl::PointNormal点云中包含的法线.我尝试使用以下代码来做到这一点:

I am trying to visualize normals that are contained in a pcl::PointNormal point cloud. I try to do this with following code:

std::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
std::mutex viewerMutex;

void viewerThreadFunction() {
    while(true) {
        if(viewer->wasStopped()) break;
        viewerMutex.lock();
        viewer->spinOnce();
        viewerMutex.unlock();
    }
}

int main() {
    viewer = std::shared_ptr<pcl::visualization::PCLVisualizer>(
                    new pcl::visualization::PCLVisualizer("Viewer"));
    viewer->setBackgroundColor(0, 0, 0);

    pcl::PointCloud<pcl::PointNormal>::Ptr cloud(new pcl::PointCloud<pcl::PointNormal>);

    viewer->addPointCloudNormals<pcl::PointNormal, pcl::PointNormal> (cloud, cloud, 25, 0.15, "normals"); // It throws an exception here:

    std::thread viewerThread{viewerThreadFunction};

    while(true) {
        // populate the point cloud
        viewerMutex.lock();
        viewer->removePointCloud("normals");
        viewer->addPointCloudNormals<pcl::PointNormal, pcl::PointNormal> (cloud, cloud, 25, 0.15, "normals");
        viewerMutex.unlock();
    }
}

我得到一个例外:

terminate called after throwing an instance of 'std::bad_array_new_length'
    what(): std::bad_array_new_length
Aborted (core dumped)

我试图重写该程序,以便仅在填充的点云上调用viewer->addPointCloudNormals,但它没有帮助.

I tried to rewrite the program so, that viewer->addPointCloudNormals is called only on a populated point cloud, but it did not help.

推荐答案

您的查看器可能缺少实际的点云数据.

Your viewer might be missing the actual point cloud data.

尝试添加

viewer->addPointCloud<pcl::PointNormal>(cloud, "foo", 1);

在调用addpointcloudnormals之前

before calling addpointcloudnormals

这篇关于在PCL中可视化PointNormal点云的法线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆