点云库PCL可视化工具中的分段故障

Segmentation fault in Point-cloud-library PCL visualizer

本文关键字:分段 故障 工具 可视化 PCL      更新时间:2023-10-16

我正试图从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);
}

当我注释掉这个部分并且在主程序中调用这个函数时,没有错误。下面给出了主函数中使用的函数调用。

 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));
}

只是为了参考,粘贴到完整代码的链接在这里

我发现了这个问题。这是与OpenCV版本有关的。我回到Opencv2.4.9,它就像魅力一样发挥作用。

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

感谢所有的帮助。非常感谢。