Point Cloud Library (PCL) 1.13.0
openni_device.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2009-2011, Willow Garage, Inc.
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 the copyright holder(s) 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#pragma once
39
40#include <pcl/pcl_config.h>
41#include <pcl/memory.h>
42#ifdef HAVE_OPENNI
43
44#include "openni_exception.h"
45#include "openni.h"
46
47#include <pcl/io/openni_camera/openni_image.h>
48#include <pcl/io/openni_camera/openni_depth_image.h>
49#include <pcl/io/openni_camera/openni_ir_image.h>
50#include <pcl/pcl_macros.h>
51
52#include <condition_variable>
53#include <functional>
54#include <map>
55#include <mutex>
56#include <thread>
57#include <vector>
58
59/// @todo Get rid of all exception-specifications, these are useless and soon to be deprecated
60
61#ifndef _WIN32
62#define __stdcall
63#endif
64
65namespace openni_wrapper
66{
67 /** \brief Class representing an astract device for OpenNI devices: Primesense PSDK, Microsoft Kinect, Asus Xtion Pro/Live.
68 * \author Suat Gedikli
69 * \ingroup io
70 */
72 {
73 public:
75 {
76 OpenNI_shift_values = 0, // Shift values (disparity)
77 OpenNI_12_bit_depth = 1, // Default mode: regular 12-bit depth
78 };
79
80 using Ptr = pcl::shared_ptr<OpenNIDevice>;
81 using ConstPtr = pcl::shared_ptr<const OpenNIDevice>;
82
83 using ImageCallbackFunction = std::function<void(Image::Ptr, void* cookie) >;
84 using DepthImageCallbackFunction = std::function<void(DepthImage::Ptr, void* cookie) >;
85 using IRImageCallbackFunction = std::function<void(IRImage::Ptr, void* cookie) >;
86 using CallbackHandle = unsigned;
87
88 public:
89
90 /** \brief virtual destructor. Never throws an exception. */
91 virtual ~OpenNIDevice () noexcept;
92
93 /** \brief finds an image output mode that can be used to retrieve images in desired output mode.
94 * e.g If device just supports VGA at 30Hz, then the desired mode QVGA at 30Hz would be possible by down sampling,
95 * but the modes VGA at 25Hz and SXGA at 30Hz would not be compatible.
96 * \param[in] output_mode the desired output mode
97 * \param[out] mode the compatible mode that the device natively supports.
98 * \return true, if a compatible mode could be found, false otherwise.
99 */
100 bool
101 findCompatibleImageMode (const XnMapOutputMode& output_mode, XnMapOutputMode& mode ) const throw ();
102
103 /** \brief finds a depth output mode that can be used to retrieve depth images in desired output mode.
104 * e.g If device just supports VGA at 30Hz, then a desired mode of QVGA at 30Hz would be possbile by downsampling,
105 * but the modes VGA at 25Hz and SXGA at 30Hz would not be compatible.
106 * \param[in] output_mode the desired output mode
107 * \param[out] mode the compatible mode that the device natively supports.
108 * \return true, if a compatible mode could be found, false otherwise.
109 */
110 bool
111 findCompatibleDepthMode (const XnMapOutputMode& output_mode, XnMapOutputMode& mode ) const throw ();
112
113 /** \brief returns whether a given mode is natively supported by the device or not
114 * \param[in] output_mode mode to be checked
115 * \return true if mode natively available, false otherwise
116 */
117 bool
118 isImageModeSupported (const XnMapOutputMode& output_mode) const throw ();
119
120 /** \brief returns whether a given mode is natively supported by the device or not
121 * \param[in] output_mode mode to be checked
122 * \return true if mode natively available, false otherwise
123 */
124 bool
125 isDepthModeSupported (const XnMapOutputMode& output_mode) const throw ();
126
127 /** \brief returns the default image mode, which is simply the first entry in the list of modes
128 * \return the default image mode
129 */
130 const XnMapOutputMode&
131 getDefaultImageMode () const throw ();
132
133 /** \brief returns the default depth mode, which is simply the first entry in the list of modes
134 * \return the default depth mode
135 */
136 const XnMapOutputMode&
137 getDefaultDepthMode () const throw ();
138
139 /** \brief returns the default IR mode, which is simply the first entry in the list of modes
140 * \return the default IR mode
141 */
142 const XnMapOutputMode&
143 getDefaultIRMode () const throw ();
144
145 /** \brief sets the output mode of the image stream
146 * \param[in] output_mode the desired output mode
147 */
148 void
149 setImageOutputMode (const XnMapOutputMode& output_mode);
150
151 /** \brief sets the output mode of the depth stream
152 * \param[in] output_mode the desired output mode
153 */
154 void
155 setDepthOutputMode (const XnMapOutputMode& output_mode);
156
157 /** \brief sets the output mode of the IR stream
158 * \param[in] output_mode the desired output mode
159 */
160 void
161 setIROutputMode (const XnMapOutputMode& output_mode);
162
163 /** \return the current output mode of the image stream */
164 XnMapOutputMode
165 getImageOutputMode () const;
166
167 /** \return the current output mode of the depth stream */
168 XnMapOutputMode
169 getDepthOutputMode () const;
170
171 /** \return the current output mode of the IR stream */
172 XnMapOutputMode
173 getIROutputMode () const;
174
175 /** \brief set the depth stream registration on or off
176 * \param[in] on_off
177 */
178 void
179 setDepthRegistration (bool on_off);
180
181 /** \return whether the depth stream is registered to the RGB camera fram or not. */
182 bool
183 isDepthRegistered () const throw ();
184
185 /** \return whether a registration of the depth stream to the RGB camera frame is supported or not. */
186 bool
187 isDepthRegistrationSupported () const throw ();
188
189 /** \brief set the hardware synchronization between Depth and RGB stream on or off.
190 * \param[in] on_off
191 */
192 void
193 setSynchronization (bool on_off);
194
195 /** \return true if Depth stream is synchronized to RGB stream, false otherwise. */
196 bool
197 isSynchronized () const throw ();
198
199 /** \return true if the Device supports hardware synchronization between Depth and RGB streams or not. */
200 virtual bool
201 isSynchronizationSupported () const throw ();
202
203 /** \return true if depth stream is a cropped version of the native depth stream, false otherwise. */
204 bool
205 isDepthCropped () const;
206
207 /** \brief turn on cropping for the depth stream.
208 * \param[in] x x-position of the rectangular subregion.
209 * \param[in] y y-position of the rectangular subregion.
210 * \param[in] width width of the rectangular subregion.
211 * \param[in] height height of the rectangular subregion.
212 */
213 void
214 setDepthCropping (unsigned x, unsigned y, unsigned width, unsigned height);
215
216 /** \return true if cropping of the depth stream is supported, false otherwise. */
217 bool
218 isDepthCroppingSupported () const throw ();
219
220 /** \brief returns the focal length for the color camera in pixels. The pixels are assumed to be square.
221 * Result depends on the output resolution of the image.
222 */
223 inline float
224 getImageFocalLength (int output_x_resolution = 0) const throw ();
225
226 /** \brief returns the focal length for the IR camera in pixels. The pixels are assumed to be square.
227 * Result depends on the output resolution of the depth image.
228 */
229 inline float
230 getDepthFocalLength (int output_x_resolution = 0) const throw ();
231
232 /** \return Baseline of the "stereo" frame. i.e. for PSDK compatible devices its the distance between the Projector and the IR camera. */
233 inline float
234 getBaseline () const throw ();
235
236 /** \brief starts the image stream. */
237 virtual void
238 startImageStream ();
239
240 /** \brief stops the image stream. */
241 virtual void
242 stopImageStream ();
243
244 /** \brief starts the depth stream. */
245 virtual void
246 startDepthStream ();
247
248 /** \brief stops the depth stream. */
249 virtual void
250 stopDepthStream ();
251
252 /** \brief starts the IR stream. */
253 virtual void
254 startIRStream ();
255
256 /** \brief stops the IR stream. */
257 virtual void
258 stopIRStream ();
259
260 /** \return true if the device supports an image stream, false otherwise. */
261 bool
262 hasImageStream () const throw ();
263
264 /** \return true if the device supports a depth stream, false otherwise. */
265 bool
266 hasDepthStream () const throw ();
267
268 /** \return true if the device supports an IR stream, false otherwise. */
269 bool
270 hasIRStream () const throw ();
271
272 /** \return true if the image stream is running / started, false otherwise. */
273 virtual bool
274 isImageStreamRunning () const throw ();
275
276 /** \return true if the depth stream is running / started, false otherwise. */
277 virtual bool
278 isDepthStreamRunning () const throw ();
279
280 /** \return true if the IR stream is running / started, false otherwise. */
281 virtual bool
282 isIRStreamRunning () const throw ();
283
284 /** \brief registers a callback function of std::function type for the image stream with an optional user defined parameter.
285 * The callback will always be called with a new image and the user data "cookie".
286 * \param[in] callback the user callback to be called if a new image is available
287 * \param[in] cookie the cookie that needs to be passed to the callback together with the new image.
288 * \return a callback handler that can be used to remove the user callback from list of image-stream callbacks.
289 */
291 registerImageCallback (const ImageCallbackFunction& callback, void* cookie = nullptr) noexcept;
292
293 /** \brief registers a callback function for the image stream with an optional user defined parameter.
294 * This version is used to register a member function of any class.
295 * The callback will always be called with a new image and the user data "cookie".
296 * \param[in] callback the user callback to be called if a new image is available
297 * \param instance
298 * \param[in] cookie the cookie that needs to be passed to the callback together with the new image.
299 * \return a callback handler that can be used to remove the user callback from list of image-stream callbacks.
300 */
301 template<typename T> CallbackHandle
302 registerImageCallback (void (T::*callback)(Image::Ptr, void* cookie), T& instance, void* cookie = nullptr) noexcept;
303
304 /** \brief unregisters a callback function. i.e. removes that function from the list of image stream callbacks.
305 * \param[in] callbackHandle the handle of the callback to unregister.
306 * \return true, if callback was in list and could be unregistered, false otherwise.
307 */
308 bool
309 unregisterImageCallback (const CallbackHandle& callbackHandle) noexcept;
310
311
312 /** \brief registers a callback function of std::function type for the depth stream with an optional user defined parameter.
313 * The callback will always be called with a new depth image and the user data "cookie".
314 * \param[in] callback the user callback to be called if a new depth image is available
315 * \param[in] cookie the cookie that needs to be passed to the callback together with the new depth image.
316 * \return a callback handler that can be used to remove the user callback from list of depth-stream callbacks.
317 */
319 registerDepthCallback (const DepthImageCallbackFunction& callback, void* cookie = nullptr) noexcept;
320
321 /** \brief registers a callback function for the depth stream with an optional user defined parameter.
322 * This version is used to register a member function of any class.
323 * The callback will always be called with a new depth image and the user data "cookie".
324 * \param[in] callback the user callback to be called if a new depth image is available
325 * \param instance
326 * \param[in] cookie the cookie that needs to be passed to the callback together with the new depth image.
327 * \return a callback handler that can be used to remove the user callback from list of depth-stream callbacks.
328 */
329 template<typename T> CallbackHandle
330 registerDepthCallback (void (T::*callback)(DepthImage::Ptr, void* cookie), T& instance, void* cookie = nullptr) noexcept;
331
332 /** \brief unregisters a callback function. i.e. removes that function from the list of depth stream callbacks.
333 * \param[in] callbackHandle the handle of the callback to unregister.
334 * \return true, if callback was in list and could be unregistered, false otherwise.
335 */
336 bool
337 unregisterDepthCallback (const CallbackHandle& callbackHandle) noexcept;
338
339 /** \brief registers a callback function of std::function type for the IR stream with an optional user defined parameter.
340 * The callback will always be called with a new IR image and the user data "cookie".
341 * \param[in] callback the user callback to be called if a new IR image is available
342 * \param[in] cookie the cookie that needs to be passed to the callback together with the new IR image.
343 * \return a callback handler that can be used to remove the user callback from list of IR-stream callbacks.
344 */
346 registerIRCallback (const IRImageCallbackFunction& callback, void* cookie = nullptr) noexcept;
347
348 /** \brief registers a callback function for the IR stream with an optional user defined parameter.
349 * This version is used to register a member function of any class.
350 * The callback will always be called with a new IR image and the user data "cookie".
351 * \param[in] callback the user callback to be called if a new IR image is available
352 * \param instance
353 * \param[in] cookie the cookie that needs to be passed to the callback together with the new IR image.
354 * \return a callback handler that can be used to remove the user callback from list of IR-stream callbacks.
355 */
356 template<typename T> CallbackHandle
357 registerIRCallback (void (T::*callback)(IRImage::Ptr, void* cookie), T& instance, void* cookie = nullptr) noexcept;
358
359 /** \brief unregisters a callback function. i.e. removes that function from the list of IR stream callbacks.
360 * \param[in] callbackHandle the handle of the callback to unregister.
361 * \return true, if callback was in list and could be unregistered, false otherwise.
362 */
363 bool
364 unregisterIRCallback (const CallbackHandle& callbackHandle) noexcept;
365
366 /** \brief returns the serial number for device.
367 * \attention This might be an empty string!!!
368 */
369 const char*
370 getSerialNumber () const throw ();
371
372 /** \brief returns the connection string for current device, which has following format vendorID/productID\@BusID/DeviceID. */
373 const char*
374 getConnectionString () const throw ();
375
376 /** \return the Vendor name of the USB device. */
377 const char*
378 getVendorName () const throw ();
379
380 /** \return the product name of the USB device. */
381 const char*
382 getProductName () const throw ();
383
384 /** \return the vendor ID of the USB device. */
385 unsigned short
386 getVendorID () const throw ();
387
388 /** \return the product ID of the USB device. */
389 unsigned short
390 getProductID () const throw ();
391
392 /** \return the USB bus on which the device is connected. */
393 unsigned char
394 getBus () const throw ();
395
396 /** \return the USB Address of the device. */
397 unsigned char
398 getAddress () const throw ();
399
400 /** \brief Set the RGB image focal length.
401 * \param[in] focal_length the RGB image focal length
402 */
403 inline void
404 setRGBFocalLength (float focal_length)
405 {
406 rgb_focal_length_SXGA_ = focal_length;
407 }
408
409 /** \brief Set the depth image focal length.
410 * \param[in] focal_length the depth image focal length
411 */
412 inline void
413 setDepthFocalLength (float focal_length)
414 {
415 depth_focal_length_SXGA_ = focal_length;
416 }
417
418 /** \brief Set the depth output format. Use 12bit depth values or shift values.
419 * \param[in] depth_mode the depth output format
420 */
421 void
422 setDepthOutputFormat (const DepthMode& depth_mode = OpenNI_12_bit_depth);
423
424 /** \brief Get the depth output format as set by the user. */
425 XnUInt64
427
428
429 /** \brief Convert shift to depth value. */
430 std::uint16_t
431 shiftToDepth (std::uint16_t shift_value) const
432 {
433 assert (shift_conversion_parameters_.init_);
434
435 std::uint16_t ret = 0;
436
437 // lookup depth value in shift lookup table
438 if (shift_value<shift_to_depth_table_.size())
439 ret = shift_to_depth_table_[shift_value];
440
441 return ret;
442 }
443
444 private:
445 // make OpenNIDevice non copyable
446 OpenNIDevice (OpenNIDevice const &);
447 OpenNIDevice& operator=(OpenNIDevice const &);
448 protected:
449 using ActualImageCallbackFunction = std::function<void(Image::Ptr) >;
451 using ActualIRImageCallbackFunction = std::function<void(IRImage::Ptr) >;
452
453 OpenNIDevice (xn::Context& context, const xn::NodeInfo& device_node, const xn::NodeInfo& image_node, const xn::NodeInfo& depth_node, const xn::NodeInfo& ir_node);
454 OpenNIDevice (xn::Context& context, const xn::NodeInfo& device_node, const xn::NodeInfo& depth_node, const xn::NodeInfo& ir_node);
455 OpenNIDevice (xn::Context& context);
456 static void __stdcall NewDepthDataAvailable (xn::ProductionNode& node, void* cookie) noexcept;
457 static void __stdcall NewImageDataAvailable (xn::ProductionNode& node, void* cookie) noexcept;
458 static void __stdcall NewIRDataAvailable (xn::ProductionNode& node, void* cookie) noexcept;
459
460 // This is a workaround, since in the NewDepthDataAvailable function WaitAndUpdateData leads to a dead-lock behaviour
461 // and retrieving image data without WaitAndUpdateData leads to incomplete images!!!
462 void
464
465 void
467
468 void
470
471 virtual bool
472 isImageResizeSupported (unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const throw () = 0;
473
474 void
475 setRegistration (bool on_off);
476
477 virtual Image::Ptr
478 getCurrentImage (pcl::shared_ptr<xn::ImageMetaData> image_data) const throw () = 0;
479
480 void
482
485
487 {
488 ShiftConversion() : init_(false) {}
489
493 XnUInt32 max_shift_;
495 XnUInt32 const_shift_;
497 XnUInt32 param_coeff_;
498 XnUInt32 shift_scale_;
499 XnUInt32 min_depth_;
500 XnUInt32 max_depth_;
501 bool init_;
502
503 } shift_conversion_parameters_;
504
505 std::vector<std::uint16_t> shift_to_depth_table_;
506
507 // holds the callback functions together with custom data
508 // since same callback function can be registered multiple times with e.g. different custom data
509 // we use a map structure with a handle as the key
510 std::map<CallbackHandle, ActualImageCallbackFunction> image_callback_;
511 std::map<CallbackHandle, ActualDepthImageCallbackFunction> depth_callback_;
512 std::map<CallbackHandle, ActualIRImageCallbackFunction> ir_callback_;
513
514 std::vector<XnMapOutputMode> available_image_modes_;
515 std::vector<XnMapOutputMode> available_depth_modes_;
516
517 /** \brief context to OpenNI driver*/
518 xn::Context& context_;
519 /** \brief node object for current device */
520 xn::NodeInfo device_node_info_;
521
522 /** \brief Depth generator object. */
523 xn::DepthGenerator depth_generator_;
524 /** \brief Image generator object. */
525 xn::ImageGenerator image_generator_;
526 /** \brief IR generator object. */
527 xn::IRGenerator ir_generator_;
528
529 XnCallbackHandle depth_callback_handle_;
530 XnCallbackHandle image_callback_handle_;
531 XnCallbackHandle ir_callback_handle_;
532
533 /** \brief focal length for IR camera producing depth information in native SXGA mode */
535 /** \brief distance between the projector and the IR camera*/
537 /** \brief focal length for regular camera producing color images in native SXGA mode */
539
540 /** the value for shadow (occluded pixels) */
542 /** the value for pixels without a valid disparity measurement */
544
548
549 bool quit_;
550 mutable std::mutex image_mutex_;
551 mutable std::mutex depth_mutex_;
552 mutable std::mutex ir_mutex_;
553 std::condition_variable image_condition_;
554 std::condition_variable depth_condition_;
555 std::condition_variable ir_condition_;
556 std::thread image_thread_;
557 std::thread depth_thread_;
558 std::thread ir_thread_;
559 };
560
561 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
562 float
563 OpenNIDevice::getImageFocalLength (int output_x_resolution) const throw ()
564 {
565 if (output_x_resolution == 0)
566 output_x_resolution = getImageOutputMode ().nXRes;
567
568 float scale = static_cast<float> (output_x_resolution) / static_cast<float> (XN_SXGA_X_RES);
569 return (rgb_focal_length_SXGA_ * scale);
570 }
571
572 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
573 float
574 OpenNIDevice::getDepthFocalLength (int output_x_resolution) const throw ()
575 {
576 if (output_x_resolution == 0)
577 output_x_resolution = getDepthOutputMode ().nXRes;
578
579 float scale = static_cast<float> (output_x_resolution) / static_cast<float> (XN_SXGA_X_RES);
580 if (isDepthRegistered ())
581 return (rgb_focal_length_SXGA_ * scale);
582 return (depth_focal_length_SXGA_ * scale);
583 }
584
585 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
586 float
588 {
589 return (baseline_);
590 }
591
592 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
593 template<typename T> OpenNIDevice::CallbackHandle
594 OpenNIDevice::registerImageCallback (void (T::*callback)(Image::Ptr, void* cookie), T& instance, void* custom_data) noexcept
595 {
596 image_callback_[image_callback_handle_counter_] = [=, &instance] (Image::Ptr img) { (instance.*callback) (img, custom_data); };
597 return (image_callback_handle_counter_++);
598 }
599
600 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
601 template<typename T> OpenNIDevice::CallbackHandle
602 OpenNIDevice::registerDepthCallback (void (T::*callback)(DepthImage::Ptr, void* cookie), T& instance, void* custom_data) noexcept
603 {
604 depth_callback_[depth_callback_handle_counter_] = [=, &instance] (DepthImage::Ptr img) { (instance.*callback) (img, custom_data); };
605 return (depth_callback_handle_counter_++);
606 }
607
608 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
609 template<typename T> OpenNIDevice::CallbackHandle
610 OpenNIDevice::registerIRCallback (void (T::*callback)(IRImage::Ptr, void* cookie), T& instance, void* custom_data) noexcept
611 {
612 ir_callback_[ir_callback_handle_counter_] = [=, &instance] (IRImage::Ptr img) { (instance.*callback) (img, custom_data); };
613 return (ir_callback_handle_counter_++);
614 }
615
616}
617#endif // HAVE_OPENNI
This class provides methods to fill a depth or disparity image.
pcl::shared_ptr< DepthImage > Ptr
Class containing just a reference to IR meta data.
pcl::shared_ptr< IRImage > Ptr
Image class containing just a reference to image meta data.
Definition: openni_image.h:59
pcl::shared_ptr< Image > Ptr
Definition: openni_image.h:61
Class representing an astract device for OpenNI devices: Primesense PSDK, Microsoft Kinect,...
Definition: openni_device.h:72
float rgb_focal_length_SXGA_
focal length for regular camera producing color images in native SXGA mode
OpenNIDevice::CallbackHandle depth_callback_handle_counter_
XnUInt64 shadow_value_
the value for shadow (occluded pixels)
std::function< void(DepthImage::Ptr, void *cookie) > DepthImageCallbackFunction
Definition: openni_device.h:84
std::map< CallbackHandle, ActualIRImageCallbackFunction > ir_callback_
void setDepthFocalLength(float focal_length)
Set the depth image focal length.
std::map< CallbackHandle, ActualImageCallbackFunction > image_callback_
std::function< void(Image::Ptr) > ActualImageCallbackFunction
xn::IRGenerator ir_generator_
IR generator object.
float baseline_
distance between the projector and the IR camera
std::function< void(IRImage::Ptr, void *cookie) > IRImageCallbackFunction
Definition: openni_device.h:85
float depth_focal_length_SXGA_
focal length for IR camera producing depth information in native SXGA mode
XnCallbackHandle ir_callback_handle_
xn::ImageGenerator image_generator_
Image generator object.
float getImageFocalLength(int output_x_resolution=0) const
returns the focal length for the color camera in pixels.
std::function< void(DepthImage::Ptr) > ActualDepthImageCallbackFunction
std::vector< std::uint16_t > shift_to_depth_table_
static void __stdcall NewImageDataAvailable(xn::ProductionNode &node, void *cookie) noexcept
std::function< void(Image::Ptr, void *cookie) > ImageCallbackFunction
Definition: openni_device.h:83
XnCallbackHandle image_callback_handle_
XnUInt64 getDepthOutputFormat() const
Get the depth output format as set by the user.
std::function< void(IRImage::Ptr) > ActualIRImageCallbackFunction
static void __stdcall NewIRDataAvailable(xn::ProductionNode &node, void *cookie) noexcept
std::uint16_t shiftToDepth(std::uint16_t shift_value) const
Convert shift to depth value.
OpenNIDevice(xn::Context &context, const xn::NodeInfo &device_node, const xn::NodeInfo &image_node, const xn::NodeInfo &depth_node, const xn::NodeInfo &ir_node)
pcl::shared_ptr< OpenNIDevice > Ptr
Definition: openni_device.h:80
float getDepthFocalLength(int output_x_resolution=0) const
returns the focal length for the IR camera in pixels.
CallbackHandle registerImageCallback(const ImageCallbackFunction &callback, void *cookie=nullptr) noexcept
registers a callback function of std::function type for the image stream with an optional user define...
std::condition_variable ir_condition_
xn::NodeInfo device_node_info_
node object for current device
CallbackHandle registerDepthCallback(const DepthImageCallbackFunction &callback, void *cookie=nullptr) noexcept
registers a callback function of std::function type for the depth stream with an optional user define...
OpenNIDevice(xn::Context &context)
static void __stdcall NewDepthDataAvailable(xn::ProductionNode &node, void *cookie) noexcept
OpenNIDevice::CallbackHandle image_callback_handle_counter_
xn::DepthGenerator depth_generator_
Depth generator object.
xn::Context & context_
context to OpenNI driver
void setDepthOutputFormat(const DepthMode &depth_mode=OpenNI_12_bit_depth)
Set the depth output format.
CallbackHandle registerIRCallback(const IRImageCallbackFunction &callback, void *cookie=nullptr) noexcept
registers a callback function of std::function type for the IR stream with an optional user defined p...
std::vector< XnMapOutputMode > available_image_modes_
OpenNIDevice(xn::Context &context, const xn::NodeInfo &device_node, const xn::NodeInfo &depth_node, const xn::NodeInfo &ir_node)
std::vector< XnMapOutputMode > available_depth_modes_
OpenNIDevice::CallbackHandle ir_callback_handle_counter_
std::condition_variable image_condition_
std::map< CallbackHandle, ActualDepthImageCallbackFunction > depth_callback_
pcl::shared_ptr< const OpenNIDevice > ConstPtr
Definition: openni_device.h:81
virtual bool isImageResizeSupported(unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const =0
void setRegistration(bool on_off)
std::condition_variable depth_condition_
virtual ~OpenNIDevice() noexcept
virtual destructor.
XnUInt64 no_sample_value_
the value for pixels without a valid disparity measurement
XnCallbackHandle depth_callback_handle_
virtual Image::Ptr getCurrentImage(pcl::shared_ptr< xn::ImageMetaData > image_data) const =0
Defines functions, macros and traits for allocating and using memory.
Defines all the PCL and non-PCL macros used.
#define PCL_EXPORTS
Definition: pcl_macros.h:323