PCLVisualizer Segmentation Fault Error

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

PCLVisualizer Segmentation Fault Error

sahandy
Hello,

I tried to follow the PCL/OpenNI Grabber tutorial with a little difference. I wanted to use PCLVisualizer instead of the CloudViewer. The reason is that I'm about to use it in another project and PCLVisualizer gives me more control over cloud visualization.

Here is the modified code snippet I'm using based on the tutorial:

class SimpleOpenNIViewer
 {
   public:
     SimpleOpenNIViewer () : viewer (new pcl::visualization::PCLVisualizer("PCL OpenNI Viewer")) {

       viewer->setBackgroundColor (0,0,0);
       viewer->addCoordinateSystem (1.0);
       viewer->initCameraParameters ();

       is_fist_cloud = true;
     }

     void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
     {
         if(is_fist_cloud)
         {
            viewer->addPointCloud<pcl::PointXYZRGBA>(cloud, "cloud1");
            viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud1");
            is_fist_cloud = false;
         }
         else
         {
          std::cout << "UPDATE pointcloud" << std::endl;
          viewer->updatePointCloud<pcl::PointXYZRGBA>(cloud, "cloud1");
         }
     }

     void run ()
     {
       std::string file_path = "../2015-08-18_captured.oni";
         pcl::Grabber* interface = new pcl::io::OpenNI2Grabber(
         file_path,
         pcl::io::OpenNI2Grabber::OpenNI_Default_Mode,
         pcl::io::OpenNI2Grabber::OpenNI_Default_Mode);

       boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
         boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);

       interface->registerCallback (f);

       interface->start ();

       while (!viewer->wasStopped())
       {
         viewer->spinOnce(1);
         boost::this_thread::sleep (boost::posix_time::milliseconds (10));
       }

       interface->stop ();
     }

    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
    bool is_fist_cloud;
 };

Every time I run the code, after a couple of frames I encounter the Segmentation Fault error, which I wouldn't if I used CloudViewer. The frame number at which this happens is completely random.

I used gdb to trace it and it gave me this:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff69b5a1c in vtkPolyData::ComputeBounds() ()
   from /usr/lib/libvtkFiltering.so.5.8

Is there any problem with my implementation? I checked out the forum and one suggested that changing OpenCV and Boost to earlier versions might help!
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer Segmentation Fault Error

VictorLamoine
Administrator
Hello,

The PCLVisualizer is not suited to visualize data streams; thus the OpenNI grabber won't work in a PCLVisualizer.

You have to use the CloudViewer if you want to display streaming data.

Bye
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer Segmentation Fault Error

sahandy
Hi,

Thank you for your answer. But is there a way that I can add different pointclouds to a CloudViewer?
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer Segmentation Fault Error

intoxica
In reply to this post by VictorLamoine
Hi Victor,

The pcl_openni2_viewer does use pclvisualizer for streaming data. So I tried
using the same source from pcl-trunk for my project but it gives me
segmentation fault at spinOnce() too. Any idea what I am missing here.

Thank you.



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer Segmentation Fault Error

sahandy
Hi intoxica,

Just to double check on something: Are you using c++11 or above? If yes,
please build your code in *Release* or *RelWithDebInfo* mode.

```
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

```



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer Segmentation Fault Error

somnath
In reply to this post by sahandy
I also witnessed similar kind of segmentation fault while using pcl
visualizer, well the problem was mainly due to VTK library which was not
properly compiled and therefore .dlls were not proper. I am not sure whether
you could just recompile your VTK library in the same version( either 32 or
64 bit, debug , release) and then link it against your code.  It may help
overcome your issue.



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users