Getting frame-by-frame pcl::PointXYZ from HDL Grabber

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

Getting frame-by-frame pcl::PointXYZ from HDL Grabber

whizzwr
Hey PCL people,

I have some success on creating a very basic viewer based on the oficial HDL
Grabber tutorial:
(http://pointclouds.org/documentation/tutorials/hdl_grabber.php)

Excuse me for a possible obvious/noob question:

*How do one get a frame-by-frame laser scan using HDL Grabber?*

If I understand correctly the sample on that link updates the Viewer canvas
by means of cloud callback.
So as long as the grabber is streaming a new data, then the viewer will get
updated:


      grabber_.start ();

      while (!cloud_viewer_->wasStopped ())
      {
        CloudConstPtr cloud;

        // See if we can get a cloud
        if (cloud_mutex_.try_lock ())
        {
          cloud_.swap (cloud);
          cloud_mutex_.unlock ();
        }

        if (cloud)
        {
          handler_.setInputCloud (cloud);
          if (!cloud_viewer_->updatePointCloud (cloud, handler_, "HDL"))
            cloud_viewer_->addPointCloud (cloud, handler_, "HDL");

          cloud_viewer_->spinOnce ();
        }

        if (!grabber_.isRunning ())
          cloud_viewer_->spin ();

        boost::this_thread::sleep (boost::posix_time::microseconds (100));
      }

      grabber_.stop ();

Meanwhile, I need to extract frame-by-frame data from a pcap file, so say I
want to access certain laser scan frame based on linear index. Just like the
VeloView software where you have the slider and input box of current frame
number (see below):
<http://www.pcl-users.org/file/t499335/veloview_slider.png>

Can anyone please give any pointer?
Do I have to implement some kind of timer and manually index the recording
based on some linear time difference?

Thanks in advance!

Whizz



--
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: Getting frame-by-frame pcl::PointXYZ from HDL Grabber

lab1440
NO you don't have to manually index it.. the HDL grabber index it you can
access the sequence index in the cloud->header->seq and the time stamp for
the current cloud in cloud->header->stamp



--
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: Getting frame-by-frame pcl::PointXYZ from HDL Grabber

whizzwr
Indeed the cloud->header->seq.id is the variable I need.
But why do I get a skipped frame sequence occasionally?

I think this is not isolated, someone else posted this:
http://www.pcl-users.org/HDL-Grabber-reg-td4046081.html



--
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: Getting frame-by-frame pcl::PointXYZ from HDL Grabber

Stephen McDowell
Does it still happen if you do nothing other than say display each cloud as it comes in?

If not my guess is that the skipped frames comes from your algorithm being too slow. Grabbers are typically receiving frames in their own dedicated thread, so if the device is sending frames faster than you process then you'll drop some.

For example, say the camera sends frames at 30FPS, and your algorithm takes 35FPS. Frame drops are pretty much guaranteed.

That may not be what's going on, but seems likely.

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

Re: Getting frame-by-frame pcl::PointXYZ from HDL Grabber

Stephen McDowell
Sorry, concept was correct but example backwards. If the grabber is sending at 30FPS and you process at say 25FPS you will drop frames...


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

Re: Getting frame-by-frame pcl::PointXYZ from HDL Grabber

lab1440
this happens even in pre recorded pcap files, where you access the data
ofline



--
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: Getting frame-by-frame pcl::PointXYZ from HDL Grabber

Stephen McDowell
it would still be helpful to know if it happens when you do something very fast such as simply displaying the point cloud.

in my own code that enables import sequences (not for PCL, for something else), I had to encode explicit logic for the device (hardware camera or importer) to not drop frames.  I don’t know the PCL grabber interface very well, so my suggestions could be completely off mark.  But given I went through a similar experience, it may be the threading logic.  for example, if there’s a hard-coded refresh rate that wakes to load a new frame.

basically, if users are able to identify a concrete circumstance in which things work (just displaying the cloud), a simple test case could go in and sleep the thread processing new clouds.  if this sleep results in dropped frames again, we’ve probably found the issue.  the solution may be non-trivial though.

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

Re: Getting frame-by-frame pcl::PointXYZ from HDL Grabber

lab1440
This post was updated on .
i checked with just displaying the clouds too.The same behviour can be
observed, but one doubt i have is where should i access the cloud for
processing it right now i access it in the viewer while loop which i have
mentioned below

 while( !viewer->wasStopped() ){
        // Update Viewer
        viewer->spinOnce();

        boost::mutex::scoped_try_lock lock( mutex );
        if( lock.owns_lock() && cloud ){
            // Update Point Cloud

should i access the cloud within viewer loop or should i access it here

 boost::function<void( const pcl::PointCloud&lt;PointType>::ConstPtr& )>
function =
        [ &cloud, &mutex ]( const pcl::PointCloud<PointType>::ConstPtr& ptr
){
            boost::mutex::scoped_lock lock( mutex );

            /* Point Cloud Processing */

            cloud = ptr;
        };

I am having doubt in this part only


_______________________________________________
PCL-users@ / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users





--
Sent from: http://www.pcl-users.org/
_______________________________________________
PCL-users@pointclouds.org / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users