I tried the first example of wiriting a pcd file and it worked perfectly.
However, when I tried the code example for loading a file I get segmentation
fault: 11. The first model I tried was an obj file generated by a Google
Tango device, which was a full person scanned. After, I tried with a simple
box obj example and the segmentation fault didnt happen, but nothing was
shown on the visualizer.
The code is this one:
Re: Segmentation Faut: 11 when loading .obj and .pcd files
it seemed that the problem was regarding to cloud_viewer.h functions. I tried
another alternative using pcl_visualizer but some of the functions were also
causing segmentation fault. The following code worked to read and visualize
the obj file, but only as a point cloud data:
int main (int argc, char** argv)
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new
if (pcl::io::loadOBJFile<pcl::PointXYZ> ("kelson.obj", *cloud) == -1) //*
load the file
PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
std::cout << "Loaded "
<< cloud->width * cloud->height
<< " data points from test_pcd.pcd with the following fields: "
const std::string windowsName = "Simple Cloud Viewer";
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new
pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
// viewer->addCoordinateSystem (1.0); This line was also causing
segmentation fault on Mac OS Sierra