openni_driver.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011 Willow Garage, Inc.
5  * Suat Gedikli <gedikli@willowgarage.com>
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef OPENNI_OPENNI_H_
39 #define OPENNI_OPENNI_H_
40 #include <string>
41 #include <vector>
42 #include <map>
43 #include "openni_exception.h"
44 #include "openni_device.h"
45 #include <boost/shared_ptr.hpp>
46 #include <boost/weak_ptr.hpp>
47 #include <XnCppWrapper.h>
48 
49 namespace openni_wrapper
50 {
51 //class OpenNIDevice;
59 {
60 public:
61  ~OpenNIDriver () throw ();
62 
63  inline static OpenNIDriver& getInstance () throw (OpenNIException);
64  unsigned updateDeviceList () throw ();
65  inline unsigned getNumberDevices () const throw ();
66 
67  boost::shared_ptr<OpenNIDevice> createVirtualDevice (const std::string& path, bool repeat, bool stream) const throw (OpenNIException);
69 #ifndef _WIN32
70  boost::shared_ptr<OpenNIDevice> getDeviceBySerialNumber (const std::string& serial_number) const throw (OpenNIException);
71  boost::shared_ptr<OpenNIDevice> getDeviceByAddress (unsigned char bus, unsigned char address) const throw (OpenNIException);
72 #endif
73 
74  const char* getSerialNumber (unsigned index) const throw ();
76  const char* getConnectionString (unsigned index) const throw ();
77 
78  const char* getVendorName (unsigned index) const throw ();
79  const char* getProductName (unsigned index) const throw ();
80  unsigned short getVendorID (unsigned index) const throw ();
81  unsigned short getProductID (unsigned index) const throw ();
82  unsigned char getBus (unsigned index) const throw ();
83  unsigned char getAddress (unsigned index) const throw ();
84 
85  void getPrimesenseSerial(xn::NodeInfo info, char* buffer, unsigned buf_size) const throw ();
86 
87  void stopAll () throw (OpenNIException);
88 
89  static void getDeviceType (const std::string& connection_string, unsigned short& vendorId, unsigned short& productId);
90 protected:
92  {
93  DeviceContext (const xn::NodeInfo& device_node, xn::NodeInfo* image_node, xn::NodeInfo* depth_node, xn::NodeInfo* ir_node);
94  DeviceContext (const xn::NodeInfo& device_node);
96  xn::NodeInfo device_node;
100  boost::weak_ptr<OpenNIDevice> device;
101  };
102 
103  OpenNIDriver () throw (OpenNIException);
104  boost::shared_ptr<OpenNIDevice> getDevice (unsigned index) const throw (OpenNIException);
105 
106 #ifndef _WIN32
107  // workaround to get additional device nformation like serial number, vendor and product name, until Primesense fix this
108  void getDeviceInfos () throw ();
109 #endif
110 
111  mutable std::vector<DeviceContext> device_context_;
112  mutable xn::Context context_;
113 
114  std::map< unsigned char, std::map<unsigned char, unsigned > > bus_map_;
115  std::map< std::string, unsigned > serial_map_;
116  std::map< std::string, unsigned > connection_string_map_;
117 };
118 
119 OpenNIDriver& OpenNIDriver::getInstance () throw (OpenNIException)
120 {
121  static OpenNIDriver driver;
122  return driver;
123 }
124 
125 unsigned OpenNIDriver::getNumberDevices () const throw ()
126 {
127  return (unsigned)device_context_.size ();
128 }
129 } // namespace
130 #endif
unsigned char getBus(unsigned index) const
const char * getSerialNumber(unsigned index) const
std::map< std::string, unsigned > serial_map_
unsigned short getVendorID(unsigned index) const
std::vector< DeviceContext > device_context_
boost::shared_ptr< OpenNIDevice > createVirtualDevice(const std::string &path, bool repeat, bool stream) const
boost::weak_ptr< OpenNIDevice > device
const char * getProductName(unsigned index) const
const char * getVendorName(unsigned index) const
Driver class implemented as Singleton. This class contains the xn::Context object used by all devices...
Definition: openni_driver.h:58
boost::shared_ptr< xn::NodeInfo > image_node
Definition: openni_driver.h:97
boost::shared_ptr< OpenNIDevice > getDeviceBySerialNumber(const std::string &serial_number) const
General exception class.
static void getDeviceType(const std::string &connection_string, unsigned short &vendorId, unsigned short &productId)
boost::shared_ptr< OpenNIDevice > getDevice(unsigned index) const
unsigned getNumberDevices() const
unsigned short getProductID(unsigned index) const
boost::shared_ptr< xn::NodeInfo > ir_node
Definition: openni_driver.h:99
boost::shared_ptr< OpenNIDevice > getDeviceByAddress(unsigned char bus, unsigned char address) const
static OpenNIDriver & getInstance()
std::map< unsigned char, std::map< unsigned char, unsigned > > bus_map_
boost::shared_ptr< OpenNIDevice > getDeviceByIndex(unsigned index) const
const char * getConnectionString(unsigned index) const
returns the connectionstring for current device, which has following format vendorID/productID@BusID/...
Class representing an astract device for Primesense or MS Kinect devices.
Definition: openni_device.h:66
std::map< std::string, unsigned > connection_string_map_
void getPrimesenseSerial(xn::NodeInfo info, char *buffer, unsigned buf_size) const
boost::shared_ptr< xn::NodeInfo > depth_node
Definition: openni_driver.h:98
DeviceContext(const xn::NodeInfo &device_node, xn::NodeInfo *image_node, xn::NodeInfo *depth_node, xn::NodeInfo *ir_node)
unsigned char getAddress(unsigned index) const


openni_camera
Author(s): Patrick Mihelich, Suat Gedikli, Radu Bogdan Rusu
autogenerated on Wed Jun 5 2019 20:15:22