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