38 #include <pcl/pcl_config.h>
41 #ifndef __OPENNI_IDEVICE_H__
42 #define __OPENNI_IDEVICE_H__
46 #include "openni_exception.h"
49 #include <pcl/io/boost.h>
50 #include <pcl/pcl_macros.h>
59 namespace openni_wrapper
74 OpenNI_shift_values = 0,
75 OpenNI_12_bit_depth = 1,
96 findCompatibleImageMode (const XnMapOutputMode& output_mode, XnMapOutputMode& mode ) const throw ();
106 findCompatibleDepthMode (const XnMapOutputMode& output_mode, XnMapOutputMode& mode ) const throw ();
113 isImageModeSupported (const XnMapOutputMode& output_mode) const throw ();
120 isDepthModeSupported (const XnMapOutputMode& output_mode) const throw ();
125 const XnMapOutputMode&
126 getDefaultImageMode () const throw ();
131 const XnMapOutputMode&
132 getDefaultDepthMode () const throw ();
137 const XnMapOutputMode&
138 getDefaultIRMode () const throw ();
144 setImageOutputMode (const XnMapOutputMode& output_mode);
150 setDepthOutputMode (const XnMapOutputMode& output_mode);
156 setIROutputMode (const XnMapOutputMode& output_mode);
160 getImageOutputMode () const;
164 getDepthOutputMode () const;
168 getIROutputMode () const;
174 setDepthRegistration (
bool on_off);
178 isDepthRegistered () const throw ();
182 isDepthRegistrationSupported () const throw ();
188 setSynchronization (
bool on_off);
192 isSynchronized () const throw ();
196 isSynchronizationSupported () const throw ();
200 isDepthCropped () const;
209 setDepthCropping (
unsigned x,
unsigned y,
unsigned width,
unsigned height);
213 isDepthCroppingSupported () const throw ();
219 getImageFocalLength (
int output_x_resolution = 0) const throw ();
225 getDepthFocalLength (
int output_x_resolution = 0) const throw ();
229 getBaseline () const throw ();
257 hasImageStream () const throw ();
261 hasDepthStream () const throw ();
265 hasIRStream () const throw ();
269 isImageStreamRunning () const throw ();
273 isDepthStreamRunning () const throw ();
277 isIRStreamRunning () const throw ();
296 registerImageCallback (
void (T::*callback)(boost::shared_ptr<
Image>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
303 unregisterImageCallback (const
CallbackHandle& callbackHandle) throw ();
323 registerDepthCallback (
void (T::*callback)(boost::shared_ptr<
DepthImage>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
330 unregisterDepthCallback (const
CallbackHandle& callbackHandle) throw ();
349 registerIRCallback (
void (T::*callback)(boost::shared_ptr<
IRImage>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
356 unregisterIRCallback (const
CallbackHandle& callbackHandle) throw ();
362 getSerialNumber () const throw ();
366 getConnectionString () const throw ();
370 getVendorName () const throw ();
374 getProductName () const throw ();
378 getVendorID () const throw ();
382 getProductID () const throw ();
386 getBus () const throw ();
390 getAddress () const throw ();
396 setRGBFocalLength (
float focal_length)
398 rgb_focal_length_SXGA_ = focal_length;
407 depth_focal_length_SXGA_ = focal_length;
414 setDepthOutputFormat (
const DepthMode& depth_mode = OpenNI_12_bit_depth);
418 getDepthOutputFormat ()
const;
425 assert (shift_conversion_parameters_.init_);
427 pcl::uint16_t ret = 0;
430 if (shift_value<shift_to_depth_table_.size())
431 ret = shift_to_depth_table_[shift_value];
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);
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 ();
455 ImageDataThreadFunction ();
458 DepthDataThreadFunction ();
461 IRDataThreadFunction ();
464 isImageResizeSupported (
unsigned input_width,
unsigned input_height,
unsigned output_width,
unsigned output_height)
const throw () = 0;
467 setRegistration (
bool on_off);
469 virtual boost::shared_ptr<Image>
470 getCurrentImage (boost::shared_ptr<xn::ImageMetaData> image_data)
const throw () = 0;
475 void InitShiftToDepthConversion();
476 void ReadDeviceParametersFromSensorNode();
495 } shift_conversion_parameters_;
557 if (output_x_resolution == 0)
558 output_x_resolution = getImageOutputMode ().nXRes;
560 float scale =
static_cast<float> (output_x_resolution) / static_cast<float> (XN_SXGA_X_RES);
561 return (rgb_focal_length_SXGA_ * scale);
568 if (output_x_resolution == 0)
569 output_x_resolution = getDepthOutputMode ().nXRes;
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);
575 return (depth_focal_length_SXGA_ * scale);
589 image_callback_[image_callback_handle_counter_] = boost::bind (callback, boost::ref (instance), _1, custom_data);
590 return (image_callback_handle_counter_++);
597 depth_callback_[depth_callback_handle_counter_] = boost::bind ( callback, boost::ref (instance), _1, custom_data);
598 return (depth_callback_handle_counter_++);
605 ir_callback_[ir_callback_handle_counter_] = boost::bind ( callback, boost::ref (instance), _1, custom_data);
606 return (ir_callback_handle_counter_++);
610 #endif // __OPENNI_IDEVICE_H__
611 #endif // HAVE_OPENNI