简体   繁体   中英

Segmentation fault in Point-cloud-library PCL visualizer

I am trying to generate a point cloud from disparity map obtained from SGBM method. I have the RGB image, the disparity image, Q matrix stored in an XML file. 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. 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.

 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

I found out the problem. It was with the version of OpenCV. I went back to Opencv 2.4.9 and it worked like charm.

Now I'm using Ubuntu 14.04 + OpenCV 2.4.9 + Latest Version of PCL

Appreciate all the help. Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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