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 
99  void setImageRegistrationMode(bool enabled) throw (OpenNI2Exception);
100  void setDepthColorSync(bool enabled) throw (OpenNI2Exception);
101 
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 
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 
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 */
openni2_wrapper::OpenNI2Device::stopColorStream
void stopColorStream()
Definition: openni2_device.cpp:316
openni2_wrapper::OpenNI2Device::stopAllStreams
void stopAllStreams()
Definition: openni2_device.cpp:298
openni2_wrapper::OpenNI2Device::getIRVideoMode
const OpenNI2VideoMode getIRVideoMode()
Definition: openni2_device.cpp:445
openni2_wrapper::OpenNI2Device::hasColorSensor
bool hasColorSensor() const
Definition: openni2_device.cpp:249
openni2_wrapper::OpenNI2Device::ir_video_stream_
boost::shared_ptr< openni::VideoStream > ir_video_stream_
Definition: openni2_device.h:151
openni2_wrapper::OpenNI2Device::getDepthVideoMode
const OpenNI2VideoMode getDepthVideoMode()
Definition: openni2_device.cpp:481
openni2_wrapper::OpenNI2Device::startIRStream
void startIRStream()
Definition: openni2_device.cpp:259
openni2_video_mode.h
boost::shared_ptr< openni::VideoStream >
openni2_wrapper::OpenNI2Device::stopDepthStream
void stopDepthStream()
Definition: openni2_device.cpp:327
openni2_wrapper::OpenNI2Device::~OpenNI2Device
virtual ~OpenNI2Device()
Definition: openni2_device.cpp:86
openni2_wrapper::OpenNI2Device::image_registration_activated_
bool image_registration_activated_
Definition: openni2_device.h:163
openni2_wrapper::OpenNI2Device::isImageRegistrationModeSupported
bool isImageRegistrationModeSupported() const
Definition: openni2_device.cpp:413
openni2_wrapper::OpenNI2Device::getAutoExposure
bool getAutoExposure() const
Definition: openni2_device.cpp:587
openni2_wrapper::OpenNI2Device::getSupportedColorVideoModes
const std::vector< OpenNI2VideoMode > & getSupportedColorVideoModes() const
Definition: openni2_device.cpp:381
openni2_wrapper::OpenNI2Device::color_video_started_
bool color_video_started_
Definition: openni2_device.h:160
openni2_wrapper::OpenNI2Device::startColorStream
void startColorStream()
Definition: openni2_device.cpp:273
openni2_wrapper::OpenNI2Device::isValid
bool isValid() const
Definition: openni2_device.cpp:131
openni2_wrapper::OpenNI2Device::ir_video_modes_
std::vector< OpenNI2VideoMode > ir_video_modes_
Definition: openni2_device.h:155
openni2_wrapper::OpenNI2Device::getUri
const std::string getUri() const
Definition: openni2_device.cpp:95
openni2_wrapper::OpenNI2Device::setDepthColorSync
void setDepthColorSync(bool enabled)
Definition: openni2_device.cpp:438
openni2_wrapper::OpenNI2Device::ir_video_started_
bool ir_video_started_
Definition: openni2_device.h:159
openni2_wrapper::OpenNI2Device::isDepthVideoModeSupported
bool isDepthVideoModeSupported(const OpenNI2VideoMode &video_mode) const
Definition: openni2_device.cpp:225
openni2_wrapper::OpenNI2Device::shutdown
void shutdown()
Definition: openni2_device.cpp:339
openni2_wrapper::OpenNI2Device::getName
const std::string getName() const
Definition: openni2_device.cpp:105
openni2_wrapper::OpenNI2Device::getAutoWhiteBalance
bool getAutoWhiteBalance() const
Definition: openni2_device.cpp:603
openni2_wrapper::OpenNI2Device::depth_video_stream_
boost::shared_ptr< openni::VideoStream > depth_video_stream_
Definition: openni2_device.h:153
openni2_wrapper::OpenNI2Device::isIRVideoModeSupported
bool isIRVideoModeSupported(const OpenNI2VideoMode &video_mode) const
Definition: openni2_device.cpp:189
openni2_wrapper::OpenNI2Device::ir_frame_listener
boost::shared_ptr< OpenNI2FrameListener > ir_frame_listener
Definition: openni2_device.h:147
openni2_wrapper::OpenNI2Device::getIRFocalLength
float getIRFocalLength(int output_y_resolution) const
Definition: openni2_device.cpp:136
openni2_wrapper::operator<<
std::ostream & operator<<(std::ostream &stream, const OpenNI2Device &device)
Definition: openni2_device.cpp:710
openni2_wrapper
Definition: openni2_convert.h:43
openni2_wrapper::OpenNI2Device::getSupportedIRVideoModes
const std::vector< OpenNI2VideoMode > & getSupportedIRVideoModes() const
Definition: openni2_device.cpp:365
openni2_wrapper::OpenNI2Device::setColorVideoMode
void setColorVideoMode(const OpenNI2VideoMode &video_mode)
Definition: openni2_device.cpp:512
openni2_wrapper::OpenNI2Device::color_frame_listener
boost::shared_ptr< OpenNI2FrameListener > color_frame_listener
Definition: openni2_device.h:148
openni2_wrapper::OpenNI2Device::setAutoWhiteBalance
void setAutoWhiteBalance(bool enable)
Definition: openni2_device.cpp:554
openni2_wrapper::OpenNI2Device::OpenNI2Device
OpenNI2Device(const std::string &device_URI)
Definition: openni2_device.cpp:51
openni2_wrapper::OpenNI2Device::setDepthFrameCallback
void setDepthFrameCallback(FrameCallbackFunction callback)
Definition: openni2_device.cpp:657
openni2_wrapper::OpenNI2Device::setUseDeviceTimer
void setUseDeviceTimer(bool enable)
Definition: openni2_device.cpp:635
openni2_wrapper::OpenNI2Device::isColorVideoModeSupported
bool isColorVideoModeSupported(const OpenNI2VideoMode &video_mode) const
Definition: openni2_device.cpp:207
openni2_wrapper::OpenNI2Device::getDepthFocalLength
float getDepthFocalLength(int output_y_resolution) const
Definition: openni2_device.cpp:162
openni2_wrapper::OpenNI2Device::setExposure
void setExposure(int exposure)
Definition: openni2_device.cpp:571
openni2_wrapper::OpenNI2Device::getDepthVideoStream
boost::shared_ptr< openni::VideoStream > getDepthVideoStream() const
Definition: openni2_device.cpp:694
openni2_wrapper::OpenNI2Device::getColorFocalLength
float getColorFocalLength(int output_y_resolution) const
Definition: openni2_device.cpp:149
openni2_wrapper::OpenNI2Device::stopIRStream
void stopIRStream()
Definition: openni2_device.cpp:305
openni2_exception.h
openni2_wrapper::OpenNI2Device::isIRStreamStarted
bool isIRStreamStarted()
Definition: openni2_device.cpp:352
openni2_wrapper::OpenNI2Device::hasDepthSensor
bool hasDepthSensor() const
Definition: openni2_device.cpp:254
openni2_wrapper::OpenNI2Device::getVendor
const std::string getVendor() const
Definition: openni2_device.cpp:100
openni2_wrapper::OpenNI2Device::isDepthStreamStarted
bool isDepthStreamStarted()
Definition: openni2_device.cpp:360
openni2_wrapper::OpenNI2Device::color_video_stream_
boost::shared_ptr< openni::VideoStream > color_video_stream_
Definition: openni2_device.h:152
openni2_wrapper::OpenNI2Device::setImageRegistrationMode
void setImageRegistrationMode(bool enabled)
Definition: openni2_device.cpp:418
openni
Definition: openni2_device.h:49
openni2_wrapper::OpenNI2Device::color_video_modes_
std::vector< OpenNI2VideoMode > color_video_modes_
Definition: openni2_device.h:156
openni2_wrapper::OpenNI2Device::getExposure
int getExposure() const
Definition: openni2_device.cpp:619
openni2_wrapper::OpenNI2Device::setDepthVideoMode
void setDepthVideoMode(const OpenNI2VideoMode &video_mode)
Definition: openni2_device.cpp:525
openni2_wrapper::OpenNI2Device::setIRVideoMode
void setIRVideoMode(const OpenNI2VideoMode &video_mode)
Definition: openni2_device.cpp:499
openni2_wrapper::OpenNI2Device::getUsbProductId
uint16_t getUsbProductId() const
Definition: openni2_device.cpp:115
openni2_wrapper::OpenNI2Device::setAutoExposure
void setAutoExposure(bool enable)
Definition: openni2_device.cpp:538
openni2_wrapper::FrameCallbackFunction
boost::function< void(sensor_msgs::ImagePtr image)> FrameCallbackFunction
Definition: openni2_device.h:60
openni2_wrapper::OpenNI2Device::setColorFrameCallback
void setColorFrameCallback(FrameCallbackFunction callback)
Definition: openni2_device.cpp:652
openni2_wrapper::OpenNI2Device::getColorVideoMode
const OpenNI2VideoMode getColorVideoMode()
Definition: openni2_device.cpp:463
openni2_wrapper::OpenNI2FrameListener
Definition: openni2_frame_listener.h:48
openni2_wrapper::OpenNI2Device::getColorVideoStream
boost::shared_ptr< openni::VideoStream > getColorVideoStream() const
Definition: openni2_device.cpp:678
openni2_wrapper::OpenNI2Device::getIRVideoStream
boost::shared_ptr< openni::VideoStream > getIRVideoStream() const
Definition: openni2_device.cpp:662
openni2_wrapper::OpenNI2Device::getUsbVendorId
uint16_t getUsbVendorId() const
Definition: openni2_device.cpp:110
openni2_wrapper::OpenNI2Device::getBaseline
float getBaseline() const
Definition: openni2_device.cpp:175
openni2_wrapper::OpenNI2VideoMode
Definition: openni2_video_mode.h:58
openni2_wrapper::OpenNI2Device::openni_device_
boost::shared_ptr< openni::Device > openni_device_
Definition: openni2_device.h:144
openni2_wrapper::OpenNI2Device::getStringID
const std::string getStringID() const
Definition: openni2_device.cpp:120
openni2_wrapper::OpenNI2Exception
General exception class.
Definition: openni2_exception.h:57
openni2_wrapper::OpenNI2Device::hasIRSensor
bool hasIRSensor() const
Definition: openni2_device.cpp:244
openni2_wrapper::OpenNI2Device::setIRFrameCallback
void setIRFrameCallback(FrameCallbackFunction callback)
Definition: openni2_device.cpp:647
openni2_wrapper::OpenNI2Device::use_device_time_
bool use_device_time_
Definition: openni2_device.h:165
openni2_wrapper::OpenNI2Device::depth_video_modes_
std::vector< OpenNI2VideoMode > depth_video_modes_
Definition: openni2_device.h:157
openni2_wrapper::OpenNI2Device
Definition: openni2_device.h:64
openni2_wrapper::OpenNI2Device::getSupportedDepthVideoModes
const std::vector< OpenNI2VideoMode > & getSupportedDepthVideoModes() const
Definition: openni2_device.cpp:397
openni2_wrapper::OpenNI2Device::depth_video_started_
bool depth_video_started_
Definition: openni2_device.h:161
openni2_wrapper::OpenNI2Device::depth_frame_listener
boost::shared_ptr< OpenNI2FrameListener > depth_frame_listener
Definition: openni2_device.h:149
openni2_wrapper::OpenNI2Device::isColorStreamStarted
bool isColorStreamStarted()
Definition: openni2_device.cpp:356
openni2_wrapper::OpenNI2Device::device_info_
boost::shared_ptr< openni::DeviceInfo > device_info_
Definition: openni2_device.h:145
openni2_wrapper::OpenNI2Device::startDepthStream
void startDepthStream()
Definition: openni2_device.cpp:285


openni2_camera
Author(s): Julius Kammerl
autogenerated on Thu Oct 26 2023 02:33:32