title: Segmentation fault in Point-cloud-library PCL visualizer
body: <p>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 <a href="http://blog.martinperis.com/2012/01/3d-reconstruction-with-opencv-and-point.html" rel="nofollow">blog</a>. 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.</p>
  
  <pre><code>//This function creates a PCL visualizer, sets the point cloud to view and returns a pointer
  boost::shared_ptr&lt;pcl::visualization::PCLVisualizer&gt; createVisualizer (pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::ConstPtr cloud)
  {
  boost::shared_ptr&lt;pcl::visualization::PCLVisualizer&gt; viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
  viewer-&gt;setBackgroundColor (0, 0, 0);
  pcl::visualization::PointCloudColorHandlerRGBField&lt;pcl::PointXYZRGB&gt; rgb(cloud);
  viewer-&gt;addPointCloud&lt;pcl::PointXYZRGB&gt; (cloud, rgb, "reconstruction");
  viewer-&gt;setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "reconstruction");
  viewer-&gt;addCoordinateSystem ( 1.0 );
  viewer-&gt;initCameraParameters ();
  return (viewer);
  }
  </code></pre>
  
  <p>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.</p>
  
  <pre><code> point_cloud_ptr-&gt;width = (int) point_cloud_ptr-&gt;points.size();
   point_cloud_ptr-&gt;height = 1;
  //Create visualizer // Two lines below is the function call
  boost::shared_ptr&lt;pcl::visualization::PCLVisualizer&gt; viewer;
  viewer = createVisualizer( point_cloud_ptr );
  //Main loop
  while ( !viewer-&gt;wasStopped())
  {
   viewer-&gt;spinOnce(100);
   boost::this_thread::sleep (boost::posix_time::microseconds (100000));
  }
  </code></pre>
  
  <p>Just for ref the pastebin link to full code is <a href="http://pastebin.com/X4jeQSWB" rel="nofollow">here</a></p>