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>
71 class PCL_EXPORTS OpenNIDevice
80 using Ptr = pcl::shared_ptr<OpenNIDevice>;
81 using ConstPtr = pcl::shared_ptr<const OpenNIDevice>;
130 const XnMapOutputMode&
136 const XnMapOutputMode&
142 const XnMapOutputMode&
435 std::uint16_t ret = 0;
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);
472 isImageResizeSupported (
unsigned input_width,
unsigned input_height,
unsigned output_width,
unsigned output_height)
const noexcept = 0;
503 } shift_conversion_parameters_;
565 if (output_x_resolution == 0)
568 float scale =
static_cast<float> (output_x_resolution) /
static_cast<float> (XN_SXGA_X_RES);
576 if (output_x_resolution == 0)
579 float scale =
static_cast<float> (output_x_resolution) /
static_cast<float> (XN_SXGA_X_RES);
This class provides methods to fill a depth or disparity image.
pcl::shared_ptr< DepthImage > Ptr
Class containing just a reference to IR meta data.
pcl::shared_ptr< IRImage > Ptr
Image class containing just a reference to image meta data.
pcl::shared_ptr< Image > Ptr
Class representing an astract device for OpenNI devices: Primesense PSDK, Microsoft Kinect,...
void setRGBFocalLength(float focal_length)
Set the RGB image focal length.
float rgb_focal_length_SXGA_
focal length for regular camera producing color images in native SXGA mode
OpenNIDevice::CallbackHandle depth_callback_handle_counter_
XnUInt64 shadow_value_
the value for shadow (occluded pixels)
std::function< void(DepthImage::Ptr, void *cookie) > DepthImageCallbackFunction
std::map< CallbackHandle, ActualIRImageCallbackFunction > ir_callback_
const XnMapOutputMode & getDefaultIRMode() const noexcept
returns the default IR mode, which is simply the first entry in the list of modes
bool isDepthCropped() const
void setSynchronization(bool on_off)
set the hardware synchronization between Depth and RGB stream on or off.
void setDepthFocalLength(float focal_length)
Set the depth image focal length.
std::map< CallbackHandle, ActualImageCallbackFunction > image_callback_
std::function< void(Image::Ptr) > ActualImageCallbackFunction
xn::IRGenerator ir_generator_
IR generator object.
float baseline_
distance between the projector and the IR camera
bool hasIRStream() const noexcept
virtual void stopDepthStream()
stops the depth stream.
std::function< void(IRImage::Ptr, void *cookie) > IRImageCallbackFunction
float depth_focal_length_SXGA_
focal length for IR camera producing depth information in native SXGA mode
XnMapOutputMode getImageOutputMode() const
unsigned short getVendorID() const noexcept
bool isImageModeSupported(const XnMapOutputMode &output_mode) const noexcept
returns whether a given mode is natively supported by the device or not
XnCallbackHandle ir_callback_handle_
bool unregisterDepthCallback(const CallbackHandle &callbackHandle) noexcept
unregisters a callback function.
xn::ImageGenerator image_generator_
Image generator object.
virtual void stopImageStream()
stops the image stream.
virtual bool isSynchronizationSupported() const noexcept
std::function< void(DepthImage::Ptr) > ActualDepthImageCallbackFunction
struct openni_wrapper::OpenNIDevice::ShiftConversion shift_conversion_parameters_
virtual Image::Ptr getCurrentImage(pcl::shared_ptr< xn::ImageMetaData > image_data) const noexcept=0
bool unregisterImageCallback(const CallbackHandle &callbackHandle) noexcept
unregisters a callback function.
XnMapOutputMode getDepthOutputMode() const
std::vector< std::uint16_t > shift_to_depth_table_
float getDepthFocalLength(int output_x_resolution=0) const noexcept
returns the focal length for the IR camera in pixels.
static void __stdcall NewImageDataAvailable(xn::ProductionNode &node, void *cookie) noexcept
const char * getProductName() const noexcept
void DepthDataThreadFunction()
std::function< void(Image::Ptr, void *cookie) > ImageCallbackFunction
XnCallbackHandle image_callback_handle_
XnUInt64 getDepthOutputFormat() const
Get the depth output format as set by the user.
std::function< void(IRImage::Ptr) > ActualIRImageCallbackFunction
unsigned char getBus() const noexcept
static void __stdcall NewIRDataAvailable(xn::ProductionNode &node, void *cookie) noexcept
void InitShiftToDepthConversion()
unsigned short getProductID() const noexcept
std::thread depth_thread_
std::uint16_t shiftToDepth(std::uint16_t shift_value) const
Convert shift to depth value.
OpenNIDevice(xn::Context &context, const xn::NodeInfo &device_node, const xn::NodeInfo &image_node, const xn::NodeInfo &depth_node, const xn::NodeInfo &ir_node)
pcl::shared_ptr< OpenNIDevice > Ptr
unsigned char getAddress() const noexcept
CallbackHandle registerImageCallback(const ImageCallbackFunction &callback, void *cookie=nullptr) noexcept
registers a callback function of std::function type for the image stream with an optional user define...
std::condition_variable ir_condition_
virtual void startDepthStream()
starts the depth stream.
void setDepthRegistration(bool on_off)
set the depth stream registration on or off
xn::NodeInfo device_node_info_
node object for current device
void ImageDataThreadFunction()
bool findCompatibleDepthMode(const XnMapOutputMode &output_mode, XnMapOutputMode &mode) const noexcept
finds a depth output mode that can be used to retrieve depth images in desired output mode.
CallbackHandle registerDepthCallback(const DepthImageCallbackFunction &callback, void *cookie=nullptr) noexcept
registers a callback function of std::function type for the depth stream with an optional user define...
float getBaseline() const noexcept
OpenNIDevice(xn::Context &context)
void setDepthCropping(unsigned x, unsigned y, unsigned width, unsigned height)
turn on cropping for the depth stream.
static void __stdcall NewDepthDataAvailable(xn::ProductionNode &node, void *cookie) noexcept
OpenNIDevice::CallbackHandle image_callback_handle_counter_
const char * getSerialNumber() const noexcept
returns the serial number for device.
bool isDepthCroppingSupported() const noexcept
virtual void startIRStream()
starts the IR stream.
xn::DepthGenerator depth_generator_
Depth generator object.
bool isSynchronized() const noexcept
xn::Context & context_
context to OpenNI driver
bool hasDepthStream() const noexcept
virtual bool isDepthStreamRunning() const noexcept
void setDepthOutputFormat(const DepthMode &depth_mode=OpenNI_12_bit_depth)
Set the depth output format.
CallbackHandle registerIRCallback(const IRImageCallbackFunction &callback, void *cookie=nullptr) noexcept
registers a callback function of std::function type for the IR stream with an optional user defined p...
const XnMapOutputMode & getDefaultImageMode() const noexcept
returns the default image mode, which is simply the first entry in the list of modes
virtual bool isIRStreamRunning() const noexcept
const XnMapOutputMode & getDefaultDepthMode() const noexcept
returns the default depth mode, which is simply the first entry in the list of modes
void IRDataThreadFunction()
const char * getVendorName() const noexcept
XnMapOutputMode getIROutputMode() const
std::vector< XnMapOutputMode > available_image_modes_
bool hasImageStream() const noexcept
virtual bool isImageResizeSupported(unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const noexcept=0
bool unregisterIRCallback(const CallbackHandle &callbackHandle) noexcept
unregisters a callback function.
virtual bool isImageStreamRunning() const noexcept
OpenNIDevice(xn::Context &context, const xn::NodeInfo &device_node, const xn::NodeInfo &depth_node, const xn::NodeInfo &ir_node)
std::vector< XnMapOutputMode > available_depth_modes_
OpenNIDevice::CallbackHandle ir_callback_handle_counter_
bool isDepthRegistrationSupported() const noexcept
std::condition_variable image_condition_
virtual void startImageStream()
starts the image stream.
std::map< CallbackHandle, ActualDepthImageCallbackFunction > depth_callback_
void setImageOutputMode(const XnMapOutputMode &output_mode)
sets the output mode of the image stream
pcl::shared_ptr< const OpenNIDevice > ConstPtr
void ReadDeviceParametersFromSensorNode()
bool isDepthModeSupported(const XnMapOutputMode &output_mode) const noexcept
returns whether a given mode is natively supported by the device or not
void setRegistration(bool on_off)
bool isDepthRegistered() const noexcept
std::condition_variable depth_condition_
bool findCompatibleImageMode(const XnMapOutputMode &output_mode, XnMapOutputMode &mode) const noexcept
finds an image output mode that can be used to retrieve images in desired output mode.
std::thread image_thread_
virtual ~OpenNIDevice() noexcept
virtual destructor.
XnUInt64 no_sample_value_
the value for pixels without a valid disparity measurement
const char * getConnectionString() const noexcept
returns the connection string for current device, which has following format vendorID/productID@BusID...
virtual void stopIRStream()
stops the IR stream.
float getImageFocalLength(int output_x_resolution=0) const noexcept
returns the focal length for the color camera in pixels.
void setDepthOutputMode(const XnMapOutputMode &output_mode)
sets the output mode of the depth stream
void setIROutputMode(const XnMapOutputMode &output_mode)
sets the output mode of the IR stream
XnCallbackHandle depth_callback_handle_
Defines functions, macros and traits for allocating and using memory.
Defines all the PCL and non-PCL macros used.
XnFloat zero_plane_pixel_size_
XnUInt32 pixel_size_factor_
XnUInt32 device_max_shift_
XnFloat emitter_dcmos_distace_
XnUInt16 zero_plane_distance_
ShiftConversion()=default