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