C++ 点云库PCL visualizer中的分段错误

C++ 点云库PCL visualizer中的分段错误,c++,opencv,segmentation-fault,computer-vision,point-cloud-library,C++,Opencv,Segmentation Fault,Computer Vision,Point Cloud Library,我正在尝试从SGBM方法获得的视差图生成点云。我有RGB图像,视差图像,Q矩阵存储在一个XML文件中。我正在使用本文中给出的代码。当我使用提供的图像和Q矩阵执行从博客中获得的代码时,我得到了分割错误。我包括代码段,我觉得这是造成分段错误的原因 //This function creates a PCL visualizer, sets the point cloud to view and returns a pointer boost::shared_ptr<pcl::visualiza

我正在尝试从SGBM方法获得的视差图生成点云。我有RGB图像,视差图像,Q矩阵存储在一个XML文件中。我正在使用本文中给出的代码。当我使用提供的图像和Q矩阵执行从博客中获得的代码时,我得到了分割错误。我包括代码段,我觉得这是造成分段错误的原因

//This function creates a PCL visualizer, sets the point cloud to view and returns a pointer
boost::shared_ptr<pcl::visualization::PCLVisualizer> createVisualizer (pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud)
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);
viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgb, "reconstruction");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "reconstruction");
viewer->addCoordinateSystem ( 1.0 );
viewer->initCameraParameters ();
return (viewer);
}
//此函数创建PCL可视化工具,设置要查看的点云并返回指针
boost::SharedptrCreateVisualizer(pcl::PointCloud::ConstPtr cloud)
{
boost::shared_ptr查看器(新的pcl::visualization::PCLVisualizer(“3D查看器”);
查看器->setBackgroundColor(0,0,0);
pcl::visualization::PointCloudColorHandlerRGBField rgb(云);
查看器->添加点云(云,rgb,“重建”);
查看器->setPointCloudRenderingProperties(pcl::visualization::pcl_VISUALIZER_POINT_SIZE,3,“重建”);
查看器->添加协调系统(1.0);
查看器->initCameraParameters();
返回(查看器);
}
当我注释掉这个部分,并且在主程序中调用这个函数时,没有错误。下面给出了主函数中使用的函数调用

 point_cloud_ptr->width = (int) point_cloud_ptr->points.size();
 point_cloud_ptr->height = 1;
//Create visualizer // Two lines below is the function call
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
viewer = createVisualizer( point_cloud_ptr );
//Main loop
while ( !viewer->wasStopped())
{
 viewer->spinOnce(100);
 boost::this_thread::sleep (boost::posix_time::microseconds (100000));
}
point_cloud_ptr->width=(int)point_cloud_ptr->points.size();
点云->高度=1;
//创建可视化工具//下面两行是函数调用
boost::共享的ptr查看器;
查看器=createVisualizer(点云ptr);
//主回路
而(!viewer->wastopped())
{
查看器->旋转一次(100);
boost::this_线程::sleep(boost::posix_时间::微秒(100000));
}

仅供参考,指向完整代码的pastebin链接是

我发现了问题。这是OpenCV的版本。我回到了Opencv 2.4.9,它工作得很有魅力

现在我使用的是Ubuntu 14.04+OpenCV 2.4.9+最新版本的PCL

谢谢你的帮助。
谢谢。

在创建可视化工具之前,云中有多少元素?在可视化云之前删除无效点也很有用(请参阅)。删除NaN元素后,数字为223700。图像大小为480*640。SegFault仍然存在。您是否能够使用此查看器可视化简单的PCD文件?例如,从这里开始:编译时不使用qt