Point Cloud Visualizer update in a loop

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

Point Cloud Visualizer update in a loop

CansenJIANG
Hi all,

I have a problem on displaying the point cloud in a loop. I have some off-line  data sequence of Time-of-Flight 3d camera, and I'm using the PCL Visualizer to display my point cloud. However, I can visualize the point cloud by using the command:

        while(!viewer.wasStopped())
        {
            viewer.spinOnce();
        }
or
        viewer.spin()


to keep the viewer displayed. However, by doing that, I cannot update my point cloud without closing the current viewer. And I couldn't find any sample codes online, so could someone please give me some hints on how to manage this case?

Thank you very much and look forward to your reply!

Best regards,
Cansen
Reply | Threaded
Open this post in threaded view
|

Re: Point Cloud Visualizer update in a loop

VictorLamoine
Administrator
Hi,

I'm not sure I understood what you want; sorry if it's not what you are looking for:
http://www.pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber

This code updates a point cloud from the OpenNI grabber; so you have to replace the OpenNI grabber with something else:
#include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>

 class SimpleOpenNIViewer
 {
   public:
     SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}

     void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud)
     {
       if (!viewer.wasStopped())
         viewer.showCloud (cloud);
     }

     void run ()
     {
       pcl::Grabber* interface = new pcl::OpenNIGrabber();

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

       interface->registerCallback (f);

       interface->start ();

       while (!viewer.wasStopped())
       {
         boost::this_thread::sleep (boost::posix_time::seconds (1));
       }

       interface->stop ();
     }

     pcl::visualization::CloudViewer viewer;
 };

 int main ()
 {
   SimpleOpenNIViewer v;
   v.run ();
   return 0;
 }
Reply | Threaded
Open this post in threaded view
|

Re: Point Cloud Visualizer update in a loop

nizar sallem
In reply to this post by CansenJIANG
First, please try the 'r' key or 1-->5 keys before saying display didn't
work cause the cloud can be just out  of center so you can not see it.
Once this is eliminated, then you may need to put some locks to make
sure you get the cloud before displaying it or you can just put a sleep
instruction.

--
Nizar
On 27/03/2014 15:46, CansenJIANG wrote:

> Hi all,
>
> I have a problem on displaying the point cloud in a loop. I have some
> off-line  data sequence of Time-of-Flight 3d camera, and I'm using the PCL
> Visualizer to display my point cloud. However, I can visualize the point
> cloud by using the command:
>
> /        while(!viewer.wasStopped())
>          {
>              viewer.spinOnce();
>          }
> or
>          viewer.spin()/
>
> to keep the viewer displayed. However, by doing that, I cannot update my
> point cloud without closing the current viewer. And I couldn't find any
> sample codes online, so could someone please give me some hints on how to
> manage this case?
>
> Thank you very much and look forward to your reply!
>
> Best regards,
> Cansen
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Point-Cloud-Visualizer-update-in-a-loop-tp4033098.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

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

Re: Point Cloud Visualizer update in a loop

CansenJIANG
Hi Nizar,

Thanks for the reply, I found out the way to update the PCL viewer in a loop now. Just in case someone may also don't know how to use it.

sample code:
    /* Initialize the veiwer */
    pcl::visualization::PCLVisualizer viewer ("Point Cloud");

    while(!viewer.wasStopped())
    {
        for(int frameID=0;frameID<N;frameID++)
        {
           
            /* play with your data here. */
 
            viewer.spinOnce();
        }
    }
// Don't remember to delete the previous cloud before updating.

Thanks and regards,
Cansen
Reply | Threaded
Open this post in threaded view
|

Re: Point Cloud Visualizer update in a loop

nizar sallem
Not sure what N is but this is definitely not how it is meant to work :)
If you are happy with it then it is OK :)

--
Nizar
On 28/03/2014 00:50, CansenJIANG wrote:

> Hi Nizar,
>
> Thanks for the reply, I found out the way to update the PCL viewer in a loop
> now. Just in case someone may also don't know how to use it.
>
> sample code:
>      /* Initialize the veiwer */
>      pcl::visualization::PCLVisualizer viewer ("Point Cloud");
>
>      while(!viewer.wasStopped())
>      {
>          for(int frameID=0;frameID<N;frameID++)
>          {
>              
>              /* play with your data here. */
>  
>              viewer.spinOnce();
>          }
>      }
> // Don't remember to delete the previous cloud before updating.
>
> Thanks and regards,
> Cansen
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Point-Cloud-Visualizer-update-in-a-loop-tp4033098p4033120.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

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

Re: Point Cloud Visualizer update in a loop

swaroop.capricorn
This post has NOT been accepted by the mailing list yet.
Hi Nizar,

I have a data coming from TOF camera to be displayed as pointcloud. It is working. Now, I would like to update the cloud frequently to view a live pointcloud. I tried some ways but couldn't figure a right one.

Regards,
Jyothi
Reply | Threaded
Open this post in threaded view
|

Re: Point Cloud Visualizer update in a loop

armhmd
This post has NOT been accepted by the mailing list yet.
In reply to this post by CansenJIANG
Hi,
I am trying to do the same thing, did you ever could figure the solution?