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.h"
00046 #include "openni_exception.h"
00047 #include "openni_device.h"
00048 #include <pcl/io/boost.h>
00049 #include <pcl/pcl_macros.h>
00050
00051 namespace openni_wrapper
00052 {
00053
00054
00062 class PCL_EXPORTS OpenNIDriver
00063 {
00064 public:
00069 ~OpenNIDriver () throw ();
00070
00076 inline static OpenNIDriver& getInstance ();
00077
00083 unsigned updateDeviceList ();
00084
00089 inline unsigned getNumberDevices () const throw ();
00090
00099 boost::shared_ptr<OpenNIDevice> createVirtualDevice (const std::string& path, bool repeat, bool stream) const;
00100
00107 boost::shared_ptr<OpenNIDevice> getDeviceByIndex (unsigned index) const;
00108
00115 boost::shared_ptr<OpenNIDevice> getDeviceBySerialNumber (const std::string& serial_number) const;
00116
00117 #ifndef _WIN32
00118
00125 boost::shared_ptr<OpenNIDevice> getDeviceByAddress (unsigned char bus, unsigned char address) const;
00126 #endif
00127
00134 const char* getSerialNumber (unsigned index) const throw ();
00135
00142 const char* getConnectionString (unsigned index) const throw ();
00143
00150 const char* getVendorName (unsigned index) const throw ();
00151
00158 const char* getProductName (unsigned index) const throw ();
00159
00166 unsigned short getVendorID (unsigned index) const throw ();
00167
00174 unsigned short getProductID (unsigned index) const throw ();
00175
00182 unsigned char getBus (unsigned index) const throw ();
00183
00190 unsigned char getAddress (unsigned index) const throw ();
00191
00196 void stopAll ();
00197
00205 static void
00206 getDeviceType (const std::string& connection_string, unsigned short& vendorId, unsigned short& productId);
00207 protected:
00208
00209 struct PCL_EXPORTS DeviceContext
00210 {
00211 DeviceContext (const xn::NodeInfo& device_node, xn::NodeInfo* image_node, xn::NodeInfo* depth_node, xn::NodeInfo * ir_node);
00212 DeviceContext (const xn::NodeInfo & device_node);
00213 DeviceContext (const DeviceContext&);
00214 xn::NodeInfo device_node;
00215 boost::shared_ptr<xn::NodeInfo> image_node;
00216 boost::shared_ptr<xn::NodeInfo> depth_node;
00217 boost::shared_ptr<xn::NodeInfo> ir_node;
00218 boost::weak_ptr<OpenNIDevice> device;
00219 } ;
00220
00221 OpenNIDriver ();
00222 boost::shared_ptr<OpenNIDevice> getDevice (unsigned index) const;
00223
00224 #ifndef _WIN32
00225
00226 void getDeviceInfos () throw ();
00227 #endif
00228
00229 mutable std::vector<DeviceContext> device_context_;
00230 mutable xn::Context context_;
00231
00232 std::map< unsigned char, std::map<unsigned char, unsigned > > bus_map_;
00233 std::map< std::string, unsigned > serial_map_;
00234 std::map< std::string, unsigned > connection_string_map_;
00235 } ;
00236
00237 OpenNIDriver&
00238 OpenNIDriver::getInstance ()
00239 {
00240 static OpenNIDriver driver;
00241 return driver;
00242 }
00243
00244 unsigned
00245 OpenNIDriver::getNumberDevices () const throw ()
00246 {
00247 return static_cast<unsigned> (device_context_.size ());
00248 }
00249 }
00250 #endif
00251 #endif