RealSense Cross Platform API
RealSense Cross-platform API
rs_device.h
Go to the documentation of this file.
1 /* License: Apache 2.0. See LICENSE file in root directory.
2  Copyright(c) 2017 RealSense, Inc. All Rights Reserved. */
3 
9 #ifndef LIBREALSENSE_RS2_DEVICE_H
10 #define LIBREALSENSE_RS2_DEVICE_H
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #include "rs_types.h"
17 #include "rs_sensor.h"
18 
25 int rs2_get_device_count(const rs2_device_list* info_list, rs2_error** error);
26 
32 
40 int rs2_device_list_contains(const rs2_device_list* info_list, const rs2_device* device, rs2_error** error);
41 
49 rs2_device* rs2_create_device(const rs2_device_list* info_list, int index, rs2_error** error);
50 
55 void rs2_delete_device(rs2_device* device);
56 
61 int rs2_device_is_connected( const rs2_device * device, rs2_error ** error );
62 
70 const char* rs2_get_device_info(const rs2_device* device, rs2_camera_info info, rs2_error** error);
71 
79 int rs2_supports_device_info(const rs2_device* device, rs2_camera_info info, rs2_error** error);
80 
87 void rs2_hardware_reset(const rs2_device * device, rs2_error ** error);
88 
93 int rs2_is_in_recovery_mode(const rs2_device* device, rs2_error** error);
94 
109 const rs2_raw_data_buffer* rs2_build_debug_protocol_command(rs2_device* device, unsigned opcode, unsigned param1, unsigned param2,
110  unsigned param3, unsigned param4, void* data, unsigned size_of_data, rs2_error** error);
111 
120 const rs2_raw_data_buffer* rs2_send_and_receive_raw_data(rs2_device* device, void* raw_data_to_send, unsigned size_of_raw_data_to_send, rs2_error** error);
121 
129 int rs2_is_device_extendable_to(const rs2_device* device, rs2_extension extension, rs2_error ** error);
130 
137 rs2_sensor_list* rs2_query_sensors(const rs2_device* device, rs2_error** error);
138 
145 void rs2_loopback_enable(const rs2_device* device, const char* from_file, rs2_error** error);
146 
152 void rs2_loopback_disable(const rs2_device* device, rs2_error** error);
153 
160 int rs2_loopback_is_enabled(const rs2_device* device, rs2_error** error);
161 
168 void rs2_connect_tm2_controller(const rs2_device* device, const unsigned char* mac_addr, rs2_error** error);
169 
176 void rs2_disconnect_tm2_controller(const rs2_device* device, int id, rs2_error** error);
177 
178 
184 void rs2_reset_to_factory_calibration(const rs2_device* device, rs2_error** e);
185 
191 void rs2_write_calibration(const rs2_device* device, rs2_error** e);
192 
202 void rs2_update_firmware_cpp(const rs2_device* device, const void* fw_image, int fw_image_size, rs2_update_progress_callback* callback, rs2_error** error);
203 
214 void rs2_update_firmware(const rs2_device* device, const void* fw_image, int fw_image_size, rs2_update_progress_callback_ptr callback, void* client_data, rs2_error** error);
215 
224 
233 const rs2_raw_data_buffer* rs2_create_flash_backup(const rs2_device* device, rs2_update_progress_callback_ptr callback, void* client_data, rs2_error** error);
234 
235 #define RS2_UNSIGNED_UPDATE_MODE_UPDATE 0
236 #define RS2_UNSIGNED_UPDATE_MODE_READ_ONLY 1
237 #define RS2_UNSIGNED_UPDATE_MODE_FULL 2
238 
250 void rs2_update_firmware_unsigned_cpp(const rs2_device* device, const void* fw_image, int fw_image_size, rs2_update_progress_callback* callback, int update_mode, rs2_error** error);
251 
260 int rs2_check_firmware_compatibility(const rs2_device* device, const void* fw_image, int fw_image_size, rs2_error** error);
261 
274 void rs2_update_firmware_unsigned(const rs2_device* device, const void* fw_image, int fw_image_size, rs2_update_progress_callback_ptr callback, void* client_data, int update_mode, rs2_error** error);
275 
281 void rs2_enter_update_state(const rs2_device* device, rs2_error** error);
282 
318 const rs2_raw_data_buffer* rs2_run_on_chip_calibration_cpp(rs2_device* device, const void* json_content, int content_size, float* health, rs2_update_progress_callback* progress_callback, int timeout_ms, rs2_error** error);
319 
358 const rs2_raw_data_buffer* rs2_run_on_chip_calibration(rs2_device* device, const void* json_content, int content_size, float* health, rs2_update_progress_callback_ptr callback, void* client_data, int timeout_ms, rs2_error** error);
359 
391 const rs2_raw_data_buffer* rs2_run_tare_calibration_cpp(rs2_device* dev, float ground_truth_mm, const void* json_content, int content_size, float* health, rs2_update_progress_callback* progress_callback, int timeout_ms, rs2_error** error);
392 
393 
401 const rs2_raw_data_buffer* rs2_process_calibration_frame(rs2_device* dev, const rs2_frame* f, float* const health, rs2_update_progress_callback* progress_callback, int timeout_ms, rs2_error** error);
402 
403 
409 {
416 
421 {
422  // Anything >= 0 is not an issue
423  RS2_CALIBRATION_TRIGGERED = 0, // AC triggered and is active; conditions are valid
424  RS2_CALIBRATION_SPECIAL_FRAME = 1, // Special frame received; expect a frame-drop!
425  RS2_CALIBRATION_STARTED = 2, // Have all frames in hand; starting processing
426  RS2_CALIBRATION_NOT_NEEDED = 3, // Finished; existing calibration within tolerances; nothing done!
427  RS2_CALIBRATION_SUCCESSFUL = 4, // Finished; have new calibration in-hand
428 
429  RS2_CALIBRATION_RETRY = -1, // Initiating retry (asked for a new special frame)
430  RS2_CALIBRATION_FAILED = -2, // Unexpected: exception, device removed, stream stopped, etc.
431  RS2_CALIBRATION_SCENE_INVALID = -3, // Scene was not good enough for calibration; will retry
432  RS2_CALIBRATION_BAD_RESULT = -4, // Calibration finished, but results aren't good; will retry
433  RS2_CALIBRATION_BAD_CONDITIONS = -5, // Trigger was attempted but conditions (temp/APD) were invalid (still inactive)
434 
440 
443 
452 
460 
468 
497 const rs2_raw_data_buffer* rs2_run_tare_calibration(rs2_device* dev, float ground_truth_mm, const void* json_content, int content_size, float* health, rs2_update_progress_callback_ptr callback, void* client_data, int timeout_ms, rs2_error** error);
498 
504 
509 void rs2_set_calibration_table(const rs2_device* device, const void* calibration, int calibration_size, rs2_error** error);
510 
511 /* Serialize JSON content, returns ASCII-serialized JSON string on success. otherwise nullptr */
513 
514 /* Load JSON and apply advanced-mode controls */
515 void rs2_load_json(rs2_device* dev, const void* json_content, unsigned content_size, rs2_error** error);
516 
530 const rs2_raw_data_buffer* rs2_run_focal_length_calibration_cpp(rs2_device* device, rs2_frame_queue* left_queue , rs2_frame_queue* right_queue, float target_width, float target_height, int adjust_both_sides,
531  float* ratio, float* angle, rs2_update_progress_callback * progress_callback, rs2_error** error);
532 
547 const rs2_raw_data_buffer* rs2_run_focal_length_calibration(rs2_device* device, rs2_frame_queue* left_queue, rs2_frame_queue* right_queue, float target_width, float target_height, int adjust_both_sides,
548  float* ratio, float* angle, rs2_update_progress_callback_ptr callback, void* client_data, rs2_error** error);
549 
562 const rs2_raw_data_buffer* rs2_run_uv_map_calibration_cpp(rs2_device* device, rs2_frame_queue* left_queue, rs2_frame_queue* color_queue, rs2_frame_queue* depth_queue, int py_px_only,
563  float * health, int health_size, rs2_update_progress_callback * progress_callback, rs2_error** error);
564 
578 const rs2_raw_data_buffer* rs2_run_uv_map_calibration(rs2_device* device, rs2_frame_queue* left_queue, rs2_frame_queue* color_queue, rs2_frame_queue* depth_queue,
579  int py_px_only, float* health, int health_size, rs2_update_progress_callback_ptr callback, void* client_data, rs2_error** error);
580 
591  float target_width, float target_height,
592  rs2_update_progress_callback* callback, rs2_error** error);
593 
604 float rs2_calculate_target_z(rs2_device* device, rs2_frame_queue* queue1, rs2_frame_queue* queue2, rs2_frame_queue* queue3,
605  float target_width, float target_height, rs2_update_progress_callback_ptr progress_callback, void* client_data, rs2_error** error);
606 
614 
621 void rs2_set_calibration_config(rs2_device* device, const char* calibration_config_json_str, rs2_error** error);
622 
623 #ifdef __cplusplus
624 }
625 #endif
626 #endif
void rs2_set_calibration_table(const rs2_device *device, const void *calibration, int calibration_size, rs2_error **error)
Definition: rs_device.h:429
float rs2_calculate_target_z(rs2_device *device, rs2_frame_queue *queue1, rs2_frame_queue *queue2, rs2_frame_queue *queue3, float target_width, float target_height, rs2_update_progress_callback_ptr progress_callback, void *client_data, rs2_error **error)
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
Definition: rs_sensor.h:22
Definition: rs_device.h:436
float rs2_calculate_target_z_cpp(rs2_device *device, rs2_frame_queue *queue1, rs2_frame_queue *queue2, rs2_frame_queue *queue3, float target_width, float target_height, rs2_update_progress_callback *callback, rs2_error **error)
struct rs2_raw_data_buffer rs2_raw_data_buffer
Definition: rs_types.h:278
int rs2_device_list_contains(const rs2_device_list *info_list, const rs2_device *device, rs2_error **error)
int rs2_loopback_is_enabled(const rs2_device *device, rs2_error **error)
void rs2_update_firmware_unsigned(const rs2_device *device, const void *fw_image, int fw_image_size, rs2_update_progress_callback_ptr callback, void *client_data, int update_mode, rs2_error **error)
Definition: rs_device.h:427
void rs2_update_firmware(const rs2_device *device, const void *fw_image, int fw_image_size, rs2_update_progress_callback_ptr callback, void *client_data, rs2_error **error)
rs2_calibration_type
Definition: rs_device.h:408
Definition: rs_device.h:411
Definition: rs_device.h:423
void rs2_register_calibration_change_callback_cpp(rs2_device *dev, rs2_calibration_change_callback *callback, rs2_error **error)
const rs2_raw_data_buffer * rs2_run_focal_length_calibration(rs2_device *device, rs2_frame_queue *left_queue, rs2_frame_queue *right_queue, float target_width, float target_height, int adjust_both_sides, float *ratio, float *angle, rs2_update_progress_callback_ptr callback, void *client_data, rs2_error **error)
int rs2_check_firmware_compatibility(const rs2_device *device, const void *fw_image, int fw_image_size, rs2_error **error)
void rs2_trigger_device_calibration(rs2_device *dev, rs2_calibration_type type, rs2_error **error)
const rs2_raw_data_buffer * rs2_run_on_chip_calibration(rs2_device *device, const void *json_content, int content_size, float *health, rs2_update_progress_callback_ptr callback, void *client_data, int timeout_ms, rs2_error **error)
Definition: rs_device.h:432
Definition: rs_device.h:437
struct rs2_frame_queue rs2_frame_queue
Definition: rs_types.h:280
const rs2_raw_data_buffer * rs2_get_calibration_table(const rs2_device *dev, rs2_error **error)
const rs2_raw_data_buffer * rs2_build_debug_protocol_command(rs2_device *device, unsigned opcode, unsigned param1, unsigned param2, unsigned param3, unsigned param4, void *data, unsigned size_of_data, rs2_error **error)
void rs2_delete_device(rs2_device *device)
void rs2_write_calibration(const rs2_device *device, rs2_error **e)
struct rs2_sensor_list rs2_sensor_list
Definition: rs_types.h:299
rs2_device * rs2_create_device(const rs2_device_list *info_list, int index, rs2_error **error)
const rs2_raw_data_buffer * rs2_run_uv_map_calibration(rs2_device *device, rs2_frame_queue *left_queue, rs2_frame_queue *color_queue, rs2_frame_queue *depth_queue, int py_px_only, float *health, int health_size, rs2_update_progress_callback_ptr callback, void *client_data, rs2_error **error)
Definition: rs_device.h:412
void rs2_load_json(rs2_device *dev, const void *json_content, unsigned content_size, rs2_error **error)
Definition: rs_device.h:426
Definition: rs_types.hpp:73
const rs2_raw_data_buffer * rs2_run_focal_length_calibration_cpp(rs2_device *device, rs2_frame_queue *left_queue, rs2_frame_queue *right_queue, float target_width, float target_height, int adjust_both_sides, float *ratio, float *angle, rs2_update_progress_callback *progress_callback, rs2_error **error)
const rs2_raw_data_buffer * rs2_run_tare_calibration(rs2_device *dev, float ground_truth_mm, const void *json_content, int content_size, float *health, rs2_update_progress_callback_ptr callback, void *client_data, int timeout_ms, rs2_error **error)
const rs2_raw_data_buffer * rs2_run_uv_map_calibration_cpp(rs2_device *device, rs2_frame_queue *left_queue, rs2_frame_queue *color_queue, rs2_frame_queue *depth_queue, int py_px_only, float *health, int health_size, rs2_update_progress_callback *progress_callback, rs2_error **error)
void(* rs2_update_progress_callback_ptr)(const float, void *)
Definition: rs_types.h:320
void rs2_connect_tm2_controller(const rs2_device *device, const unsigned char *mac_addr, rs2_error **error)
void rs2_loopback_enable(const rs2_device *device, const char *from_file, rs2_error **error)
rs2_raw_data_buffer * rs2_serialize_json(rs2_device *dev, rs2_error **error)
void rs2_disconnect_tm2_controller(const rs2_device *device, int id, rs2_error **error)
Exposes RealSense structs.
int rs2_supports_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)
Definition: rs_device.h:425
void rs2_register_calibration_change_callback(rs2_device *dev, rs2_calibration_change_callback_ptr callback, void *user, rs2_error **error)
rs2_calibration_status
Definition: rs_device.h:420
Definition: rs_device.h:433
const char * rs2_calibration_status_to_string(rs2_calibration_status)
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
const rs2_raw_data_buffer * rs2_get_calibration_config(rs2_device *device, rs2_error **error)
void rs2_hardware_reset(const rs2_device *device, rs2_error **error)
Exposes RealSense sensor functionality for C compilers.
rs2_sensor_list * rs2_query_sensors(const rs2_device *device, rs2_error **error)
void rs2_update_firmware_cpp(const rs2_device *device, const void *fw_image, int fw_image_size, rs2_update_progress_callback *callback, rs2_error **error)
Definition: rs_device.h:430
void rs2_reset_to_factory_calibration(const rs2_device *device, rs2_error **e)
int rs2_device_is_connected(const rs2_device *device, rs2_error **error)
Definition: rs_device.h:413
const rs2_raw_data_buffer * rs2_create_flash_backup_cpp(const rs2_device *device, rs2_update_progress_callback *callback, rs2_error **error)
const rs2_raw_data_buffer * rs2_send_and_receive_raw_data(rs2_device *device, void *raw_data_to_send, unsigned size_of_raw_data_to_send, rs2_error **error)
const rs2_raw_data_buffer * rs2_create_flash_backup(const rs2_device *device, rs2_update_progress_callback_ptr callback, void *client_data, rs2_error **error)
Definition: rs_types.hpp:97
int rs2_is_in_recovery_mode(const rs2_device *device, rs2_error **error)
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:137
Definition: rs_device.h:435
void rs2_enter_update_state(const rs2_device *device, rs2_error **error)
struct rs2_device rs2_device
Definition: rs_types.h:275
void(* rs2_calibration_change_callback_ptr)(rs2_calibration_status, void *arg)
Definition: rs_device.h:442
Definition: rs_device.h:410
void rs2_update_firmware_unsigned_cpp(const rs2_device *device, const void *fw_image, int fw_image_size, rs2_update_progress_callback *callback, int update_mode, rs2_error **error)
void rs2_set_calibration_config(rs2_device *device, const char *calibration_config_json_str, rs2_error **error)
const rs2_raw_data_buffer * rs2_process_calibration_frame(rs2_device *dev, const rs2_frame *f, float *const health, rs2_update_progress_callback *progress_callback, int timeout_ms, rs2_error **error)
struct rs2_device_list rs2_device_list
Definition: rs_types.h:284
Definition: rs_device.h:431
const char * rs2_calibration_type_to_string(rs2_calibration_type)
struct rs2_error rs2_error
Definition: rs_types.h:276
void rs2_loopback_disable(const rs2_device *device, rs2_error **error)
void rs2_delete_device_list(rs2_device_list *info_list)
Definition: rs_device.h:424
int rs2_get_device_count(const rs2_device_list *info_list, rs2_error **error)
const rs2_raw_data_buffer * rs2_run_on_chip_calibration_cpp(rs2_device *device, const void *json_content, int content_size, float *health, rs2_update_progress_callback *progress_callback, int timeout_ms, rs2_error **error)
struct rs2_frame rs2_frame
Definition: rs_types.h:279
const rs2_raw_data_buffer * rs2_run_tare_calibration_cpp(rs2_device *dev, float ground_truth_mm, const void *json_content, int content_size, float *health, rs2_update_progress_callback *progress_callback, int timeout_ms, rs2_error **error)
const char * rs2_get_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)