00001 #ifndef OPENNI_CAPTURE_H 00002 #define OPENNI_CAPTURE_H 00003 00004 #include "typedefs.h" 00005 00006 #include <pcl/io/openni_grabber.h> 00007 #include <pcl/visualization/pcl_visualizer.h> 00008 00009 /* A simple class for capturing data from an OpenNI camera */ 00010 class OpenNICapture 00011 { 00012 public: 00013 OpenNICapture (const std::string& device_id = ""); 00014 ~OpenNICapture (); 00015 00016 void setTriggerMode (bool use_trigger); 00017 const PointCloudPtr snap (); 00018 const PointCloudPtr snapAndSave (const std::string & filename); 00019 00020 protected: 00021 void onNewFrame (const PointCloudConstPtr &cloud); 00022 void onKeyboardEvent (const pcl::visualization::KeyboardEvent & event); 00023 00024 void waitForTrigger (); 00025 00026 pcl::OpenNIGrabber grabber_; 00027 pcl::visualization::PCLVisualizer *preview_; 00028 int frame_counter_; 00029 PointCloudPtr most_recent_frame_; 00030 bool use_trigger_, trigger_; 00031 boost::mutex mutex_; 00032 }; 00033 00034 #endif