Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
Public Member Functions | List of all members
rs::device Class Reference

Provides convenience methods relating to devices. More...

#include <rs.hpp>

Public Member Functions

const char * get_name () const
 Retrieves human-readable device model string. More...
 
const char * get_serial () const
 Retrieves unique serial number of device. More...
 
const char * get_usb_port_id () const
 Retrieves USB port number of device. More...
 
const char * get_firmware_version () const
 Retrieves version of firmware currently installed on device. More...
 
const char * get_info (camera_info info) const
 Retrieves camera-specific information such as versions of various components. More...
 
extrinsics get_extrinsics (stream from_stream, stream to_stream) const
 Retrieves extrinsic transformation between viewpoints of two different streams. More...
 
extrinsics get_motion_extrinsics_from (stream from_stream) const
 Retrieves extrinsic transformation between viewpoints of specific stream and motion module. More...
 
float get_depth_scale () const
 Retrieves mapping between units of depth image and meters. More...
 
bool supports_option (option option) const
 Determines if device allows specific option to be queried and set. More...
 
int get_stream_mode_count (stream stream) const
 Determines number of streaming modes available for given stream. More...
 
void get_stream_mode (stream stream, int index, int &width, int &height, format &format, int &framerate) const
 Determines properties of specific streaming mode. More...
 
void enable_stream (stream stream, int width, int height, format format, int framerate, output_buffer_format output_buffer_type=output_buffer_format::continous)
 Enables specific stream and requests specific properties. More...
 
void enable_stream (stream stream, preset preset)
 Enables specific stream and requests properties using preset. More...
 
void disable_stream (stream stream)
 Disables specific stream. More...
 
bool is_stream_enabled (stream stream) const
 Determines if specific stream is enabled. More...
 
int get_stream_width (stream stream) const
 Retrieves width, in pixels, of a specific stream, equivalent to the width field from the stream's intrinsic. More...
 
int get_stream_height (stream stream) const
 Retrieves height, in pixels, of a specific stream, equivalent to the height field from the stream's intrinsic. More...
 
format get_stream_format (stream stream) const
 Retrieves pixel format for specific stream. More...
 
int get_stream_framerate (stream stream) const
 Retrieves frame rate for specific stream. More...
 
intrinsics get_stream_intrinsics (stream stream) const
 Retrieves intrinsic camera parameters for specific stream. More...
 
motion_intrinsics get_motion_intrinsics () const
 Retrieves intrinsic camera parameters for motion module. More...
 
void set_frame_callback (rs::stream stream, std::function< void(frame)> frame_handler)
 Sets callback for frame arrival event. More...
 
void enable_motion_tracking (std::function< void(motion_data)> motion_handler, std::function< void(timestamp_data)> timestamp_handler)
 Sets callback for motion module event. More...
 
void enable_motion_tracking (std::function< void(motion_data)> motion_handler)
 Sets the callback for motion module event. More...
 
void disable_motion_tracking (void)
 Disables events polling. More...
 
int is_motion_tracking_active ()
 Checks if data acquisition is active
More...
 
void start (rs::source source=rs::source::video)
 Begins streaming on all enabled streams for this device. More...
 
void stop (rs::source source=rs::source::video)
 Ends streaming on all streams for this device. More...
 
bool is_streaming () const
 Determines if device is currently streaming. More...
 
void get_option_range (option option, double &min, double &max, double &step)
 Retrieves available range of values of supported option. More...
 
void get_option_range (option option, double &min, double &max, double &step, double &def)
 Retrieves available range of values of supported option. More...
 
void get_options (const option *options, size_t count, double *values)
 Efficiently retrieves value of arbitrary number of options, using minimal hardware IO. More...
 
void set_options (const option *options, size_t count, const double *values)
 Efficiently sets value of arbitrary number of options, using minimal hardware IO. More...
 
double get_option (option option)
 Retrieves current value of single option. More...
 
const char * get_option_description (option option)
 Retrieves device-specific option description. More...
 
void set_option (option option, double value)
 Sets current value of single option. More...
 
void wait_for_frames ()
 Blocks until new frames are available. More...
 
bool poll_for_frames ()
 Checks if new frames are available, without blocking. More...
 
bool supports (capabilities capability) const
 Determines device capabilities. More...
 
bool supports (camera_info info_param) const
 Determines device capabilities. More...
 
double get_frame_timestamp (stream stream) const
 Retrieves time at which the latest frame on a stream was captured. More...
 
unsigned long long get_frame_number (stream stream) const
 Retrieves frame number. More...
 
const void * get_frame_data (stream stream) const
 Retrieves contents of latest frame on a stream. More...
 
void send_blob_to_device (rs::blob_type type, void *data, int size)
 Sends device-specific data to device. More...
 

Detailed Description

Provides convenience methods relating to devices.

Member Function Documentation

◆ disable_motion_tracking()

void rs::device::disable_motion_tracking ( void  )
inline

Disables events polling.

◆ disable_stream()

void rs::device::disable_stream ( stream  stream)
inline

Disables specific stream.

Parameters
[in]streamStream

◆ enable_motion_tracking() [1/2]

void rs::device::enable_motion_tracking ( std::function< void(motion_data)>  motion_handler)
inline

Sets the callback for motion module event.

The provided callback will be called the instant new motion event is available.

Parameters
[in]motion_handlerFrame callback to be invokes on every new motion event
Returns
Frame rate of the stream, in frames per second

◆ enable_motion_tracking() [2/2]

void rs::device::enable_motion_tracking ( std::function< void(motion_data)>  motion_handler,
std::function< void(timestamp_data)>  timestamp_handler 
)
inline

Sets callback for motion module event.

The provided callback will be called the instant new motion or timestamp event is available. Note:

The rs_enable_motion_tracking_cpp() method is responsible for activating the motion module on-board the device. One of the services it provides is to produce shared and high-resolution timestamps for all components that are connected to it. For Depth, IR, Color and Fisheye sensors, librealsense takes care of that and copies the timestamps on the relevant frames.

However, when you have an external device (such as a compass, magnetometer, light sensor, or other) and wish to synchronize it precisely with image and motion streams, you can connect that sensor to a GPIO that is available on some devices. Every time the sensor signals, you get a timestamp callback with a frame number, source ID, and a timestamp. This timestamp callback allows advanced users to synchronize compass events (presumably coming though I2C or some other method) with RealSense data.

Parameters
[in]motion_handlerFrame callback to be invoke on every new motion event
[in]timestamp_handlerFrame callback to be invoke on every new timestamp event (can be left-out)
Returns
Frame rate of the stream, in frames per second

◆ enable_stream() [1/2]

void rs::device::enable_stream ( stream  stream,
int  width,
int  height,
format  format,
int  framerate,
output_buffer_format  output_buffer_type = output_buffer_format::continous 
)
inline

Enables specific stream and requests specific properties.

Parameters
[in]streamStream
[in]widthDesired width of frame image in pixels, or 0 if any width is acceptable
[in]heightDesired height of frame image in pixels, or 0 if any height is acceptable
[in]formatPixel format of frame image, or ANY if any format is acceptable
[in]framerateNumber of frames that will be streamed per second, or 0 if any frame rate is acceptable
[in]output_buffer_typeoutput buffer format (continous in memory / native with pitch)

◆ enable_stream() [2/2]

void rs::device::enable_stream ( stream  stream,
preset  preset 
)
inline

Enables specific stream and requests properties using preset.

Parameters
[in]streamStream to enable
[in]presetPreset to use to enable the stream

◆ get_depth_scale()

float rs::device::get_depth_scale ( ) const
inline

Retrieves mapping between units of depth image and meters.

Returns
Depth in meters corresponding to a depth value of 1

◆ get_extrinsics()

extrinsics rs::device::get_extrinsics ( stream  from_stream,
stream  to_stream 
) const
inline

Retrieves extrinsic transformation between viewpoints of two different streams.

Parameters
[in]from_streamStream whose coordinate space to transform from
[in]to_streamStream whose coordinate space to transform to
Returns
Transformation between two streams

◆ get_firmware_version()

const char * rs::device::get_firmware_version ( ) const
inline

Retrieves version of firmware currently installed on device.

Returns
Firmware version string, in a format that is specific to device model

◆ get_frame_data()

const void * rs::device::get_frame_data ( stream  stream) const
inline

Retrieves contents of latest frame on a stream.

Parameters
[in]streamStream
Returns
Pointer to start of frame data

◆ get_frame_number()

unsigned long long rs::device::get_frame_number ( stream  stream) const
inline

Retrieves frame number.

Parameters
[in]streamStream of interest
Returns
Number of frame since device was started

◆ get_frame_timestamp()

double rs::device::get_frame_timestamp ( stream  stream) const
inline

Retrieves time at which the latest frame on a stream was captured.

Parameters
[in]streamStream of interest
Returns
Timestamp of frame, in milliseconds since the device was started

◆ get_info()

const char * rs::device::get_info ( camera_info  info) const
inline

Retrieves camera-specific information such as versions of various components.

Returns
Camera info string, in a format that is specific to device model

◆ get_motion_extrinsics_from()

extrinsics rs::device::get_motion_extrinsics_from ( stream  from_stream) const
inline

Retrieves extrinsic transformation between viewpoints of specific stream and motion module.

Parameters
[in]from_streamStream whose coordinate space to transform from
Returns
Transformation between specific stream and motion module

◆ get_motion_intrinsics()

motion_intrinsics rs::device::get_motion_intrinsics ( ) const
inline

Retrieves intrinsic camera parameters for motion module.

Returns
Intrinsic parameters

◆ get_name()

const char * rs::device::get_name ( ) const
inline

Retrieves human-readable device model string.

Returns
Model string, such as "Intel RealSense F200" or "Intel RealSense R200"

◆ get_option()

double rs::device::get_option ( option  option)
inline

Retrieves current value of single option.

Parameters
[in]optionOption
Returns
Option value

◆ get_option_description()

const char * rs::device::get_option_description ( option  option)
inline

Retrieves device-specific option description.

Parameters
[in]optionOption
Returns
Option value

◆ get_option_range() [1/2]

void rs::device::get_option_range ( option  option,
double &  min,
double &  max,
double &  step 
)
inline

Retrieves available range of values of supported option.

Parameters
[in]optionOption
[out]minMinimum value that is acceptable for this option
[out]maxMaximum value that is acceptable for this option
[out]stepGranularity of options that accept discrete values, or zero if the option accepts continuous values

◆ get_option_range() [2/2]

void rs::device::get_option_range ( option  option,
double &  min,
double &  max,
double &  step,
double &  def 
)
inline

Retrieves available range of values of supported option.

Parameters
[in]optionOption
[out]minMinimum value that is acceptable for this option
[out]maxMaximum value that is acceptable for this option
[out]stepGranularity of options that accept discrete values, or zero if the option accepts continuous values
[out]defDefault value of the option

◆ get_options()

void rs::device::get_options ( const option options,
size_t  count,
double *  values 
)
inline

Efficiently retrieves value of arbitrary number of options, using minimal hardware IO.

Parameters
[in]optionsArray of options that should be queried
[in]countLength of options and values arrays
[out]valuesArray that receives the values of the queried options

◆ get_serial()

const char * rs::device::get_serial ( ) const
inline

Retrieves unique serial number of device.

Returns
Serial number, in a format specific to the device model

◆ get_stream_format()

format rs::device::get_stream_format ( stream  stream) const
inline

Retrieves pixel format for specific stream.

Parameters
[in]streamStream
Returns
Pixel format of the stream

◆ get_stream_framerate()

int rs::device::get_stream_framerate ( stream  stream) const
inline

Retrieves frame rate for specific stream.

Parameters
[in]streamStream
Returns
Frame rate of the stream, in frames per second

◆ get_stream_height()

int rs::device::get_stream_height ( stream  stream) const
inline

Retrieves height, in pixels, of a specific stream, equivalent to the height field from the stream's intrinsic.

Parameters
[in]streamStream
Returns
Height, in pixels of images from this stream

◆ get_stream_intrinsics()

intrinsics rs::device::get_stream_intrinsics ( stream  stream) const
inline

Retrieves intrinsic camera parameters for specific stream.

Parameters
[in]streamStream
Returns
Intrinsic parameters of the stream

◆ get_stream_mode()

void rs::device::get_stream_mode ( stream  stream,
int  index,
int &  width,
int &  height,
format format,
int &  framerate 
) const
inline

Determines properties of specific streaming mode.

Parameters
[in]streamStream whose mode will be queried
[in]indexZero-based index of streaming mode
[out]widthWidth of a frame image in pixels
[out]heightHeight of a frame image in pixels
[out]formatPixel format of a frame image
[out]framerateNumber of frames that will be streamed per second

◆ get_stream_mode_count()

int rs::device::get_stream_mode_count ( stream  stream) const
inline

Determines number of streaming modes available for given stream.

Parameters
[in]streamStream whose modes will be enumerated
Returns
Count of available modes

◆ get_stream_width()

int rs::device::get_stream_width ( stream  stream) const
inline

Retrieves width, in pixels, of a specific stream, equivalent to the width field from the stream's intrinsic.

Parameters
[in]streamStream
Returns
Width, in pixels of images from this stream

◆ get_usb_port_id()

const char * rs::device::get_usb_port_id ( ) const
inline

Retrieves USB port number of device.

Returns
USB port number, in a format that is specific to device model

◆ is_motion_tracking_active()

int rs::device::is_motion_tracking_active ( )
inline

Checks if data acquisition is active

◆ is_stream_enabled()

bool rs::device::is_stream_enabled ( stream  stream) const
inline

Determines if specific stream is enabled.

Parameters
[in]streamStream to check
Returns
true if the stream is currently enabled

◆ is_streaming()

bool rs::device::is_streaming ( ) const
inline

Determines if device is currently streaming.

Returns
true if device is currently streaming

◆ poll_for_frames()

bool rs::device::poll_for_frames ( )
inline

Checks if new frames are available, without blocking.

Returns
true if new frames are available; false if no new frames have arrived.

◆ send_blob_to_device()

void rs::device::send_blob_to_device ( rs::blob_type  type,
void *  data,
int  size 
)
inline

Sends device-specific data to device.

Parameters
[in]typeType of raw data to send to the device
[in]dataRaw data pointer to send
[in]sizeSize, in bytes of the raw data to send

◆ set_frame_callback()

void rs::device::set_frame_callback ( rs::stream  stream,
std::function< void(frame)>  frame_handler 
)
inline

Sets callback for frame arrival event.

The provided callback will be called the instant new frame of given stream becomes available once callback is set on certain stream type, frames of this type will no longer be available throuhg wait/poll methods (those two approaches are mutually exclusive) while wait/poll methods provide consistent set of syncronized frames at the expense of extra latency, set frame callbacks provides low latency solution with no syncronization

Parameters
[in]streamStream
[in]frame_handlerFrame callback to be invoked on every new frame
Returns
Frame rate of the stream, in frames per second

◆ set_option()

void rs::device::set_option ( option  option,
double  value 
)
inline

Sets current value of single option.

Parameters
[in]optionOption
[in]valueOption value

◆ set_options()

void rs::device::set_options ( const option options,
size_t  count,
const double *  values 
)
inline

Efficiently sets value of arbitrary number of options, using minimal hardware IO.

Parameters
[in]optionsArray of options that should be set
[in]countLength of options and values arrays
[in]valuesArray of values to which the options should be set

◆ start()

void rs::device::start ( rs::source  source = rs::source::video)
inline

Begins streaming on all enabled streams for this device.

◆ stop()

void rs::device::stop ( rs::source  source = rs::source::video)
inline

Ends streaming on all streams for this device.

◆ supports() [1/2]

bool rs::device::supports ( camera_info  info_param) const
inline

Determines device capabilities.

Parameters
[in]info_paramCapability to check for support
Returns
true if device has this capability

◆ supports() [2/2]

bool rs::device::supports ( capabilities  capability) const
inline

Determines device capabilities.

Parameters
[in]capabilityCapability to check
Returns
true if device has this capability

◆ supports_option()

bool rs::device::supports_option ( option  option) const
inline

Determines if device allows specific option to be queried and set.

Parameters
[in]optionOption to check
Returns
true if the option can be queried and set

◆ wait_for_frames()

void rs::device::wait_for_frames ( )
inline

Blocks until new frames are available.


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