Advertisement
Guest User

Untitled

a guest
Feb 26th, 2012
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. #include <pcl/io/openni_grabber.h>
  2. #include <pcl/visualization/cloud_viewer.h>
  3. #include <pcl/io/pcd_io.h>
  4.  
  5. class SimpleOpenNIViewer
  6. {
  7. public:
  8.    SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}
  9.    
  10.    void cloud_cb_2_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
  11.    {
  12.       //do nothing...
  13.    }
  14.    
  15.    void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
  16.    {
  17.       //show cloud
  18.       if (!viewer.wasStopped())
  19.          viewer.showCloud (cloud);
  20.    }
  21.    
  22.    void run ()
  23.    {
  24.       //**********************************
  25.       //start first kinect
  26.       pcl::Grabber* interface = new pcl::OpenNIGrabber("#1");
  27.      
  28.       boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
  29.          boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);
  30.      
  31.       interface->registerCallback (f);
  32.       interface->start();
  33.       //**********************************
  34.  
  35.       //**********************************  
  36.       //start second kinect
  37.        pcl::Grabber* interface2 = new pcl::OpenNIGrabber("#2");  
  38.        boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f2 =
  39.          boost::bind (&SimpleOpenNIViewer::cloud_cb_2_, this, _1);
  40.        
  41.        interface2->registerCallback (f2);
  42.  
  43.        interface2->start();
  44.       //**********************************
  45.  
  46.  
  47.        while (!viewer.wasStopped())
  48.        {
  49.          sleep (1);
  50.        }
  51.  
  52.        interface->stop ();
  53.        interface2->stop ();
  54.      }
  55.  
  56.      pcl::visualization::CloudViewer viewer;
  57.  };
  58.  
  59.  int main ()
  60.  {
  61.    SimpleOpenNIViewer v;
  62.    v.run ();
  63.    return 0;
  64.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement