openni2_device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Author: Julius Kammerl (jkammerl@willowgarage.com)
30  */
31 
32 #ifndef OPENNI2_DEVICE_H
33 #define OPENNI2_DEVICE_H
34 
36 
38 
39 #include <boost/shared_ptr.hpp>
40 #include <boost/cstdint.hpp>
41 #include <boost/bind.hpp>
42 #include <boost/function.hpp>
43 
44 #include <sensor_msgs/Image.h>
45 
46 #include <string>
47 #include <vector>
48 
49 namespace openni
50 {
51 class Device;
52 class DeviceInfo;
53 class VideoStream;
54 class SensorInfo;
55 }
56 
57 namespace openni2_wrapper
58 {
59 
60 typedef boost::function<void(sensor_msgs::ImagePtr image)> FrameCallbackFunction;
61 
63 
65 {
66 public:
67  OpenNI2Device(const std::string& device_URI) throw (OpenNI2Exception);
68  virtual ~OpenNI2Device();
69 
70  const std::string getUri() const;
71  const std::string getVendor() const;
72  const std::string getName() const;
73  uint16_t getUsbVendorId() const;
74  uint16_t getUsbProductId() const;
75 
76  const std::string getStringID() const;
77 
78  bool isValid() const;
79 
80  bool hasIRSensor() const;
81  bool hasColorSensor() const;
82  bool hasDepthSensor() const;
83 
84  void startIRStream();
85  void startColorStream();
86  void startDepthStream();
87 
88  void stopAllStreams();
89 
90  void stopIRStream();
91  void stopColorStream();
92  void stopDepthStream();
93 
94  bool isIRStreamStarted();
95  bool isColorStreamStarted();
96  bool isDepthStreamStarted();
97 
98  bool isImageRegistrationModeSupported() const;
99  void setImageRegistrationMode(bool enabled) throw (OpenNI2Exception);
100  void setDepthColorSync(bool enabled) throw (OpenNI2Exception);
101 
102  const OpenNI2VideoMode getIRVideoMode() throw (OpenNI2Exception);
103  const OpenNI2VideoMode getColorVideoMode() throw (OpenNI2Exception);
104  const OpenNI2VideoMode getDepthVideoMode() throw (OpenNI2Exception);
105 
106  const std::vector<OpenNI2VideoMode>& getSupportedIRVideoModes() const;
107  const std::vector<OpenNI2VideoMode>& getSupportedColorVideoModes() const;
108  const std::vector<OpenNI2VideoMode>& getSupportedDepthVideoModes() const;
109 
110  bool isIRVideoModeSupported(const OpenNI2VideoMode& video_mode) const;
111  bool isColorVideoModeSupported(const OpenNI2VideoMode& video_mode) const;
112  bool isDepthVideoModeSupported(const OpenNI2VideoMode& video_mode) const;
113 
114  void setIRVideoMode(const OpenNI2VideoMode& video_mode) throw (OpenNI2Exception);
115  void setColorVideoMode(const OpenNI2VideoMode& video_mode) throw (OpenNI2Exception);
116  void setDepthVideoMode(const OpenNI2VideoMode& video_mode) throw (OpenNI2Exception);
117 
118  void setIRFrameCallback(FrameCallbackFunction callback);
119  void setColorFrameCallback(FrameCallbackFunction callback);
120  void setDepthFrameCallback(FrameCallbackFunction callback);
121 
122  float getIRFocalLength (int output_y_resolution) const;
123  float getColorFocalLength (int output_y_resolution) const;
124  float getDepthFocalLength (int output_y_resolution) const;
125  float getBaseline () const;
126 
127  void setAutoExposure(bool enable) throw (OpenNI2Exception);
128  void setAutoWhiteBalance(bool enable) throw (OpenNI2Exception);
129  void setExposure(int exposure) throw (OpenNI2Exception);
130 
131  bool getAutoExposure() const;
132  bool getAutoWhiteBalance() const;
133  int getExposure() const;
134 
135  void setUseDeviceTimer(bool enable);
136 
137 protected:
138  void shutdown();
139 
140  boost::shared_ptr<openni::VideoStream> getIRVideoStream() const throw (OpenNI2Exception);
141  boost::shared_ptr<openni::VideoStream> getColorVideoStream() const throw (OpenNI2Exception);
142  boost::shared_ptr<openni::VideoStream> getDepthVideoStream() const throw (OpenNI2Exception);
143 
146 
150 
154 
155  mutable std::vector<OpenNI2VideoMode> ir_video_modes_;
156  mutable std::vector<OpenNI2VideoMode> color_video_modes_;
157  mutable std::vector<OpenNI2VideoMode> depth_video_modes_;
158 
162 
164 
166 
167 };
168 
169 std::ostream& operator << (std::ostream& stream, const OpenNI2Device& device);
170 
171 }
172 
173 #endif /* OPENNI_DEVICE_H */
std::ostream & operator<<(std::ostream &stream, const OpenNI2Device &device)
boost::function< void(sensor_msgs::ImagePtr image)> FrameCallbackFunction
boost::shared_ptr< openni::VideoStream > depth_video_stream_
boost::shared_ptr< openni::VideoStream > color_video_stream_
std::vector< OpenNI2VideoMode > ir_video_modes_
std::string getName(void *handle)
std::vector< OpenNI2VideoMode > color_video_modes_
General exception class.
boost::shared_ptr< OpenNI2FrameListener > ir_frame_listener
boost::shared_ptr< OpenNI2FrameListener > color_frame_listener
boost::shared_ptr< OpenNI2FrameListener > depth_frame_listener
boost::shared_ptr< openni::Device > openni_device_
boost::shared_ptr< openni::VideoStream > ir_video_stream_
boost::shared_ptr< openni::DeviceInfo > device_info_
std::vector< OpenNI2VideoMode > depth_video_modes_


openni2_camera
Author(s): Julius Kammerl
autogenerated on Wed Feb 3 2021 03:18:41