Point Cloud Library (PCL)  1.14.1-dev
List of all members | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
openni_wrapper::DeviceONI Class Reference

Concrete implementation of the interface OpenNIDevice for a virtual device playing back an ONI file. More...

#include <pcl/io/openni_camera/openni_device_oni.h>

+ Inheritance diagram for openni_wrapper::DeviceONI:
+ Collaboration diagram for openni_wrapper::DeviceONI:

Public Types

using Ptr = pcl::shared_ptr< DeviceONI >
 
using ConstPtr = pcl::shared_ptr< const DeviceONI >
 
- Public Types inherited from openni_wrapper::OpenNIDevice
enum  DepthMode { OpenNI_shift_values = 0 , OpenNI_12_bit_depth = 1 }
 
using Ptr = pcl::shared_ptr< OpenNIDevice >
 
using ConstPtr = pcl::shared_ptr< const OpenNIDevice >
 
using ImageCallbackFunction = std::function< void(Image::Ptr, void *cookie) >
 
using DepthImageCallbackFunction = std::function< void(DepthImage::Ptr, void *cookie) >
 
using IRImageCallbackFunction = std::function< void(IRImage::Ptr, void *cookie) >
 
using CallbackHandle = unsigned
 

Public Member Functions

 DeviceONI (xn::Context &context, const std::string &file_name, bool repeat=false, bool streaming=true)
 
 ~DeviceONI () noexcept override
 
void startImageStream () override
 starts the image stream. More...
 
void stopImageStream () override
 stops the image stream. More...
 
void startDepthStream () override
 starts the depth stream. More...
 
void stopDepthStream () override
 stops the depth stream. More...
 
void startIRStream () override
 starts the IR stream. More...
 
void stopIRStream () override
 stops the IR stream. More...
 
bool isImageStreamRunning () const noexcept override
 
bool isDepthStreamRunning () const noexcept override
 
bool isIRStreamRunning () const noexcept override
 
bool isImageResizeSupported (unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const noexcept override
 
bool trigger (int relative_offset=0)
 Trigger a new frame in the ONI stream. More...
 
bool isStreaming () const noexcept
 
bool hasDataLeft ()
 Check if there is any data left in the ONI file to process. More...
 
- Public Member Functions inherited from openni_wrapper::OpenNIDevice
virtual ~OpenNIDevice () noexcept
 virtual destructor. More...
 
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. More...
 
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. More...
 
bool isImageModeSupported (const XnMapOutputMode &output_mode) const noexcept
 returns whether a given mode is natively supported by the device or not More...
 
bool isDepthModeSupported (const XnMapOutputMode &output_mode) const noexcept
 returns whether a given mode is natively supported by the device or not More...
 
const XnMapOutputMode & getDefaultImageMode () const noexcept
 returns the default image mode, which is simply the first entry in the list of modes More...
 
const XnMapOutputMode & getDefaultDepthMode () const noexcept
 returns the default depth mode, which is simply the first entry in the list of modes More...
 
const XnMapOutputMode & getDefaultIRMode () const noexcept
 returns the default IR mode, which is simply the first entry in the list of modes More...
 
void setImageOutputMode (const XnMapOutputMode &output_mode)
 sets the output mode of the image stream More...
 
void setDepthOutputMode (const XnMapOutputMode &output_mode)
 sets the output mode of the depth stream More...
 
void setIROutputMode (const XnMapOutputMode &output_mode)
 sets the output mode of the IR stream More...
 
XnMapOutputMode getImageOutputMode () const
 
XnMapOutputMode getDepthOutputMode () const
 
XnMapOutputMode getIROutputMode () const
 
void setDepthRegistration (bool on_off)
 set the depth stream registration on or off More...
 
bool isDepthRegistered () const noexcept
 
bool isDepthRegistrationSupported () const noexcept
 
void setSynchronization (bool on_off)
 set the hardware synchronization between Depth and RGB stream on or off. More...
 
bool isSynchronized () const noexcept
 
virtual bool isSynchronizationSupported () const noexcept
 
bool isDepthCropped () const
 
void setDepthCropping (unsigned x, unsigned y, unsigned width, unsigned height)
 turn on cropping for the depth stream. More...
 
bool isDepthCroppingSupported () const noexcept
 
float getImageFocalLength (int output_x_resolution=0) const noexcept
 returns the focal length for the color camera in pixels. More...
 
float getDepthFocalLength (int output_x_resolution=0) const noexcept
 returns the focal length for the IR camera in pixels. More...
 
float getBaseline () const noexcept
 
bool hasImageStream () const noexcept
 
bool hasDepthStream () const noexcept
 
bool hasIRStream () 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 defined parameter. More...
 
template<typename T >
CallbackHandle registerImageCallback (void(T::*callback)(Image::Ptr, void *cookie), T &instance, void *cookie=nullptr) noexcept
 registers a callback function for the image stream with an optional user defined parameter. More...
 
bool unregisterImageCallback (const CallbackHandle &callbackHandle) noexcept
 unregisters a callback function. More...
 
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 defined parameter. More...
 
template<typename T >
CallbackHandle registerDepthCallback (void(T::*callback)(DepthImage::Ptr, void *cookie), T &instance, void *cookie=nullptr) noexcept
 registers a callback function for the depth stream with an optional user defined parameter. More...
 
bool unregisterDepthCallback (const CallbackHandle &callbackHandle) noexcept
 unregisters a callback function. More...
 
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 parameter. More...
 
template<typename T >
CallbackHandle registerIRCallback (void(T::*callback)(IRImage::Ptr, void *cookie), T &instance, void *cookie=nullptr) noexcept
 registers a callback function for the IR stream with an optional user defined parameter. More...
 
bool unregisterIRCallback (const CallbackHandle &callbackHandle) noexcept
 unregisters a callback function. More...
 
const char * getSerialNumber () const noexcept
 returns the serial number for device. More...
 
const char * getConnectionString () const noexcept
 returns the connection string for current device, which has following format vendorID/productID@BusID/DeviceID. More...
 
const char * getVendorName () const noexcept
 
const char * getProductName () const noexcept
 
unsigned short getVendorID () const noexcept
 
unsigned short getProductID () const noexcept
 
unsigned char getBus () const noexcept
 
unsigned char getAddress () const noexcept
 
void setRGBFocalLength (float focal_length)
 Set the RGB image focal length. More...
 
void setDepthFocalLength (float focal_length)
 Set the depth image focal length. More...
 
void setDepthOutputFormat (const DepthMode &depth_mode=OpenNI_12_bit_depth)
 Set the depth output format. More...
 
XnUInt64 getDepthOutputFormat () const
 Get the depth output format as set by the user. More...
 
std::uint16_t shiftToDepth (std::uint16_t shift_value) const
 Convert shift to depth value. More...
 

Protected Member Functions

Image::Ptr getCurrentImage (pcl::shared_ptr< xn::ImageMetaData > image_meta_data) const noexcept override
 
void PlayerThreadFunction ()
 
- Protected Member Functions inherited from openni_wrapper::OpenNIDevice
 OpenNIDevice (xn::Context &context, const xn::NodeInfo &device_node, const xn::NodeInfo &image_node, const xn::NodeInfo &depth_node, const xn::NodeInfo &ir_node)
 
 OpenNIDevice (xn::Context &context, const xn::NodeInfo &device_node, const xn::NodeInfo &depth_node, const xn::NodeInfo &ir_node)
 
 OpenNIDevice (xn::Context &context)
 
void ImageDataThreadFunction ()
 
void DepthDataThreadFunction ()
 
void IRDataThreadFunction ()
 
void setRegistration (bool on_off)
 
void Init ()
 
void InitShiftToDepthConversion ()
 
void ReadDeviceParametersFromSensorNode ()
 

Static Protected Member Functions

static void __stdcall NewONIDepthDataAvailable (xn::ProductionNode &node, void *cookie) noexcept
 
static void __stdcall NewONIImageDataAvailable (xn::ProductionNode &node, void *cookie) noexcept
 
static void __stdcall NewONIIRDataAvailable (xn::ProductionNode &node, void *cookie) noexcept
 
- Static Protected Member Functions inherited from openni_wrapper::OpenNIDevice
static void __stdcall NewDepthDataAvailable (xn::ProductionNode &node, void *cookie) noexcept
 
static void __stdcall NewImageDataAvailable (xn::ProductionNode &node, void *cookie) noexcept
 
static void __stdcall NewIRDataAvailable (xn::ProductionNode &node, void *cookie) noexcept
 

Protected Attributes

xn::Player player_
 
std::thread player_thread_
 
std::mutex player_mutex_
 
std::condition_variable player_condition_
 
bool streaming_
 
bool depth_stream_running_ {false}
 
bool image_stream_running_ {false}
 
bool ir_stream_running_ {false}
 
- Protected Attributes inherited from openni_wrapper::OpenNIDevice
struct openni_wrapper::OpenNIDevice::ShiftConversion shift_conversion_parameters_
 
std::vector< std::uint16_t > shift_to_depth_table_
 
std::map< CallbackHandle, ActualImageCallbackFunctionimage_callback_
 
std::map< CallbackHandle, ActualDepthImageCallbackFunctiondepth_callback_
 
std::map< CallbackHandle, ActualIRImageCallbackFunctionir_callback_
 
std::vector< XnMapOutputMode > available_image_modes_
 
std::vector< XnMapOutputMode > available_depth_modes_
 
xn::Context & context_
 context to OpenNI driver More...
 
xn::NodeInfo device_node_info_
 node object for current device More...
 
xn::DepthGenerator depth_generator_
 Depth generator object. More...
 
xn::ImageGenerator image_generator_
 Image generator object. More...
 
xn::IRGenerator ir_generator_
 IR generator object. More...
 
XnCallbackHandle depth_callback_handle_
 
XnCallbackHandle image_callback_handle_
 
XnCallbackHandle ir_callback_handle_
 
float depth_focal_length_SXGA_
 focal length for IR camera producing depth information in native SXGA mode More...
 
float baseline_
 distance between the projector and the IR camera More...
 
float rgb_focal_length_SXGA_
 focal length for regular camera producing color images in native SXGA mode More...
 
XnUInt64 shadow_value_
 the value for shadow (occluded pixels) More...
 
XnUInt64 no_sample_value_
 the value for pixels without a valid disparity measurement More...
 
OpenNIDevice::CallbackHandle image_callback_handle_counter_
 
OpenNIDevice::CallbackHandle depth_callback_handle_counter_
 
OpenNIDevice::CallbackHandle ir_callback_handle_counter_
 
bool quit_
 
std::mutex image_mutex_
 
std::mutex depth_mutex_
 
std::mutex ir_mutex_
 
std::condition_variable image_condition_
 
std::condition_variable depth_condition_
 
std::condition_variable ir_condition_
 
std::thread image_thread_
 
std::thread depth_thread_
 
std::thread ir_thread_
 

Friends

class OpenNIDriver
 

Additional Inherited Members

- Protected Types inherited from openni_wrapper::OpenNIDevice
using ActualImageCallbackFunction = std::function< void(Image::Ptr) >
 
using ActualDepthImageCallbackFunction = std::function< void(DepthImage::Ptr) >
 
using ActualIRImageCallbackFunction = std::function< void(IRImage::Ptr) >
 

Detailed Description

Concrete implementation of the interface OpenNIDevice for a virtual device playing back an ONI file.

Author
Suat Gedikli
Date
19. june 2011

Definition at line 60 of file openni_device_oni.h.

Member Typedef Documentation

◆ ConstPtr

using openni_wrapper::DeviceONI::ConstPtr = pcl::shared_ptr<const DeviceONI>

Definition at line 66 of file openni_device_oni.h.

◆ Ptr

using openni_wrapper::DeviceONI::Ptr = pcl::shared_ptr<DeviceONI>

Definition at line 65 of file openni_device_oni.h.

Constructor & Destructor Documentation

◆ DeviceONI()

openni_wrapper::DeviceONI::DeviceONI ( xn::Context &  context,
const std::string &  file_name,
bool  repeat = false,
bool  streaming = true 
)

◆ ~DeviceONI()

openni_wrapper::DeviceONI::~DeviceONI ( )
overridenoexcept

Member Function Documentation

◆ getCurrentImage()

Image::Ptr openni_wrapper::DeviceONI::getCurrentImage ( pcl::shared_ptr< xn::ImageMetaData >  image_meta_data) const
overrideprotectedvirtualnoexcept

◆ hasDataLeft()

bool openni_wrapper::DeviceONI::hasDataLeft ( )
inline

Check if there is any data left in the ONI file to process.

Definition at line 96 of file openni_device_oni.h.

References player_.

◆ isDepthStreamRunning()

bool openni_wrapper::DeviceONI::isDepthStreamRunning ( ) const
overridevirtualnoexcept
Returns
true if the depth stream is running / started, false otherwise.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ isImageResizeSupported()

bool openni_wrapper::DeviceONI::isImageResizeSupported ( unsigned  input_width,
unsigned  input_height,
unsigned  output_width,
unsigned  output_height 
) const
overridevirtualnoexcept

◆ isImageStreamRunning()

bool openni_wrapper::DeviceONI::isImageStreamRunning ( ) const
overridevirtualnoexcept
Returns
true if the image stream is running / started, false otherwise.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ isIRStreamRunning()

bool openni_wrapper::DeviceONI::isIRStreamRunning ( ) const
overridevirtualnoexcept
Returns
true if the IR stream is running / started, false otherwise.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ isStreaming()

bool openni_wrapper::DeviceONI::isStreaming ( ) const
noexcept

◆ NewONIDepthDataAvailable()

static void __stdcall openni_wrapper::DeviceONI::NewONIDepthDataAvailable ( xn::ProductionNode &  node,
void *  cookie 
)
staticprotectednoexcept

◆ NewONIImageDataAvailable()

static void __stdcall openni_wrapper::DeviceONI::NewONIImageDataAvailable ( xn::ProductionNode &  node,
void *  cookie 
)
staticprotectednoexcept

◆ NewONIIRDataAvailable()

static void __stdcall openni_wrapper::DeviceONI::NewONIIRDataAvailable ( xn::ProductionNode &  node,
void *  cookie 
)
staticprotectednoexcept

◆ PlayerThreadFunction()

void openni_wrapper::DeviceONI::PlayerThreadFunction ( )
protected

◆ startDepthStream()

void openni_wrapper::DeviceONI::startDepthStream ( )
overridevirtual

starts the depth stream.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ startImageStream()

void openni_wrapper::DeviceONI::startImageStream ( )
overridevirtual

starts the image stream.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ startIRStream()

void openni_wrapper::DeviceONI::startIRStream ( )
overridevirtual

starts the IR stream.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ stopDepthStream()

void openni_wrapper::DeviceONI::stopDepthStream ( )
overridevirtual

stops the depth stream.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ stopImageStream()

void openni_wrapper::DeviceONI::stopImageStream ( )
overridevirtual

stops the image stream.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ stopIRStream()

void openni_wrapper::DeviceONI::stopIRStream ( )
overridevirtual

stops the IR stream.

Reimplemented from openni_wrapper::OpenNIDevice.

◆ trigger()

bool openni_wrapper::DeviceONI::trigger ( int  relative_offset = 0)

Trigger a new frame in the ONI stream.

Parameters
[in]relative_offsetthe relative offset in case we want to seek in the file

Friends And Related Function Documentation

◆ OpenNIDriver

friend class OpenNIDriver
friend

Definition at line 62 of file openni_device_oni.h.

Member Data Documentation

◆ depth_stream_running_

bool openni_wrapper::DeviceONI::depth_stream_running_ {false}
protected

Definition at line 114 of file openni_device_oni.h.

◆ image_stream_running_

bool openni_wrapper::DeviceONI::image_stream_running_ {false}
protected

Definition at line 115 of file openni_device_oni.h.

◆ ir_stream_running_

bool openni_wrapper::DeviceONI::ir_stream_running_ {false}
protected

Definition at line 116 of file openni_device_oni.h.

◆ player_

xn::Player openni_wrapper::DeviceONI::player_
protected

Definition at line 109 of file openni_device_oni.h.

Referenced by hasDataLeft().

◆ player_condition_

std::condition_variable openni_wrapper::DeviceONI::player_condition_
protected

Definition at line 112 of file openni_device_oni.h.

◆ player_mutex_

std::mutex openni_wrapper::DeviceONI::player_mutex_
mutableprotected

Definition at line 111 of file openni_device_oni.h.

◆ player_thread_

std::thread openni_wrapper::DeviceONI::player_thread_
protected

Definition at line 110 of file openni_device_oni.h.

◆ streaming_

bool openni_wrapper::DeviceONI::streaming_
protected

Definition at line 113 of file openni_device_oni.h.


The documentation for this class was generated from the following file: