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 ();
297 registerImageCallback (
void (T::*callback)(
boost::shared_ptr<
Image>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
304 unregisterImageCallback (const
CallbackHandle& callbackHandle) throw ();
325 registerDepthCallback (
void (T::*callback)(
boost::shared_ptr<
DepthImage>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
332 unregisterDepthCallback (const
CallbackHandle& callbackHandle) throw ();
352 registerIRCallback (
void (T::*callback)(
boost::shared_ptr<
IRImage>,
void* cookie), T& instance,
void* cookie = NULL) throw ();
359 unregisterIRCallback (const
CallbackHandle& callbackHandle) throw ();
365 getSerialNumber () const throw ();
369 getConnectionString () const throw ();
373 getVendorName () const throw ();
377 getProductName () const throw ();
381 getVendorID () const throw ();
385 getProductID () const throw ();
389 getBus () const throw ();
393 getAddress () const throw ();
399 setRGBFocalLength (
float focal_length)
401 rgb_focal_length_SXGA_ = focal_length;
410 depth_focal_length_SXGA_ = focal_length;
417 setDepthOutputFormat (
const DepthMode& depth_mode = OpenNI_12_bit_depth);
421 getDepthOutputFormat ()
const;
428 assert (shift_conversion_parameters_.init_);
430 pcl::uint16_t ret = 0;
433 if (shift_value<shift_to_depth_table_.size())
434 ret = shift_to_depth_table_[shift_value];
448 OpenNIDevice (xn::Context& context,
const xn::NodeInfo& device_node,
const xn::NodeInfo& image_node,
const xn::NodeInfo& depth_node,
const xn::NodeInfo& ir_node);
449 OpenNIDevice (xn::Context& context,
const xn::NodeInfo& device_node,
const xn::NodeInfo& depth_node,
const xn::NodeInfo& ir_node);
451 static void __stdcall NewDepthDataAvailable (xn::ProductionNode& node,
void* cookie)
throw ();
452 static void __stdcall NewImageDataAvailable (xn::ProductionNode& node,
void* cookie)
throw ();
453 static void __stdcall NewIRDataAvailable (xn::ProductionNode& node,
void* cookie)
throw ();
458 ImageDataThreadFunction ();
461 DepthDataThreadFunction ();
464 IRDataThreadFunction ();
467 isImageResizeSupported (
unsigned input_width,
unsigned input_height,
unsigned output_width,
unsigned output_height)
const throw () = 0;
470 setRegistration (
bool on_off);
472 virtual boost::shared_ptr<Image>
473 getCurrentImage (boost::shared_ptr<xn::ImageMetaData> image_data)
const throw () = 0;
478 void InitShiftToDepthConversion();
479 void ReadDeviceParametersFromSensorNode();
498 } shift_conversion_parameters_;
560 if (output_x_resolution == 0)
561 output_x_resolution = getImageOutputMode ().nXRes;
563 float scale =
static_cast<float> (output_x_resolution) / static_cast<float> (XN_SXGA_X_RES);
564 return (rgb_focal_length_SXGA_ * scale);
571 if (output_x_resolution == 0)
572 output_x_resolution = getDepthOutputMode ().nXRes;
574 float scale =
static_cast<float> (output_x_resolution) / static_cast<float> (XN_SXGA_X_RES);
575 if (isDepthRegistered ())
576 return (rgb_focal_length_SXGA_ * scale);
578 return (depth_focal_length_SXGA_ * scale);
592 image_callback_[image_callback_handle_counter_] = boost::bind (callback, boost::ref (instance), _1, custom_data);
593 return (image_callback_handle_counter_++);
600 depth_callback_[depth_callback_handle_counter_] = boost::bind ( callback, boost::ref (instance), _1, custom_data);
601 return (depth_callback_handle_counter_++);
608 ir_callback_[ir_callback_handle_counter_] = boost::bind ( callback, boost::ref (instance), _1, custom_data);
609 return (ir_callback_handle_counter_++);
613 #endif // __OPENNI_IDEVICE_H__ 614 #endif // HAVE_OPENNI boost::function< void(boost::shared_ptr< IRImage >) > ActualIRImageCallbackFunction
std::vector< XnMapOutputMode > available_depth_modes_
float getBaseline() const
boost::thread depth_thread_
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...
DeviceArray2D< uchar4 > Image
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...
float getImageFocalLength(int output_x_resolution=0) const
returns the focal length for the color camera in pixels.
boost::function< void(boost::shared_ptr< Image >) > ActualImageCallbackFunction
std::map< CallbackHandle, ActualImageCallbackFunction > image_callback_
Class representing an astract device for OpenNI devices: Primesense PSDK, Microsoft Kinect...
xn::ImageGenerator image_generator_
Image generator object.
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.
XnUInt32 device_max_shift_
OpenNIDevice::CallbackHandle ir_callback_handle_counter_
boost::function< void(boost::shared_ptr< DepthImage >, void *cookie) > DepthImageCallbackFunction
float baseline_
distance between the projector and the IR camera
xn::Context & context_
context to OpenNI driver
OpenNIDevice::CallbackHandle depth_callback_handle_counter_
boost::condition_variable ir_condition_
pcl::io::DepthImage DepthImage
This class provides methods to fill a depth or disparity image.
boost::condition_variable image_condition_
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...
xn::IRGenerator ir_generator_
IR generator object.
boost::function< void(boost::shared_ptr< DepthImage >) > ActualDepthImageCallbackFunction
XnUInt16 zero_plane_distance_
XnCallbackHandle depth_callback_handle_
boost::function< void(boost::shared_ptr< Image >, void *cookie) > ImageCallbackFunction
boost::function< void(boost::shared_ptr< IRImage >, void *cookie) > IRImageCallbackFunction
XnUInt32 pixel_size_factor_
std::vector< pcl::uint16_t > shift_to_depth_table_
xn::NodeInfo device_node_info_
node object for current device
pcl::uint16_t shiftToDepth(pcl::uint16_t shift_value) const
Convert shift to depth value.
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_
boost::mutex depth_mutex_
boost::condition_variable depth_condition_
boost::thread image_thread_
XnCallbackHandle ir_callback_handle_
boost::mutex image_mutex_
float getDepthFocalLength(int output_x_resolution=0) const
returns the focal length for the IR camera in pixels.
XnFloat zero_plane_pixel_size_
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.
XnCallbackHandle image_callback_handle_
XnFloat emitter_dcmos_distace_
XnUInt64 shadow_value_
the value for shadow (occluded pixels)