4 #ifndef LIBREALSENSE_RS2_DEVICE_HPP 5 #define LIBREALSENSE_RS2_DEVICE_HPP 16 class pipeline_profile;
29 std::shared_ptr<rs2_sensor_list> list(
37 std::vector<sensor> results;
38 for (
auto i = 0; i < size; i++)
40 std::shared_ptr<rs2_sensor> dev(
46 results.push_back(rs2_dev);
76 std::ostringstream os;
81 os <<
"[" << type <<
"] ";
87 os << type <<
" device";
89 os <<
"unknown device";
101 if (
auto t = s.as<T>())
return t;
103 throw rs2::error(
"Could not find requested sensor type!");
116 return is_supported > 0;
158 operator bool()
const 160 return _dev !=
nullptr;
162 const std::shared_ptr<rs2_device>&
get()
const 199 explicit operator std::shared_ptr<rs2_device>() {
return _dev; };
200 explicit device(std::shared_ptr<rs2_device> dev) :
_dev(dev) {}
207 std::shared_ptr<rs2_device>
_dev;
254 std::vector<uint8_t> results;
257 std::shared_ptr<const rs2_raw_data_buffer> list(
267 results.insert(results.begin(), start, start + size);
275 std::vector<uint8_t> results;
278 std::shared_ptr<const rs2_raw_data_buffer> list(
288 results.insert(results.begin(), start, start + size);
337 void update(
const std::vector<uint8_t>& fw_image)
const 347 void update(
const std::vector<uint8_t>& fw_image, T callback)
const 437 std::vector<uint8_t> results;
450 results.insert(results.begin(), start, start + size);
491 std::vector<uint8_t> results;
504 results.insert(results.begin(), start, start + size);
543 std::vector<uint8_t> results;
555 results.insert(results.begin(), start, start + size);
592 std::vector<uint8_t> results;
604 results.insert(results.begin(), start, start + size);
620 std::vector<uint8_t> results;
632 results.insert(results.begin(), start, start + size);
646 std::vector<uint8_t> results;
658 results.insert(results.begin(), start, start + size);
669 std::vector<uint8_t> results;
672 std::shared_ptr<const rs2_raw_data_buffer> list(
682 results.insert(results.begin(), start, start + size);
721 std::vector<uint8_t> result;
735 result.insert(result.begin(), start, start + size);
737 return std::string(result.begin(), result.end());
752 float* ratio,
float* angle)
const 754 std::vector<uint8_t> results;
757 std::shared_ptr<const rs2_raw_data_buffer> list(
758 rs2_run_focal_length_calibration_cpp(
_dev.get(), left.
get().get(), right.
get().get(), target_w, target_h, adjust_both_sides, ratio, angle,
nullptr, &e),
767 results.insert(results.begin(), start, start + size);
785 float* ratio,
float* angle, T callback)
const 787 std::vector<uint8_t> results;
790 std::shared_ptr<const rs2_raw_data_buffer> list(
801 results.insert(results.begin(), start, start + size);
818 float* health,
int health_size)
const 820 std::vector<uint8_t> results;
823 std::shared_ptr<const rs2_raw_data_buffer> list(
833 results.insert(results.begin(), start, start + size);
852 float* health,
int health_size, T callback)
const 854 std::vector<uint8_t> results;
857 std::shared_ptr<const rs2_raw_data_buffer> list(
868 results.insert(results.begin(), start, start + size);
882 float target_width,
float target_height)
const 886 target_width, target_height,
nullptr, &e);
903 float target_width,
float target_height, T callback)
const 944 template<
class callback >
986 template<
typename T >
1041 uint32_t param1 = 0,
1042 uint32_t param2 = 0,
1043 uint32_t param3 = 0,
1044 uint32_t param4 = 0,
1045 std::vector<uint8_t>
const & data = {})
const 1047 std::vector<uint8_t> results;
1051 (
void*)data.data(), (uint32_t)data.size(), &e);
1061 results.insert(results.begin(), start, start + size);
1068 std::vector<uint8_t> results;
1071 std::shared_ptr<const rs2_raw_data_buffer> list(
1082 results.insert(results.begin(), start, start + size);
1092 : _list(std::move(list)) {}
1097 operator std::vector<device>()
const 1099 std::vector<device> res;
1100 for (
auto&& dev : *
this) res.push_back(dev);
1114 _list = std::move(list);
1121 std::shared_ptr<rs2_device> dev(
1140 return std::move((*
this)[
size() - 1]);
1156 return _list[_index];
1160 return other._index != _index || &other._list != &_list;
1164 return !(*
this != other);
1190 operator std::shared_ptr<rs2_device_list>() {
return _list; };
1193 std::shared_ptr<rs2_device_list> _list;
1196 #endif // LIBREALSENSE_RS2_DEVICE_HPP Definition: rs_types.hpp:110
device operator*() const
Definition: rs_device.hpp:1154
void rs2_set_calibration_table(const rs2_device *device, const void *calibration, int calibration_size, rs2_error **error)
device back() const
Definition: rs_device.hpp:1138
int rs2_get_sensors_count(const rs2_sensor_list *info_list, 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
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)
Definition: rs_sensor.hpp:102
update_device()
Definition: rs_device.hpp:323
bool is() const
Definition: rs_device.hpp:183
Definition: rs_frame.hpp:345
struct rs2_raw_data_buffer rs2_raw_data_buffer
Definition: rs_types.h:231
int rs2_device_list_contains(const rs2_device_list *info_list, const rs2_device *device, rs2_error **error)
Definition: rs_types.h:193
device_list(std::shared_ptr< rs2_device_list > list)
Definition: rs_device.hpp:1091
std::vector< uint8_t > send_and_receive_raw_data(const std::vector< uint8_t > &input) const
Definition: rs_device.hpp:1066
std::vector< uint8_t > create_flash_backup() const
Definition: rs_device.hpp:252
void release() override
Definition: rs_device.hpp:224
rs2_calibration_type
Definition: rs_device.h:402
std::vector< sensor > query_sensors() const
Definition: rs_device.hpp:26
calibration_change_device()=default
std::vector< uint8_t > run_focal_length_calibration(rs2::frame_queue left, rs2::frame_queue right, float target_w, float target_h, int adjust_both_sides, float *ratio, float *angle, T callback) const
Definition: rs_device.hpp:784
auto_calibrated_device(device d)
Definition: rs_device.hpp:388
device()
Definition: rs_device.hpp:154
const char * get_info(rs2_camera_info info) const
Definition: rs_device.hpp:124
device & operator=(const device &dev)
Definition: rs_device.hpp:148
void rs2_register_calibration_change_callback_cpp(rs2_device *dev, rs2_calibration_change_callback *callback, 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)
Definition: rs_pipeline.hpp:18
bool operator==(const device_list_iterator &other) const
Definition: rs_device.hpp:1162
void update_unsigned(const std::vector< uint8_t > &image, int update_mode=RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
Definition: rs_device.hpp:303
void update(const std::vector< uint8_t > &fw_image) const
Definition: rs_device.hpp:337
const rs2_raw_data_buffer * rs2_get_calibration_table(const rs2_device *dev, rs2_error **error)
rs2_sensor * rs2_create_sensor(const rs2_sensor_list *list, int index, rs2_error **error)
calibrated_device(device d)
Definition: rs_device.hpp:360
Definition: rs_sensor.h:24
void set_calibration_config(const rs2_calibration_config &calib_config)
Definition: rs_device.hpp:933
void set_calibration_table(const calibration_table &calibration)
Definition: rs_device.hpp:691
Definition: rs_sensor.h:30
void update_unsigned(const std::vector< uint8_t > &image, T callback, int update_mode=RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
Definition: rs_device.hpp:312
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)
calibration_table process_calibration_frame(rs2::frame f, float *const health, int timeout_ms=5000) const
Definition: rs_device.hpp:644
const unsigned char * rs2_get_raw_data(const rs2_raw_data_buffer *buffer, rs2_error **error)
void rs2_write_calibration(const rs2_device *device, rs2_error **e)
rs2_device * rs2_create_device(const rs2_device_list *info_list, int index, rs2_error **error)
device_list & operator=(std::shared_ptr< rs2_device_list > list)
Definition: rs_device.hpp:1112
calibration_change_device(device d)
Definition: rs_device.hpp:967
Definition: rs_device.hpp:212
Definition: rs_context.hpp:11
Definition: rs_types.hpp:68
Definition: rs_sensor.h:23
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)
bool operator<(device const &other) const
Definition: rs_device.hpp:166
void rs2_delete_raw_data(const rs2_raw_data_buffer *buffer)
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)
calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, float *health, int timeout_ms=5000) const
Definition: rs_device.hpp:590
Definition: rs_context.hpp:96
void reset_to_factory_calibration()
Definition: rs_device.hpp:377
int rs2_get_raw_data_size(const rs2_raw_data_buffer *buffer, rs2_error **error)
Definition: rs_device.hpp:227
T as() const
Definition: rs_device.hpp:190
void rs2_get_calibration_config(rs2_device *device, rs2_calibration_config *calib_config, rs2_error **error)
void enter_update_state() const
Definition: rs_device.hpp:243
device_calibration(device d)
Definition: rs_device.hpp:1005
device_list_iterator begin() const
Definition: rs_device.hpp:1177
std::vector< uint8_t > calibration_table
Definition: rs_device.hpp:355
Definition: rs_device.hpp:1026
device operator[](uint32_t index) const
Definition: rs_device.hpp:1118
rs2_calibration_config get_calibration_config() const
Definition: rs_device.hpp:918
int rs2_supports_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)
#define RS2_UNSIGNED_UPDATE_MODE_UPDATE
Definition: rs_device.h:229
rs2_calibration_status
Definition: rs_device.h:414
void rs2_delete_sensor(rs2_sensor *sensor)
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
device front() const
Definition: rs_device.hpp:1137
Definition: rs_sensor.h:32
uint32_t size() const
Definition: rs_device.hpp:1129
void trigger_device_calibration(rs2_calibration_type type)
Definition: rs_device.hpp:1018
void hardware_reset()
Definition: rs_device.hpp:135
const std::shared_ptr< rs2_device > & get() const
Definition: rs_device.hpp:162
std::vector< uint8_t > run_uv_map_calibration(rs2::frame_queue left, rs2::frame_queue color, rs2::frame_queue depth, int py_px_only, float *health, int health_size) const
Definition: rs_device.hpp:817
void update(const std::vector< uint8_t > &fw_image, T callback) const
Definition: rs_device.hpp:347
std::shared_ptr< rs2_device > _dev
Definition: rs_device.hpp:207
std::vector< uint8_t > run_focal_length_calibration(rs2::frame_queue left, rs2::frame_queue right, float target_w, float target_h, int adjust_both_sides, float *ratio, float *angle) const
Definition: rs_device.hpp:751
Definition: rs_types.h:299
std::vector< uint8_t > create_flash_backup(T callback) const
Definition: rs_device.hpp:273
void rs2_hardware_reset(const rs2_device *device, rs2_error **error)
Definition: rs_types.h:175
Definition: rs_device.hpp:963
rs2_sensor_list * rs2_query_sensors(const rs2_device *device, rs2_error **error)
bool is_connected() const
Definition: rs_device.hpp:174
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)
calibration_table get_calibration_table()
Definition: rs_device.hpp:667
std::vector< uint8_t > build_command(uint32_t opcode, uint32_t param1=0, uint32_t param2=0, uint32_t param3=0, uint32_t param4=0, std::vector< uint8_t > const &data={}) const
Definition: rs_device.hpp:1040
void release() override
Definition: rs_device.hpp:960
void write_calibration() const
Definition: rs_device.hpp:367
update_device(device d)
Definition: rs_device.hpp:324
static void handle(rs2_error *e)
Definition: rs_types.hpp:162
calibration_table run_on_chip_calibration(std::string json_content, float *health, T callback, int timeout_ms=5000) const
Definition: rs_device.hpp:435
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)
device_calibration()=default
std::vector< uint8_t > run_uv_map_calibration(rs2::frame_queue left, rs2::frame_queue color, rs2::frame_queue depth, int py_px_only, float *health, int health_size, T callback) const
Definition: rs_device.hpp:851
calibration_change_callback(callback cb)
Definition: rs_device.hpp:950
rs2_calibration_config json_string_to_calibration_config(const std::string &json_str) const
Definition: rs_device.hpp:704
Definition: rs_device.hpp:945
const rs2_raw_data_buffer * rs2_create_flash_backup_cpp(const rs2_device *device, rs2_update_progress_callback *callback, rs2_error **error)
bool contains(const device &dev) const
Definition: rs_device.hpp:1104
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)
Definition: rs_types.h:179
Definition: rs_types.hpp:92
Definition: rs_types.h:139
calibration_table process_calibration_frame(rs2::frame f, float *const health, T callback, int timeout_ms=5000) const
Definition: rs_device.hpp:618
bool supports(rs2_camera_info info) const
Definition: rs_device.hpp:111
update_progress_callback(T callback)
Definition: rs_device.hpp:217
device & operator=(const std::shared_ptr< rs2_device > dev)
Definition: rs_device.hpp:142
device_list_iterator & operator++()
Definition: rs_device.hpp:1166
device_list()
Definition: rs_device.hpp:1094
Definition: rs_device.hpp:385
updatable()
Definition: rs_device.hpp:230
Definition: rs_device.hpp:1088
bool check_firmware_compatibility(const std::vector< uint8_t > &image) const
Definition: rs_device.hpp:294
Definition: rs_device.hpp:357
std::string calibration_config_to_json_string(const rs2_calibration_config &calib_config) const
Definition: rs_device.hpp:719
updatable(device d)
Definition: rs_device.hpp:231
void rs2_json_string_to_calibration_config(rs2_device *device, const char *json_str, rs2_calibration_config *calib_config, rs2_error **error)
void rs2_enter_update_state(const rs2_device *device, rs2_error **error)
Definition: rs_types.h:187
Definition: rs_context.hpp:234
bool operator!=(const device_list_iterator &other) const
Definition: rs_device.hpp:1158
Definition: rs_types.h:176
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)
std::string get_description() const
Definition: rs_device.hpp:74
void on_calibration_change(rs2_calibration_status status) noexcept override
Definition: rs_device.hpp:952
void rs2_delete_sensor_list(rs2_sensor_list *info_list)
Definition: rs_sensor.h:35
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)
Definition: rs_processing.hpp:134
void on_update_progress(const float progress) override
Definition: rs_device.hpp:219
struct rs2_device_list rs2_device_list
Definition: rs_types.h:237
debug_protocol(device d)
Definition: rs_device.hpp:1029
void rs2_set_calibration_config(rs2_device *device, rs2_calibration_config const *calib_config, rs2_error **error)
device_list_iterator end() const
Definition: rs_device.hpp:1181
void register_calibration_change_callback(T callback)
Definition: rs_device.hpp:987
Definition: rs_device.hpp:1001
struct rs2_error rs2_error
Definition: rs_types.h:229
Definition: rs_device.hpp:1143
float calculate_target_z(rs2::frame_queue queue1, rs2::frame_queue queue2, rs2::frame_queue queue3, float target_width, float target_height, T callback) const
Definition: rs_device.hpp:902
std::shared_ptr< rs2_frame_queue > get()
Definition: rs_processing.hpp:240
Definition: rs_device.hpp:19
float calculate_target_z(rs2::frame_queue queue1, rs2::frame_queue queue2, rs2::frame_queue queue3, float target_width, float target_height) const
Definition: rs_device.hpp:881
int rs2_get_device_count(const rs2_device_list *info_list, rs2_error **error)
const rs2_raw_data_buffer * rs2_calibration_config_to_json_string(rs2_device *device, rs2_calibration_config const *calib_config, rs2_error **error)
calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, float *health, T callback, int timeout_ms=5000) const
Definition: rs_device.hpp:541
rs2_frame * get() const
Definition: rs_frame.hpp:592
Definition: rs_device.hpp:320
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)
const rs2_device_list * get_list() const
Definition: rs_device.hpp:1185
T first() const
Definition: rs_device.hpp:97
virtual ~device()
Definition: rs_device.hpp:195
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)
calibration_table run_on_chip_calibration(std::string json_content, float *health, int timeout_ms=5000) const
Definition: rs_device.hpp:489
std::string get_type() const
Definition: rs_device.hpp:55
device(std::shared_ptr< rs2_device > dev)
Definition: rs_device.hpp:200
const char * rs2_get_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)