00001 #ifndef OPENNI_CAPTURE_H 00002 #define OPENNI_CAPTURE_H 00003 00004 #include <pcl/io/openni_grabber.h> 00005 #include <pcl/visualization/pcl_visualizer.h> 00006 00007 namespace OpenNIFrameSource 00008 { 00009 00010 typedef pcl::PointXYZRGBA PointT; 00011 typedef pcl::PointCloud<PointT> PointCloud; 00012 typedef pcl::PointCloud<PointT>::Ptr PointCloudPtr; 00013 typedef pcl::PointCloud<PointT>::ConstPtr PointCloudConstPtr; 00014 00015 /* A simple class for capturing data from an OpenNI camera */ 00016 class PCL_EXPORTS OpenNIFrameSource 00017 { 00018 public: 00019 OpenNIFrameSource (const std::string& device_id = ""); 00020 ~OpenNIFrameSource (); 00021 00022 const PointCloudPtr 00023 snap (); 00024 bool 00025 isActive (); 00026 void 00027 onKeyboardEvent (const pcl::visualization::KeyboardEvent & event); 00028 00029 protected: 00030 void 00031 onNewFrame (const PointCloudConstPtr &cloud); 00032 00033 pcl::OpenNIGrabber grabber_; 00034 PointCloudPtr most_recent_frame_; 00035 int frame_counter_; 00036 boost::mutex mutex_; 00037 bool active_; 00038 }; 00039 00040 } 00041 00042 #endif