Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <pcl/pcl_config.h>
00038 #ifdef HAVE_OPENNI
00039
00040 #ifndef OPENNI_OPENNI_H_
00041 #define OPENNI_OPENNI_H_
00042 #include <string>
00043 #include <vector>
00044 #include <map>
00045 #include "openni_exception.h"
00046 #include "openni_device.h"
00047 #include <boost/shared_ptr.hpp>
00048 #include <boost/weak_ptr.hpp>
00049 #include <XnCppWrapper.h>
00050
00051 #include <pcl/pcl_macros.h>
00052
00053 namespace openni_wrapper
00054 {
00055
00056
00064 class PCL_EXPORTS OpenNIDriver
00065 {
00066 public:
00071 ~OpenNIDriver () throw ();
00072
00078 inline static OpenNIDriver& getInstance ();
00079
00085 unsigned updateDeviceList ();
00086
00091 inline unsigned getNumberDevices () const throw ();
00092
00101 boost::shared_ptr<OpenNIDevice> createVirtualDevice (const std::string& path, bool repeat, bool stream) const;
00102
00109 boost::shared_ptr<OpenNIDevice> getDeviceByIndex (unsigned index) const;
00110
00117 boost::shared_ptr<OpenNIDevice> getDeviceBySerialNumber (const std::string& serial_number) const;
00118
00119 #ifndef _WIN32
00120
00127 boost::shared_ptr<OpenNIDevice> getDeviceByAddress (unsigned char bus, unsigned char address) const;
00128 #endif
00129
00136 const char* getSerialNumber (unsigned index) const throw ();
00137
00144 const char* getConnectionString (unsigned index) const throw ();
00145
00152 const char* getVendorName (unsigned index) const throw ();
00153
00160 const char* getProductName (unsigned index) const throw ();
00161
00168 unsigned short getVendorID (unsigned index) const throw ();
00169
00176 unsigned short getProductID (unsigned index) const throw ();
00177
00184 unsigned char getBus (unsigned index) const throw ();
00185
00192 unsigned char getAddress (unsigned index) const throw ();
00193
00198 void stopAll ();
00199
00207 static void
00208 getDeviceType (const std::string& connection_string, unsigned short& vendorId, unsigned short& productId);
00209 protected:
00210
00211 struct PCL_EXPORTS DeviceContext
00212 {
00213 DeviceContext (const xn::NodeInfo& device_node, xn::NodeInfo* image_node, xn::NodeInfo* depth_node, xn::NodeInfo * ir_node);
00214 DeviceContext (const xn::NodeInfo & device_node);
00215 DeviceContext (const DeviceContext&);
00216 xn::NodeInfo device_node;
00217 boost::shared_ptr<xn::NodeInfo> image_node;
00218 boost::shared_ptr<xn::NodeInfo> depth_node;
00219 boost::shared_ptr<xn::NodeInfo> ir_node;
00220 boost::weak_ptr<OpenNIDevice> device;
00221 } ;
00222
00223 OpenNIDriver ();
00224 boost::shared_ptr<OpenNIDevice> getDevice (unsigned index) const;
00225
00226 #ifndef _WIN32
00227
00228 void getDeviceInfos () throw ();
00229 #endif
00230
00231 mutable std::vector<DeviceContext> device_context_;
00232 mutable xn::Context context_;
00233
00234 std::map< unsigned char, std::map<unsigned char, unsigned > > bus_map_;
00235 std::map< std::string, unsigned > serial_map_;
00236 std::map< std::string, unsigned > connection_string_map_;
00237 } ;
00238
00239 OpenNIDriver&
00240 OpenNIDriver::getInstance ()
00241 {
00242 static OpenNIDriver driver;
00243 return driver;
00244 }
00245
00246 unsigned
00247 OpenNIDriver::getNumberDevices () const throw ()
00248 {
00249 return static_cast<unsigned> (device_context_.size ());
00250 }
00251 }
00252 #endif
00253 #endif