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>
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 ();
295 template<typename T> CallbackHandle
296 registerImageCallback (
void (T::*callback)(
boost::shared_ptr<
Image>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
303 unregisterImageCallback (const CallbackHandle& callbackHandle) throw ();
322 template<typename T> CallbackHandle
323 registerDepthCallback (
void (T::*callback)(
boost::shared_ptr<
DepthImage>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
330 unregisterDepthCallback (const CallbackHandle& callbackHandle) throw ();
348 template<typename T> CallbackHandle
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
std::map< CallbackHandle, ActualIRImageCallbackFunction > ir_callback_
float getImageFocalLength(int output_x_resolution=0) const
returns the focal length for the color camera in pixels.
Class containing just a reference to IR meta data.
XnUInt64 shadow_value_
the value for shadow (occluded pixels)
boost::function< void(boost::shared_ptr< DepthImage >) > ActualDepthImageCallbackFunction
std::map< CallbackHandle, ActualDepthImageCallbackFunction > depth_callback_
std::map< CallbackHandle, ActualImageCallbackFunction > image_callback_
OpenNIDevice::CallbackHandle image_callback_handle_counter_
xn::Context & context_
context to OpenNI driver
XnUInt32 device_max_shift_
boost::function< void(boost::shared_ptr< DepthImage >, void *cookie) > DepthImageCallbackFunction
float getBaseline() const
boost::function< void(boost::shared_ptr< IRImage >) > ActualIRImageCallbackFunction
pcl::PointCloud< Color > Image
An Image is a point cloud of Color.
float rgb_focal_length_SXGA_
focal length for regular camera producing color images in native SXGA mode
XnUInt32 pixel_size_factor_
OpenNIDevice::CallbackHandle ir_callback_handle_counter_
OpenNIDevice::CallbackHandle depth_callback_handle_counter_
float getDepthFocalLength(int output_x_resolution=0) const
returns the focal length for the IR camera in pixels.
float baseline_
distance between the projector and the IR camera
boost::condition_variable image_condition_
XnUInt64 no_sample_value_
the value for pixels without a valid disparity measurement
This class provides methods to fill a depth or disparity image.
boost::function< void(boost::shared_ptr< Image >) > ActualImageCallbackFunction
xn::DepthGenerator depth_generator_
Depth generator object.
std::vector< XnMapOutputMode > available_image_modes_
boost::condition_variable depth_condition_
boost::condition_variable ir_condition_
XnCallbackHandle image_callback_handle_
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...
XnFloat zero_plane_pixel_size_
std::vector< pcl::uint16_t > shift_to_depth_table_
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...
boost::thread image_thread_
std::vector< XnMapOutputMode > available_depth_modes_
boost::function< void(boost::shared_ptr< Image >, void *cookie) > ImageCallbackFunction
xn::IRGenerator ir_generator_
IR generator object.
boost::function< void(boost::shared_ptr< IRImage >, void *cookie) > IRImageCallbackFunction
XnCallbackHandle ir_callback_handle_
XnUInt16 zero_plane_distance_
float depth_focal_length_SXGA_
focal length for IR camera producing depth information in native SXGA mode
XnCallbackHandle depth_callback_handle_
boost::mutex depth_mutex_
XnFloat emitter_dcmos_distace_
xn::ImageGenerator image_generator_
Image generator object.
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...
xn::NodeInfo device_node_info_
node object for current device
Image class containing just a reference to image meta data.
void setDepthFocalLength(float focal_length)
Set the depth image focal length.
boost::thread depth_thread_
pcl::uint16_t shiftToDepth(pcl::uint16_t shift_value) const
Convert shift to depth value.
boost::mutex image_mutex_
Class representing an astract device for OpenNI devices: Primesense PSDK, Microsoft Kinect...