简体   繁体   English

Point-cloud-library PCL可视化器中的分段错误

[英]Segmentation fault in Point-cloud-library PCL visualizer

I am trying to generate a point cloud from disparity map obtained from SGBM method. 我试图从SGBM方法获得的视差图生成点云。 I have the RGB image, the disparity image, Q matrix stored in an XML file. 我有RGB图像,视差图像,Q矩阵存储在XML文件中。 I am using the code given in this blog . 我正在使用此博客中给出的代码。 When I execute the code obtained from the blog with the supplied images and Q matrix I am getting segmentation fault. 当我使用提供的图像和Q矩阵执行从博客获得的代码时,我得到分段错误。 I am including the code segment which I feel is causing the segmentation fault. 我包括我觉得导致分段错误的代码段。

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

When I comment out this section and the call to this function is made in the main program there is no error. 当我注释掉这一部分并且在主程序中调用此函数时,没有错误。 The function call used in the main function is given below. 下面给出了main函数中使用的函数调用。

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

Just for ref the pastebin link to full code is here 仅供参考, 这里是完整代码的pastebin链接

I found out the problem. 我发现了问题。 It was with the version of OpenCV. 这是OpenCV的版本。 I went back to Opencv 2.4.9 and it worked like charm. 我回到了Opencv 2.4.9,它就像魅力一样。

Now I'm using Ubuntu 14.04 + OpenCV 2.4.9 + Latest Version of PCL 现在我使用的是Ubuntu 14.04 + OpenCV 2.4.9 +最新版PCL

Appreciate all the help. 感谢所有的帮助。 Thank you. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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