19 const char *
function;
26 template<
class T>
void stream_args(std::ostream & out,
const char *
names,
const T & last) { out << names <<
':' << last; }
27 template<
class T,
class... U>
void stream_args(std::ostream & out,
const char *
names,
const T &
first,
const U &... rest)
29 while(*names && *names !=
',') out << *names++;
30 out <<
':' << first <<
", ";
31 while(*names && (*names ==
',' || isspace(*names))) ++
names;
38 catch (
const std::exception &
e) {
if (error) *error =
new rs_error {e.what(),
name, move(args)}; }
39 catch (...) {
if (error) *error =
new rs_error {
"unknown error",
name, move(args)}; }
42 #define HANDLE_EXCEPTIONS_AND_RETURN(R, ...) catch(...) { std::ostringstream ss; rsimpl::stream_args(ss, #__VA_ARGS__, __VA_ARGS__); rsimpl::translate_exception(__FUNCTION__, ss.str(), error); return R; } 43 #define VALIDATE_NOT_NULL(ARG) if(!(ARG)) throw std::runtime_error("null pointer passed for argument \"" #ARG "\""); 44 #define VALIDATE_ENUM(ARG) if(!rsimpl::is_valid(ARG)) { std::ostringstream ss; ss << "bad enum value for argument \"" #ARG "\""; throw std::runtime_error(ss.str()); } 45 #define VALIDATE_RANGE(ARG, MIN, MAX) if((ARG) < (MIN) || (ARG) > (MAX)) { std::ostringstream ss; ss << "out of range value for argument \"" #ARG "\""; throw std::runtime_error(ss.str()); } 46 #define VALIDATE_LE(ARG, MAX) if((ARG) > (MAX)) { std::ostringstream ss; ss << "out of range value for argument \"" #ARG "\""; throw std::runtime_error(ss.str()); } 47 #define VALIDATE_NATIVE_STREAM(ARG) VALIDATE_ENUM(ARG); if(ARG >= RS_STREAM_NATIVE_COUNT) { std::ostringstream ss; ss << "argument \"" #ARG "\" must be a native stream"; throw std::runtime_error(ss.str()); } 51 return version / 10000;
55 return (version % 10000) / 100;
59 return (version % 100);
70 throw std::runtime_error(
rsimpl::to_string() <<
"API version mismatch: librealsense.so was compiled with API version " 72 <<
api_version_to_string(compiletime) <<
"! Make sure correct version of the library is installed (make install)");
81 if ((runtime_api_version < 10) || (api_version < 10))
84 if (api_version != runtime_api_version)
87 else if ((
major(runtime_api_version) == 1 &&
minor(runtime_api_version) <= 9)
88 || (
major(api_version) == 1 &&
minor(api_version) <= 9))
91 if (api_version != runtime_api_version)
97 if ((
major(api_version) !=
major(runtime_api_version))
98 || (
minor(api_version) !=
minor(runtime_api_version)))
116 return (
int)context->get_device_count();
124 return context->get_device(
index);
131 return device->get_name();
138 return device->get_serial();
145 return device->get_camera_info(info);
152 return device->get_usb_port_id();
159 return device->get_firmware_version();
169 *extrin = device->get_stream_interface(from).get_extrinsics_to(device->get_stream_interface(to));
178 *extrin = device->get_motion_extrinsics_from(from);
186 return device->supports_option(
option);
194 return device->get_stream_interface(
stream).get_mode_count();
245 device->disable_stream(
stream);
253 return device->get_stream_interface(
stream).is_enabled();
261 return device->get_stream_interface(
stream).get_intrinsics().width;
269 return device->get_stream_interface(
stream).get_intrinsics().height;
277 return device->get_stream_interface(
stream).get_format();
285 return device->get_stream_interface(
stream).get_framerate();
294 *intrin = device->get_stream_interface(
stream).get_intrinsics();
302 *intrinsic = device->get_motion_intrinsics();
311 device->set_stream_callback(
stream, on_frame, user);
320 device->set_stream_callback(
stream, callback);
346 device->enable_motion_tracking();
360 device->enable_motion_tracking();
362 device->set_timestamp_callback(ts_callback);
369 device->disable_motion_tracking();
370 device->set_motion_callback(
nullptr,
nullptr);
371 device->set_timestamp_callback(
nullptr,
nullptr);
379 return device->is_motion_tracking_active();
416 return device->is_capturing();
423 return device->get_depth_scale();
431 device->wait_all_streams();
438 return device->poll_all_streams();
446 return device->supports(capability);
454 return device->supports(info_param);
478 return device->get_stream_interface(
stream).get_frame_timestamp();
486 return device->get_stream_interface(
stream).get_frame_number();
494 return device->get_stream_interface(
stream).get_frame_data();
501 return frame_ref->get_frame_timestamp();
508 return frame_ref->get_frame_timestamp_domain();
515 return frame_ref->get_frame_data();
522 return frame_ref->get_frame_width();
529 return frame_ref->get_frame_height();
536 return frame_ref->get_frame_framerate();
543 return frame_ref->get_frame_stride();
551 return frame_ref->get_frame_bpp();
558 return frame_ref->get_frame_format();
565 return frame_ref->get_stream_type();
573 return frame->get_frame_number();
581 device->release_frame(frame);
641 device->get_option_range(
option, min ? *min :
x, max ? *max :
x, step ? *step :
x, def);
650 device->get_option_range(
option, min ? *min :
x, max ? *max :
x, step ? *step :
x, def ? *def :
x);
661 std::vector<double>
values;
662 for (
int i = 0; i <
count; ++i)
668 device->set_options(options,
count,
values.data());
708 return device->get_option_description(
option);
742 throw std::runtime_error(
"sending binary data to the device is only available when using physical device!");
void rs_set_device_option(rs_device *device, rs_option option, double value, rs_error **error)
Sets the current value of a single option.
const char * rs_get_stream_name(rs_stream stream, rs_error **error)
const char * rs_blob_type_to_string(rs_blob_type type)
void on_timestamp_event(rs::timestamp_data entry)
void(* rs_frame_callback_ptr)(rs_device *dev, rs_frame_ref *frame, void *user)
const char * rs_get_preset_name(rs_preset preset, rs_error **error)
const char * rs_timestamp_domain_to_string(rs_timestamp_domain info)
int rs_get_stream_width(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the width in pixels of a specific stream, equivalent to the width field from the stream's i...
const char * rs_get_device_info(const rs_device *device, rs_camera_info info, rs_error **error)
Retrieves camera specific information, such as versions of various internal componnents.
frame_metadata
Types of value provided from the device with each frame.
GLint GLint GLsizei GLsizei height
rs_blob_type
Proprietary formats for direct communication with device firmware.
int rs_get_stream_mode_count(const rs_device *device, rs_stream stream, rs_error **error)
Determines the number of streaming modes available for a given stream.
void motion_callback(rs_device *, rs_motion_data, void *)
void(* rs_motion_callback_ptr)(rs_device *, rs_motion_data, void *)
void rs_set_frame_callback_cpp(rs_device *device, rs_stream stream, rs_frame_callback *callback, rs_error **error)
Sets up a frame callback that is called immediately when an image is available, with no synchronizati...
void rs_send_blob_to_device(rs_device *device, rs_blob_type type, void *data, int size, rs_error **error)
Sends arbitrary binary data to the device.
GLsizei const GLchar *const * string
rs_format rs_get_detached_frame_format(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves frame format.
void rs_log_to_callback_cpp(rs_log_severity min_severity, rs_log_callback *callback, rs_error **error)
Starts logging to user-provided callback.
const char * rs_stream_to_string(rs_stream stream)
double rs_get_detached_frame_timestamp(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves timestamp from frame reference.
int rs_get_detached_frame_height(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves frame intrinsic height.
void rs_disable_stream(rs_device *device, rs_stream stream, rs_error **error)
Disables a specific stream.
void rs_stop_device(rs_device *device, rs_error **error)
Ends data acquisition for the specified source providers.
void(* rs_log_callback_ptr)(rs_log_severity min_severity, const char *message, void *user)
void rs_log_to_file(rs_log_severity min_severity, const char *file_path, rs_error **error)
Starts logging to file.
const char * rs_option_to_string(rs_option option)
void log_to_file(rs_log_severity min_severity, const char *file_path)
const char * rs_preset_to_string(rs_preset preset)
rs_option
Defines general configuration controls.
rs_output_buffer_format
Output buffer format: sets how librealsense works with frame memory.
void rs_set_device_options(rs_device *device, const rs_option options[], unsigned int count, const double values[], rs_error **error)
rs_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
void rs_get_device_option_range(rs_device *device, rs_option option, double *min, double *max, double *step, rs_error **error)
Retrieves the available range of values for a supported option.
void rs_disable_motion_tracking(rs_device *device, rs_error **error)
Disables motion-tracking handlers.
#define RS_API_PATCH_VERSION
unsigned long long rs_get_frame_number(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves frame number.
rs_device * rs_get_device(rs_context *context, int index, rs_error **error)
Retrieves connected device by index.
int rs_supports_frame_metadata(const rs_frame_ref *frame, rs_frame_metadata frame_metadata, rs_error **error)
Determines device metadata.
int rs_get_detached_framerate(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves frame intrinsic frame rate.
const char * rs_get_error_message(const rs_error *error)
Returns static pointer to error message.
void rs_release_frame(rs_device *device, rs_frame_ref *frame, rs_error **error)
Releases frame handle.
std::string api_version_to_string(int version)
void rs_stop_source(rs_device *device, rs_source source, rs_error **error)
Ends data acquisition for the specified source providers.
void stream_args(std::ostream &out, const char *names, const T &first, const U &...rest)
#define VALIDATE_ENUM(ARG)
const char * rs_distortion_to_string(rs_distortion distortion)
rs_stream rs_get_detached_frame_stream_type(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves frame stream type.
virtual void send_blob_to_device(rs_blob_type, void *, int)
void log_to_console(rs_log_severity min_severity)
GLuint GLuint GLsizei count
void rs_log_to_console(rs_log_severity min_severity, rs_error **error)
Starts logging to console.
rs_camera_info
Read-only strings that can be queried from the device.
void log_to_callback(rs_log_severity min_severity, rs_log_callback *callback)
Motion module intrinsics: includes accelerometer and gyroscope intrinsics structs of type rs_motion_d...
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
float rs_get_device_depth_scale(const rs_device *device, rs_error **error)
Retrieves mapping between the units of the depth image and meters.
#define RS_API_MINOR_VERSION
int rs_get_detached_frame_stride(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves frame stride, meaning the actual line width in memory in bytes (not the logical image width...
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * data
void rs_enable_stream_ex(rs_device *device, rs_stream stream, int width, int height, rs_format format, int framerate, rs_output_buffer_format output, rs_error **error)
Enables a specific stream and requests specific properties.
const char * rs_get_option_name(rs_option option, rs_error **error)
double rs_get_device_option(rs_device *device, rs_option option, rs_error **error)
Retrieves the current value of a single option.
double rs_get_frame_timestamp(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves time at which the latest frame on a stream was captured.
int rs_is_stream_enabled(const rs_device *device, rs_stream stream, rs_error **error)
Determines if a specific stream is enabled.
rs_format
Formats: defines how each stream can be encoded.
rs_timestamp_domain rs_get_detached_frame_timestamp_domain(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves timestamp domain from frame reference.
static void translate_exception(const char *name, std::string args, rs_error **error)
const char * rs_format_to_string(rs_format format)
int rs_get_api_version(rs_error **error)
Retrieves API version from the source code. Evaluate that the value is conformant to the established ...
const char * rs_frame_metadata_to_string(rs_frame_metadata md)
const char * rs_get_device_firmware_version(const rs_device *device, rs_error **error)
Retrieves the version of the firmware currently installed on the device.
void rs_wait_for_frames(rs_device *device, rs_error **error)
Blocks until new frames are available.
const char * rs_source_to_string(rs_source source)
void rs_free_error(rs_error *error)
Frees memory of an error object.
const char * rs_get_device_usb_port_id(const rs_device *device, rs_error **error)
Retrieves the USB port number of the device.
GLsizei const GLfloat * value
void rs_get_device_extrinsics(const rs_device *device, rs_stream from, rs_stream to, rs_extrinsics *extrin, rs_error **error)
Retrieves extrinsic transformation between the viewpoints of two different streams.
const char * rs_get_format_name(rs_format format, rs_error **error)
const char * rs_camera_info_to_string(rs_camera_info info)
void(* rs_timestamp_callback_ptr)(rs_device *, rs_timestamp_data, void *)
void rs_get_device_option_range_ex(rs_device *device, rs_option option, double *min, double *max, double *step, double *def, rs_error **error)
Retrieves the available range of values for a supported option.
void rs_start_source(rs_device *device, rs_source source, rs_error **error)
Begins streaming on all enabled streams for this device.
rs_source
Source: allows you to choose between available hardware subdevices.
int rs_get_device_count(const rs_context *context, rs_error **error)
Determines number of connected devices.
const char * rs_get_capabilities_name(rs_capabilities capability, rs_error **error)
typedef void(APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode
int rs_supports_camera_info(rs_device *device, rs_camera_info info_param, rs_error **error)
Returns true if given camera information parameter is supported by the device.
Cross-stream extrinsics: encode the topology describing how the different devices are connected...
#define VALIDATE_NATIVE_STREAM(ARG)
void rs_enable_motion_tracking_cpp(rs_device *device, rs_motion_callback *motion_callback, rs_timestamp_callback *ts_callback, rs_error **error)
Enables and configures motion-tracking data handlers.
const char * get_string(rs_stream value)
const void * rs_get_frame_data(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the contents of the latest frame on a stream.
int rs_supports(rs_device *device, rs_capabilities capability, rs_error **error)
Determines device capabilities.
rs_preset
Presets: general preferences that are translated by librealsense into concrete resolution and FPS...
const char * rs_get_device_name(const rs_device *device, rs_error **error)
Retrieves human-readable device model string.
GLenum GLsizei GLsizei GLint * values
int rs_device_supports_option(const rs_device *device, rs_option option, rs_error **error)
Determines if the device allows a specific option to be queried and set.
const char * rs_get_event_name(rs_event_source event, rs_error **error)
distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
const char * rs_get_distortion_name(rs_distortion distortion, rs_error **error)
rs_stream
Streams are different types of data provided by RealSense devices.
#define RS_API_MAJOR_VERSION
void rs_get_device_options(rs_device *device, const rs_option options[], unsigned int count, double values[], rs_error **error)
GLint GLint GLsizei width
const char * rs_get_failed_args(const rs_error *error)
Returns static pointer to arguments of a failing function in case of error.
GLuint const GLchar * name
double rs_get_detached_frame_metadata(const rs_frame_ref *frame, rs_frame_metadata frame_metadata, rs_error **error)
Retrieves metadata from a frame reference.
GLsizei GLsizei GLchar * source
void rs_get_stream_intrinsics(const rs_device *device, rs_stream stream, rs_intrinsics *intrin, rs_error **error)
Retrieves intrinsic camera parameters for a specific stream.
rs_log_severity
Severity of the librealsense logger.
rs_format rs_get_stream_format(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the pixel format for a specific stream.
void rs_enable_stream_preset(rs_device *device, rs_stream stream, rs_preset preset, rs_error **error)
Enables a specific stream and requests properties using a preset.
void rs_get_stream_mode(const rs_device *device, rs_stream stream, int index, int *width, int *height, rs_format *format, int *framerate, rs_error **error)
Determines the properties of a specific streaming mode.
void rs_get_motion_intrinsics(const rs_device *device, rs_motion_intrinsics *intrinsic, rs_error **error)
Retrieves intrinsic camera parameters for a motion module.
int rs_get_stream_framerate(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the frame rate for a specific stream.
rs_capabilities
Specifies various capabilities of a RealSense device.
static rs_context * acquire_instance()
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
void rs_start_device(rs_device *device, rs_error **error)
Begins streaming on all enabled streams for this device.
int rs_is_device_streaming(const rs_device *device, rs_error **error)
Determines if the device is currently streaming.
#define VALIDATE_LE(ARG, MAX)
int rs_get_detached_frame_width(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves frame intrinsic width in pixels.
rs_distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
void rs_get_motion_extrinsics_from(const rs_device *device, rs_stream from, rs_extrinsics *extrin, rs_error **error)
Retrieves extrinsic transformation between specific stream and the motion module. ...
void rs_enable_motion_tracking(rs_device *device, rs_motion_callback_ptr on_motion_event, void *motion_handler, rs_timestamp_callback_ptr on_timestamp_event, void *timestamp_handler, rs_error **error)
Enables and configures motion-tracking data handlers.
rs_frame_metadata
Types of value provided from the device with each frame.
void rs_set_frame_callback(rs_device *device, rs_stream stream, rs_frame_callback_ptr on_frame, void *user, rs_error **error)
Sets up a frame callback that is called immediately when an image is available, with no synchronizati...
int rs_is_motion_tracking_active(rs_device *device, rs_error **error)
Checks if data acquisition is active.
const char * rs_get_device_option_description(rs_device *device, rs_option option, rs_error **error)
Retrieves a static description of what a particular option does on given device.
const void * rs_get_detached_frame_data(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves data from frame reference.
void rs_log_to_callback(rs_log_severity min_severity, rs_log_callback_ptr on_log, void *user, rs_error **error)
Starts logging to user-provided callback (C version)
void rs_reset_device_options_to_default(rs_device *device, const rs_option *options, int count, rs_error **error)
Efficiently resets the value of an arbitrary number of options to default.
#define HANDLE_EXCEPTIONS_AND_RETURN(R,...)
const char * rs_get_device_serial(const rs_device *device, rs_error **error)
Retrieves unique serial number of the device.
unsigned long long rs_get_detached_frame_number(const rs_frame_ref *frame, rs_error **error)
Retrieves frame number from frame reference.
void on_motion_event(rs::motion_data entry)
const char * rs_event_to_string(rs_event_source event)
#define VALIDATE_NOT_NULL(ARG)
void report_version_mismatch(int runtime, int compiletime)
int rs_get_stream_height(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the height in pixels of a specific stream, equivalent to the height field from the stream's...
GLint GLint GLint GLint GLint x
rs_event_source
Source device that triggered a specific timestamp event from the motion module.
int rs_poll_for_frames(rs_device *device, rs_error **error)
Checks if new frames are available, without blocking.
void rs_delete_context(rs_context *context, rs_error **error)
Frees the relevant context object.
int rs_get_detached_frame_bpp(const rs_frame_ref *frame_ref, rs_error **error)
Retrieves frame bits per pixel.
#define VALIDATE_RANGE(ARG, MIN, MAX)
const char * rs_get_failed_function(const rs_error *error)
Returns static pointer to name of a failing function in case of error.
void rs_enable_stream(rs_device *device, rs_stream stream, int width, int height, rs_format format, int framerate, rs_error **error)
Enables a specific stream and requests specific properties.
GLuint GLuint GLsizei GLenum type
preset
Presets: general preferences that are translated by librealsense into concrete resolution and FPS...
rs_context * rs_create_context(int api_version, rs_error **error)
Creates RealSense context that is required for the rest of the API.
const char * rs_capabilities_to_string(rs_capabilities capability)
static void release_instance()