我正在尝试可视化pcl::PointNormal
点云中包含的法线。我尝试使用以下代码执行此操作:
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
,但它没有帮助。
答案 0 :(得分:1)
您的查看者可能缺少实际的点云数据。
尝试添加
viewer->addPointCloud<pcl::PointNormal>(cloud, "foo", 1);
在调用addpointcloudnormals之前