40 #include <pcl/pcl_config.h>
44 #include "openni_exception.h"
47 #include <pcl/io/openni_camera/openni_image.h>
48 #include <pcl/io/openni_camera/openni_depth_image.h>
49 #include <pcl/io/openni_camera/openni_ir_image.h>
52 #include <condition_variable>
76 OpenNI_shift_values = 0,
77 OpenNI_12_bit_depth = 1,
80 using Ptr = pcl::shared_ptr<OpenNIDevice>;
81 using ConstPtr = pcl::shared_ptr<const OpenNIDevice>;
101 findCompatibleImageMode (const XnMapOutputMode& output_mode, XnMapOutputMode& mode ) const throw ();
111 findCompatibleDepthMode (const XnMapOutputMode& output_mode, XnMapOutputMode& mode ) const throw ();
118 isImageModeSupported (const XnMapOutputMode& output_mode) const throw ();
125 isDepthModeSupported (const XnMapOutputMode& output_mode) const throw ();
130 const XnMapOutputMode&
131 getDefaultImageMode () const throw ();
136 const XnMapOutputMode&
137 getDefaultDepthMode () const throw ();
142 const XnMapOutputMode&
143 getDefaultIRMode () const throw ();
149 setImageOutputMode (const XnMapOutputMode& output_mode);
155 setDepthOutputMode (const XnMapOutputMode& output_mode);
161 setIROutputMode (const XnMapOutputMode& output_mode);
165 getImageOutputMode () const;
169 getDepthOutputMode () const;
173 getIROutputMode () const;
179 setDepthRegistration (
bool on_off);
183 isDepthRegistered () const throw ();
187 isDepthRegistrationSupported () const throw ();
193 setSynchronization (
bool on_off);
197 isSynchronized () const throw ();
201 isSynchronizationSupported () const throw ();
205 isDepthCropped () const;
214 setDepthCropping (
unsigned x,
unsigned y,
unsigned width,
unsigned height);
218 isDepthCroppingSupported () const throw ();
224 getImageFocalLength (
int output_x_resolution = 0) const throw ();
230 getDepthFocalLength (
int output_x_resolution = 0) const throw ();
234 getBaseline () const throw ();
262 hasImageStream () const throw ();
266 hasDepthStream () const throw ();
270 hasIRStream () const throw ();
274 isImageStreamRunning () const throw ();
278 isDepthStreamRunning () const throw ();
282 isIRStreamRunning () const throw ();
302 registerImageCallback (
void (T::*callback)(
Image::
Ptr,
void* cookie), T& instance,
void* cookie =
nullptr) noexcept;
309 unregisterImageCallback (const
CallbackHandle& callbackHandle) noexcept;
330 registerDepthCallback (
void (T::*callback)(
DepthImage::
Ptr,
void* cookie), T& instance,
void* cookie =
nullptr) noexcept;
337 unregisterDepthCallback (const
CallbackHandle& callbackHandle) noexcept;
357 registerIRCallback (
void (T::*callback)(
IRImage::
Ptr,
void* cookie), T& instance,
void* cookie =
nullptr) noexcept;
364 unregisterIRCallback (const
CallbackHandle& callbackHandle) noexcept;
370 getSerialNumber () const throw ();
374 getConnectionString () const throw ();
378 getVendorName () const throw ();
382 getProductName () const throw ();
386 getVendorID () const throw ();
390 getProductID () const throw ();
394 getBus () const throw ();
398 getAddress () const throw ();
404 setRGBFocalLength (
float focal_length)
406 rgb_focal_length_SXGA_ = focal_length;
415 depth_focal_length_SXGA_ = focal_length;
422 setDepthOutputFormat (
const DepthMode& depth_mode = OpenNI_12_bit_depth);
426 getDepthOutputFormat ()
const;
433 assert (shift_conversion_parameters_.init_);
435 std::uint16_t ret = 0;
438 if (shift_value<shift_to_depth_table_.size())
439 ret = shift_to_depth_table_[shift_value];
453 OpenNIDevice (xn::Context& context,
const xn::NodeInfo& device_node,
const xn::NodeInfo& image_node,
const xn::NodeInfo& depth_node,
const xn::NodeInfo& ir_node);
454 OpenNIDevice (xn::Context& context,
const xn::NodeInfo& device_node,
const xn::NodeInfo& depth_node,
const xn::NodeInfo& ir_node);
456 static void __stdcall NewDepthDataAvailable (xn::ProductionNode& node,
void* cookie) noexcept;
457 static void __stdcall NewImageDataAvailable (xn::ProductionNode& node,
void* cookie) noexcept;
458 static void __stdcall NewIRDataAvailable (xn::ProductionNode& node,
void* cookie) noexcept;
463 ImageDataThreadFunction ();
466 DepthDataThreadFunction ();
469 IRDataThreadFunction ();
472 isImageResizeSupported (
unsigned input_width,
unsigned input_height,
unsigned output_width,
unsigned output_height)
const throw () = 0;
475 setRegistration (
bool on_off);
478 getCurrentImage (pcl::shared_ptr<xn::ImageMetaData> image_data)
const throw () = 0;
483 void InitShiftToDepthConversion();
484 void ReadDeviceParametersFromSensorNode();
503 } shift_conversion_parameters_;
565 if (output_x_resolution == 0)
566 output_x_resolution = getImageOutputMode ().nXRes;
568 float scale =
static_cast<float> (output_x_resolution) /
static_cast<float> (XN_SXGA_X_RES);
569 return (rgb_focal_length_SXGA_ * scale);
576 if (output_x_resolution == 0)
577 output_x_resolution = getDepthOutputMode ().nXRes;
579 float scale =
static_cast<float> (output_x_resolution) /
static_cast<float> (XN_SXGA_X_RES);
580 if (isDepthRegistered ())
581 return (rgb_focal_length_SXGA_ * scale);
582 return (depth_focal_length_SXGA_ * scale);
596 image_callback_[image_callback_handle_counter_] = [=, &instance] (
Image::Ptr img) { (instance.*callback) (img, custom_data); };
597 return (image_callback_handle_counter_++);
604 depth_callback_[depth_callback_handle_counter_] = [=, &instance] (
DepthImage::Ptr img) { (instance.*callback) (img, custom_data); };
605 return (depth_callback_handle_counter_++);
612 ir_callback_[ir_callback_handle_counter_] = [=, &instance] (
IRImage::Ptr img) { (instance.*callback) (img, custom_data); };
613 return (ir_callback_handle_counter_++);
617 #endif // HAVE_OPENNI