Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
Loading...
Searching...
No Matches
rs_device.hpp
Go to the documentation of this file.
1// License: Apache 2.0. See LICENSE file in root directory.
2// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3
4#ifndef LIBREALSENSE_RS2_DEVICE_HPP
5#define LIBREALSENSE_RS2_DEVICE_HPP
6
7#include "rs_types.hpp"
8#include "rs_sensor.hpp"
9#include <array>
10#include <cstring>
11
12namespace rs2
13{
14 class context;
15 class device_list;
16 class pipeline_profile;
17 class device_hub;
18
19 class device
20 {
21 public:
26 std::vector<sensor> query_sensors() const
27 {
28 rs2_error* e = nullptr;
29 std::shared_ptr<rs2_sensor_list> list(
30 rs2_query_sensors(_dev.get(), &e),
33
34 auto size = rs2_get_sensors_count(list.get(), &e);
36
37 std::vector<sensor> results;
38 for (auto i = 0; i < size; i++)
39 {
40 std::shared_ptr<rs2_sensor> dev(
41 rs2_create_sensor(list.get(), i, &e),
44
45 sensor rs2_dev(dev);
46 results.push_back(rs2_dev);
47 }
48
49 return results;
50 }
51
55 std::string get_type() const
56 {
58 return "USB";
60 {
61 std::string pid = get_info( RS2_CAMERA_INFO_PRODUCT_ID );
62 if( pid == "ABCD" ) // Specific for D457
63 return "GMSL";
64 return pid; // for DDS devices, this will be "DDS"
65 }
66 return {};
67 }
68
72 std::string get_description() const
73 {
74 std::ostringstream os;
75 auto type = get_type();
77 {
78 if( ! type.empty() )
79 os << "[" << type << "] ";
81 }
82 else
83 {
84 if( ! type.empty() )
85 os << type << " device";
86 else
87 os << "unknown device";
88 }
90 os << " s/n " << get_info( RS2_CAMERA_INFO_SERIAL_NUMBER );
91 return os.str();
92 }
93
94 template<class T>
95 T first() const
96 {
97 for (auto&& s : query_sensors())
98 {
99 if (auto t = s.as<T>()) return t;
100 }
101 throw rs2::error("Could not find requested sensor type!");
102 }
103
109 bool supports(rs2_camera_info info) const
110 {
111 rs2_error* e = nullptr;
112 auto is_supported = rs2_supports_device_info(_dev.get(), info, &e);
113 error::handle(e);
114 return is_supported > 0;
115 }
116
122 const char* get_info(rs2_camera_info info) const
123 {
124 rs2_error* e = nullptr;
125 auto result = rs2_get_device_info(_dev.get(), info, &e);
126 error::handle(e);
127 return result;
128 }
129
134 {
135 rs2_error* e = nullptr;
136 rs2_hardware_reset(_dev.get(), &e);
137 error::handle(e);
138 }
139
140 device& operator=(const std::shared_ptr<rs2_device> dev)
141 {
142 _dev.reset();
143 _dev = dev;
144 return *this;
145 }
147 {
148 *this = nullptr;
149 _dev = dev._dev;
150 return *this;
151 }
152 device() : _dev(nullptr) {}
153
154 // Note: this checks the validity of rs2::device (i.e., if it's connected to a realsense device), and does
155 // NOT reflect the current condition (connected/disconnected). Use is_connected() for that.
156 operator bool() const
157 {
158 return _dev != nullptr;
159 }
160 const std::shared_ptr<rs2_device>& get() const
161 {
162 return _dev;
163 }
164 bool operator<( device const & other ) const
165 {
166 // All RealSense cameras have an update-ID but not always a serial number
167 return std::strcmp( get_info( RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID ),
169 < 0;
170 }
171
172 bool is_connected() const
173 {
174 rs2_error * e = nullptr;
175 bool connected = rs2_device_is_connected( _dev.get(), &e );
176 error::handle( e );
177 return connected;
178 }
179
180 template<class T>
181 bool is() const
182 {
183 T extension(*this);
184 return extension;
185 }
186
187 template<class T>
188 T as() const
189 {
190 T extension(*this);
191 return extension;
192 }
193 virtual ~device()
194 {
195 }
196
197 explicit operator std::shared_ptr<rs2_device>() { return _dev; };
198 explicit device(std::shared_ptr<rs2_device> dev) : _dev(dev) {}
199 protected:
200 friend class rs2::context;
201 friend class rs2::device_list;
203 friend class rs2::device_hub;
204
205 std::shared_ptr<rs2_device> _dev;
206
207 };
208
209 template<class T>
211 {
212 T _callback;
213
214 public:
215 explicit update_progress_callback(T callback) : _callback(callback) {}
216
217 void on_update_progress(const float progress) override
218 {
219 _callback(progress);
220 }
221
222 void release() override { delete this; }
223 };
224
225 class updatable : public device
226 {
227 public:
230 : device(d.get())
231 {
232 rs2_error* e = nullptr;
234 {
235 _dev.reset();
236 }
237 error::handle(e);
238 }
239
240 // Move the device to update state, this will cause the updatable device to disconnect and reconnect as an update device.
242 {
243 rs2_error* e = nullptr;
244 rs2_enter_update_state(_dev.get(), &e);
245 error::handle(e);
246 }
247
248 // Create backup of camera flash memory. Such backup does not constitute valid firmware image, and cannot be
249 // loaded back to the device, but it does contain all calibration and device information."
250 std::vector<uint8_t> create_flash_backup() const
251 {
252 std::vector<uint8_t> results;
253
254 rs2_error* e = nullptr;
255 std::shared_ptr<const rs2_raw_data_buffer> list(
256 rs2_create_flash_backup_cpp(_dev.get(), nullptr, &e),
258 error::handle(e);
259
260 auto size = rs2_get_raw_data_size(list.get(), &e);
261 error::handle(e);
262
263 auto start = rs2_get_raw_data(list.get(), &e);
264
265 results.insert(results.begin(), start, start + size);
266
267 return results;
268 }
269
270 template<class T>
271 std::vector<uint8_t> create_flash_backup(T callback) const
272 {
273 std::vector<uint8_t> results;
274
275 rs2_error* e = nullptr;
276 std::shared_ptr<const rs2_raw_data_buffer> list(
277 rs2_create_flash_backup_cpp(_dev.get(), new update_progress_callback<T>(std::move(callback)), &e),
279 error::handle(e);
280
281 auto size = rs2_get_raw_data_size(list.get(), &e);
282 error::handle(e);
283
284 auto start = rs2_get_raw_data(list.get(), &e);
285
286 results.insert(results.begin(), start, start + size);
287
288 return results;
289 }
290
291 // check firmware compatibility with SKU
292 bool check_firmware_compatibility(const std::vector<uint8_t>& image) const
293 {
294 rs2_error* e = nullptr;
295 auto res = !!rs2_check_firmware_compatibility(_dev.get(), image.data(), (int)image.size(), &e);
296 error::handle(e);
297 return res;
298 }
299
300 // Update an updatable device to the provided unsigned firmware. This call is executed on the caller's thread.
301 void update_unsigned(const std::vector<uint8_t>& image, int update_mode = RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
302 {
303 rs2_error* e = nullptr;
304 rs2_update_firmware_unsigned_cpp(_dev.get(), image.data(), (int)image.size(), nullptr, update_mode, &e);
305 error::handle(e);
306 }
307
308 // Update an updatable device to the provided unsigned firmware. This call is executed on the caller's thread and it supports progress notifications via the callback.
309 template<class T>
310 void update_unsigned(const std::vector<uint8_t>& image, T callback, int update_mode = RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
311 {
312 rs2_error* e = nullptr;
313 rs2_update_firmware_unsigned_cpp(_dev.get(), image.data(), int(image.size()), new update_progress_callback<T>(std::move(callback)), update_mode, &e);
314 error::handle(e);
315 }
316 };
317
318 class update_device : public device
319 {
320 public:
323 : device(d.get())
324 {
325 rs2_error* e = nullptr;
327 {
328 _dev.reset();
329 }
330 error::handle(e);
331 }
332
333 // Update an updatable device to the provided firmware.
334 // This call is executed on the caller's thread.
335 void update(const std::vector<uint8_t>& fw_image) const
336 {
337 rs2_error* e = nullptr;
338 rs2_update_firmware_cpp(_dev.get(), fw_image.data(), (int)fw_image.size(), NULL, &e);
339 error::handle(e);
340 }
341
342 // Update an updatable device to the provided firmware.
343 // This call is executed on the caller's thread and it supports progress notifications via the callback.
344 template<class T>
345 void update(const std::vector<uint8_t>& fw_image, T callback) const
346 {
347 rs2_error* e = nullptr;
348 rs2_update_firmware_cpp(_dev.get(), fw_image.data(), int(fw_image.size()), new update_progress_callback<T>(std::move(callback)), &e);
349 error::handle(e);
350 }
351 };
352
353 typedef std::vector<uint8_t> calibration_table;
354
356 {
357 public:
359 : device(d.get())
360 {}
361
365 void write_calibration() const
366 {
367 rs2_error* e = nullptr;
368 rs2_write_calibration(_dev.get(), &e);
369 error::handle(e);
370 }
371
376 {
377 rs2_error* e = nullptr;
379 error::handle(e);
380 }
381 };
382
384 {
385 public:
388 {
389 rs2_error* e = nullptr;
391 {
392 _dev.reset();
393 }
394 error::handle(e);
395 }
396
432 template<class T>
433 calibration_table run_on_chip_calibration(std::string json_content, float* health, T callback, int timeout_ms = 5000) const
434 {
435 std::vector<uint8_t> results;
436
437 rs2_error* e = nullptr;
438 auto buf = rs2_run_on_chip_calibration_cpp(_dev.get(), json_content.data(), int(json_content.size()), health, new update_progress_callback<T>(std::move(callback)), timeout_ms, &e);
439 error::handle(e);
440
441 std::shared_ptr<const rs2_raw_data_buffer> list(buf, rs2_delete_raw_data);
442
443 auto size = rs2_get_raw_data_size(list.get(), &e);
444 error::handle(e);
445
446 auto start = rs2_get_raw_data(list.get(), &e);
447
448 results.insert(results.begin(), start, start + size);
449
450 return results;
451 }
452
487 calibration_table run_on_chip_calibration(std::string json_content, float* health, int timeout_ms = 5000) const
488 {
489 std::vector<uint8_t> results;
490
491 rs2_error* e = nullptr;
492 const rs2_raw_data_buffer* buf = rs2_run_on_chip_calibration_cpp(_dev.get(), json_content.data(), static_cast< int >( json_content.size() ), health, nullptr, timeout_ms, &e);
493 error::handle(e);
494 std::shared_ptr<const rs2_raw_data_buffer> list(buf, rs2_delete_raw_data);
495
496 auto size = rs2_get_raw_data_size(list.get(), &e);
497 error::handle(e);
498
499 auto start = rs2_get_raw_data(list.get(), &e);
500 error::handle(e);
501
502 results.insert(results.begin(), start, start + size);
503
504 return results;
505 }
506
538 template<class T>
539 calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, float* health, T callback, int timeout_ms = 5000) const
540 {
541 std::vector<uint8_t> results;
542
543 rs2_error* e = nullptr;
544 const rs2_raw_data_buffer* buf = rs2_run_tare_calibration_cpp(_dev.get(), ground_truth_mm, json_content.data(), int(json_content.size()), health, new update_progress_callback<T>(std::move(callback)), timeout_ms, &e);
545 error::handle(e);
546 std::shared_ptr<const rs2_raw_data_buffer> list(buf, rs2_delete_raw_data);
547
548 auto size = rs2_get_raw_data_size(list.get(), &e);
549 error::handle(e);
550
551 auto start = rs2_get_raw_data(list.get(), &e);
552
553 results.insert(results.begin(), start, start + size);
554
555 return results;
556 }
557
588 calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, float * health, int timeout_ms = 5000) const
589 {
590 std::vector<uint8_t> results;
591
592 rs2_error* e = nullptr;
593 const rs2_raw_data_buffer* buf = rs2_run_tare_calibration_cpp(_dev.get(), ground_truth_mm, json_content.data(), static_cast< int >( json_content.size() ), health, nullptr, timeout_ms, &e);
594 error::handle(e);
595 std::shared_ptr<const rs2_raw_data_buffer> list(buf, rs2_delete_raw_data);
596
597 auto size = rs2_get_raw_data_size(list.get(), &e);
598 error::handle(e);
599
600 auto start = rs2_get_raw_data(list.get(), &e);
601
602 results.insert(results.begin(), start, start + size);
603
604 return results;
605 }
606
615 template<class T>
616 calibration_table process_calibration_frame(rs2::frame f, float* const health, T callback, int timeout_ms = 5000) const
617 {
618 std::vector<uint8_t> results;
619
620 rs2_error* e = nullptr;
621 const rs2_raw_data_buffer* buf = rs2_process_calibration_frame(_dev.get(), f.get(), health, new update_progress_callback<T>(std::move(callback)), timeout_ms, &e);
622 error::handle(e);
623 std::shared_ptr<const rs2_raw_data_buffer> list(buf, rs2_delete_raw_data);
624
625 auto size = rs2_get_raw_data_size(list.get(), &e);
626 error::handle(e);
627
628 auto start = rs2_get_raw_data(list.get(), &e);
629
630 results.insert(results.begin(), start, start + size);
631
632 return results;
633 }
634
642 calibration_table process_calibration_frame(rs2::frame f, float* const health, int timeout_ms = 5000) const
643 {
644 std::vector<uint8_t> results;
645
646 rs2_error* e = nullptr;
647 const rs2_raw_data_buffer* buf = rs2_process_calibration_frame(_dev.get(), f.get(), health, nullptr, timeout_ms, &e);
648 error::handle(e);
649 std::shared_ptr<const rs2_raw_data_buffer> list(buf, rs2_delete_raw_data);
650
651 auto size = rs2_get_raw_data_size(list.get(), &e);
652 error::handle(e);
653
654 auto start = rs2_get_raw_data(list.get(), &e);
655
656 results.insert(results.begin(), start, start + size);
657
658 return results;
659 }
660
666 {
667 std::vector<uint8_t> results;
668
669 rs2_error* e = nullptr;
670 std::shared_ptr<const rs2_raw_data_buffer> list(
673 error::handle(e);
674
675 auto size = rs2_get_raw_data_size(list.get(), &e);
676 error::handle(e);
677
678 auto start = rs2_get_raw_data(list.get(), &e);
679
680 results.insert(results.begin(), start, start + size);
681
682 return results;
683 }
684
690 {
691 rs2_error* e = nullptr;
692 rs2_set_calibration_table(_dev.get(), calibration.data(), static_cast< int >( calibration.size() ), &e);
693 error::handle(e);
694 }
695
707 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,
708 float* ratio, float* angle) const
709 {
710 std::vector<uint8_t> results;
711
712 rs2_error* e = nullptr;
713 std::shared_ptr<const rs2_raw_data_buffer> list(
714 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),
716 error::handle(e);
717
718 auto size = rs2_get_raw_data_size(list.get(), &e);
719 error::handle(e);
720
721 auto start = rs2_get_raw_data(list.get(), &e);
722
723 results.insert(results.begin(), start, start + size);
724
725 return results;
726 }
727
739 template<class T>
740 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,
741 float* ratio, float* angle, T callback) const
742 {
743 std::vector<uint8_t> results;
744
745 rs2_error* e = nullptr;
746 std::shared_ptr<const rs2_raw_data_buffer> list(
747 rs2_run_focal_length_calibration_cpp(_dev.get(), left.get().get(), right.get().get(), target_w, target_h, adjust_both_sides, ratio, angle,
748 new update_progress_callback<T>(std::move(callback)), &e),
750 error::handle(e);
751
752 auto size = rs2_get_raw_data_size(list.get(), &e);
753 error::handle(e);
754
755 auto start = rs2_get_raw_data(list.get(), &e);
756
757 results.insert(results.begin(), start, start + size);
758
759 return results;
760 }
761
773 std::vector<uint8_t> run_uv_map_calibration(rs2::frame_queue left, rs2::frame_queue color, rs2::frame_queue depth, int py_px_only,
774 float* health, int health_size) const
775 {
776 std::vector<uint8_t> results;
777
778 rs2_error* e = nullptr;
779 std::shared_ptr<const rs2_raw_data_buffer> list(
780 rs2_run_uv_map_calibration_cpp(_dev.get(), left.get().get(), color.get().get(), depth.get().get(), py_px_only, health, health_size, nullptr, &e),
782 error::handle(e);
783
784 auto size = rs2_get_raw_data_size(list.get(), &e);
785 error::handle(e);
786
787 auto start = rs2_get_raw_data(list.get(), &e);
788
789 results.insert(results.begin(), start, start + size);
790
791 return results;
792 }
793
806 template<class T>
807 std::vector<uint8_t> run_uv_map_calibration(rs2::frame_queue left, rs2::frame_queue color, rs2::frame_queue depth, int py_px_only,
808 float* health, int health_size, T callback) const
809 {
810 std::vector<uint8_t> results;
811
812 rs2_error* e = nullptr;
813 std::shared_ptr<const rs2_raw_data_buffer> list(
814 rs2_run_uv_map_calibration_cpp(_dev.get(), left.get().get(), color.get().get(), depth.get().get(), py_px_only, health, health_size,
815 new update_progress_callback<T>(std::move(callback)), &e),
817 error::handle(e);
818
819 auto size = rs2_get_raw_data_size(list.get(), &e);
820 error::handle(e);
821
822 auto start = rs2_get_raw_data(list.get(), &e);
823
824 results.insert(results.begin(), start, start + size);
825
826 return results;
827 }
828
838 float target_width, float target_height) const
839 {
840 rs2_error* e = nullptr;
841 float result = rs2_calculate_target_z_cpp(_dev.get(), queue1.get().get(), queue2.get().get(), queue3.get().get(),
842 target_width, target_height, nullptr, &e);
843 error::handle(e);
844
845 return result;
846 }
847
857 template<class T>
859 float target_width, float target_height, T callback) const
860 {
861 rs2_error* e = nullptr;
862 float result = rs2_calculate_target_z_cpp(_dev.get(), queue1.get().get(), queue2.get().get(), queue3.get().get(),
863 target_width, target_height, new update_progress_callback<T>(std::move(callback)), &e);
864 error::handle(e);
865
866 return result;
867 }
868 };
869
870 /*
871 Wrapper around any callback function that is given to calibration_change_callback.
872 */
873 template< class callback >
875 {
876 //using callback = std::function< void( rs2_calibration_status ) >;
877 callback _callback;
878 public:
879 calibration_change_callback( callback cb ) : _callback( cb ) {}
880
881 void on_calibration_change( rs2_calibration_status status ) noexcept override
882 {
883 try
884 {
885 _callback( status );
886 }
887 catch( ... ) { }
888 }
889 void release() override { delete this; }
890 };
891
893 {
894 public:
897 : device(d.get())
898 {
899 rs2_error* e = nullptr;
901 {
902 _dev.reset();
903 }
904 error::handle(e);
905 }
906
907 /*
908 Your callback should look like this, for example:
909 sensor.register_calibration_change_callback(
910 []( rs2_calibration_status ) noexcept
911 {
912 ...
913 })
914 */
915 template< typename T >
917 {
918 // We wrap the callback with an interface and pass it to librealsense, who will
919 // now manage its lifetime. Rather than deleting it, though, it will call its
920 // release() function, where (back in our context) it can be safely deleted:
921 rs2_error* e = nullptr;
923 _dev.get(),
924 new calibration_change_callback< T >(std::move(callback)),
925 &e);
926 error::handle(e);
927 }
928 };
929
931 {
932 public:
935 {
936 rs2_error* e = nullptr;
938 {
939 _dev = d.get();
940 }
941 error::handle( e );
942 }
943
948 {
949 rs2_error* e = nullptr;
950 rs2_trigger_device_calibration( _dev.get(), type, &e );
951 error::handle( e );
952 }
953 };
954
955 class debug_protocol : public device
956 {
957 public:
959 : device(d.get())
960 {
961 rs2_error* e = nullptr;
962 if(rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_DEBUG, &e) == 0 && !e)
963 {
964 _dev.reset();
965 }
966 error::handle(e);
967 }
968
969 std::vector<uint8_t> build_command(uint32_t opcode,
970 uint32_t param1 = 0,
971 uint32_t param2 = 0,
972 uint32_t param3 = 0,
973 uint32_t param4 = 0,
974 std::vector<uint8_t> const & data = {}) const
975 {
976 std::vector<uint8_t> results;
977
978 rs2_error* e = nullptr;
979 auto buffer = rs2_build_debug_protocol_command(_dev.get(), opcode, param1, param2, param3, param4,
980 (void*)data.data(), (uint32_t)data.size(), &e);
981 std::shared_ptr<const rs2_raw_data_buffer> list(buffer, rs2_delete_raw_data);
982 error::handle(e);
983
984 auto size = rs2_get_raw_data_size(list.get(), &e);
985 error::handle(e);
986
987 auto start = rs2_get_raw_data(list.get(), &e);
988 error::handle(e);
989
990 results.insert(results.begin(), start, start + size);
991
992 return results;
993 }
994
995 std::vector<uint8_t> send_and_receive_raw_data(const std::vector<uint8_t>& input) const
996 {
997 std::vector<uint8_t> results;
998
999 rs2_error* e = nullptr;
1000 std::shared_ptr<const rs2_raw_data_buffer> list(
1001 rs2_send_and_receive_raw_data(_dev.get(), (void*)input.data(), (uint32_t)input.size(), &e),
1003 error::handle(e);
1004
1005 auto size = rs2_get_raw_data_size(list.get(), &e);
1006 error::handle(e);
1007
1008 auto start = rs2_get_raw_data(list.get(), &e);
1009 error::handle(e);
1010
1011 results.insert(results.begin(), start, start + size);
1012
1013 return results;
1014 }
1015 };
1016
1018 {
1019 public:
1020 explicit device_list(std::shared_ptr<rs2_device_list> list)
1021 : _list(std::move(list)) {}
1022
1024 : _list(nullptr) {}
1025
1026 operator std::vector<device>() const
1027 {
1028 std::vector<device> res;
1029 for (auto&& dev : *this) res.push_back(dev);
1030 return res;
1031 }
1032
1033 bool contains(const device& dev) const
1034 {
1035 rs2_error* e = nullptr;
1036 auto res = !!(rs2_device_list_contains(_list.get(), dev.get().get(), &e));
1037 error::handle(e);
1038 return res;
1039 }
1040
1041 device_list& operator=(std::shared_ptr<rs2_device_list> list)
1042 {
1043 _list = std::move(list);
1044 return *this;
1045 }
1046
1047 device operator[](uint32_t index) const
1048 {
1049 rs2_error* e = nullptr;
1050 std::shared_ptr<rs2_device> dev(
1051 rs2_create_device(_list.get(), index, &e),
1053 error::handle(e);
1054
1055 return device(dev);
1056 }
1057
1058 uint32_t size() const
1059 {
1060 rs2_error* e = nullptr;
1061 auto size = rs2_get_device_count(_list.get(), &e);
1062 error::handle(e);
1063 return size;
1064 }
1065
1066 device front() const { return std::move((*this)[0]); }
1067 device back() const
1068 {
1069 return std::move((*this)[size() - 1]);
1070 }
1071
1073 {
1075 const device_list& device_list,
1076 uint32_t uint32_t)
1077 : _list(device_list),
1078 _index(uint32_t)
1079 {
1080 }
1081
1082 public:
1084 {
1085 return _list[_index];
1086 }
1087 bool operator!=(const device_list_iterator& other) const
1088 {
1089 return other._index != _index || &other._list != &_list;
1090 }
1091 bool operator==(const device_list_iterator& other) const
1092 {
1093 return !(*this != other);
1094 }
1096 {
1097 _index++;
1098 return *this;
1099 }
1100 private:
1101 friend device_list;
1102 const device_list& _list;
1103 uint32_t _index;
1104 };
1105
1107 {
1108 return device_list_iterator(*this, 0);
1109 }
1111 {
1112 return device_list_iterator(*this, size());
1113 }
1115 {
1116 return _list.get();
1117 }
1118
1119 operator std::shared_ptr<rs2_device_list>() { return _list; };
1120
1121 private:
1122 std::shared_ptr<rs2_device_list> _list;
1123 };
1124}
1125#endif // LIBREALSENSE_RS2_DEVICE_HPP
Definition rs_device.hpp:384
calibration_table process_calibration_frame(rs2::frame f, float *const health, T callback, int timeout_ms=5000) const
Definition rs_device.hpp:616
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:539
auto_calibrated_device(device d)
Definition rs_device.hpp:386
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:837
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:707
calibration_table get_calibration_table()
Definition rs_device.hpp:665
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:740
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:773
calibration_table run_on_chip_calibration(std::string json_content, float *health, int timeout_ms=5000) const
Definition rs_device.hpp:487
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:858
void set_calibration_table(const calibration_table &calibration)
Definition rs_device.hpp:689
calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, float *health, int timeout_ms=5000) const
Definition rs_device.hpp:588
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:807
calibration_table run_on_chip_calibration(std::string json_content, float *health, T callback, int timeout_ms=5000) const
Definition rs_device.hpp:433
calibration_table process_calibration_frame(rs2::frame f, float *const health, int timeout_ms=5000) const
Definition rs_device.hpp:642
Definition rs_device.hpp:356
calibrated_device(device d)
Definition rs_device.hpp:358
void write_calibration() const
Definition rs_device.hpp:365
void reset_to_factory_calibration()
Definition rs_device.hpp:375
Definition rs_device.hpp:875
calibration_change_callback(callback cb)
Definition rs_device.hpp:879
void on_calibration_change(rs2_calibration_status status) noexcept override
Definition rs_device.hpp:881
void release() override
Definition rs_device.hpp:889
Definition rs_device.hpp:893
calibration_change_device(device d)
Definition rs_device.hpp:896
void register_calibration_change_callback(T callback)
Definition rs_device.hpp:916
Definition rs_context.hpp:97
Definition rs_device.hpp:956
debug_protocol(device d)
Definition rs_device.hpp:958
std::vector< uint8_t > send_and_receive_raw_data(const std::vector< uint8_t > &input) const
Definition rs_device.hpp:995
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:969
Definition rs_device.hpp:931
void trigger_device_calibration(rs2_calibration_type type)
Definition rs_device.hpp:947
device_calibration(device d)
Definition rs_device.hpp:934
Definition rs_context.hpp:235
Definition rs_device.hpp:1073
device_list_iterator & operator++()
Definition rs_device.hpp:1095
device operator*() const
Definition rs_device.hpp:1083
bool operator==(const device_list_iterator &other) const
Definition rs_device.hpp:1091
bool operator!=(const device_list_iterator &other) const
Definition rs_device.hpp:1087
Definition rs_device.hpp:1018
device_list(std::shared_ptr< rs2_device_list > list)
Definition rs_device.hpp:1020
device back() const
Definition rs_device.hpp:1067
device operator[](uint32_t index) const
Definition rs_device.hpp:1047
bool contains(const device &dev) const
Definition rs_device.hpp:1033
device_list & operator=(std::shared_ptr< rs2_device_list > list)
Definition rs_device.hpp:1041
uint32_t size() const
Definition rs_device.hpp:1058
device_list_iterator end() const
Definition rs_device.hpp:1110
device front() const
Definition rs_device.hpp:1066
const rs2_device_list * get_list() const
Definition rs_device.hpp:1114
device_list_iterator begin() const
Definition rs_device.hpp:1106
device_list()
Definition rs_device.hpp:1023
Definition rs_device.hpp:20
bool is_connected() const
Definition rs_device.hpp:172
std::string get_description() const
Definition rs_device.hpp:72
device(std::shared_ptr< rs2_device > dev)
Definition rs_device.hpp:198
virtual ~device()
Definition rs_device.hpp:193
void hardware_reset()
Definition rs_device.hpp:133
T as() const
Definition rs_device.hpp:188
bool operator<(device const &other) const
Definition rs_device.hpp:164
T first() const
Definition rs_device.hpp:95
device & operator=(const std::shared_ptr< rs2_device > dev)
Definition rs_device.hpp:140
std::string get_type() const
Definition rs_device.hpp:55
device & operator=(const device &dev)
Definition rs_device.hpp:146
const std::shared_ptr< rs2_device > & get() const
Definition rs_device.hpp:160
bool is() const
Definition rs_device.hpp:181
std::shared_ptr< rs2_device > _dev
Definition rs_device.hpp:205
std::vector< sensor > query_sensors() const
Definition rs_device.hpp:26
const char * get_info(rs2_camera_info info) const
Definition rs_device.hpp:122
device()
Definition rs_device.hpp:152
bool supports(rs2_camera_info info) const
Definition rs_device.hpp:109
Definition rs_types.hpp:110
static void handle(rs2_error *e)
Definition rs_types.hpp:161
Definition rs_processing.hpp:135
std::shared_ptr< rs2_frame_queue > get()
Definition rs_processing.hpp:240
Definition rs_frame.hpp:346
rs2_frame * get() const
Definition rs_frame.hpp:592
Definition rs_pipeline.hpp:19
Definition rs_sensor.hpp:103
Definition rs_device.hpp:226
bool check_firmware_compatibility(const std::vector< uint8_t > &image) const
Definition rs_device.hpp:292
updatable()
Definition rs_device.hpp:228
std::vector< uint8_t > create_flash_backup() const
Definition rs_device.hpp:250
void enter_update_state() const
Definition rs_device.hpp:241
void update_unsigned(const std::vector< uint8_t > &image, int update_mode=RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
Definition rs_device.hpp:301
updatable(device d)
Definition rs_device.hpp:229
void update_unsigned(const std::vector< uint8_t > &image, T callback, int update_mode=RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
Definition rs_device.hpp:310
std::vector< uint8_t > create_flash_backup(T callback) const
Definition rs_device.hpp:271
Definition rs_device.hpp:319
update_device()
Definition rs_device.hpp:321
update_device(device d)
Definition rs_device.hpp:322
void update(const std::vector< uint8_t > &fw_image) const
Definition rs_device.hpp:335
void update(const std::vector< uint8_t > &fw_image, T callback) const
Definition rs_device.hpp:345
Definition rs_device.hpp:211
void release() override
Definition rs_device.hpp:222
update_progress_callback(T callback)
Definition rs_device.hpp:215
void on_update_progress(const float progress) override
Definition rs_device.hpp:217
Definition rs_processing_gl.hpp:13
std::vector< uint8_t > calibration_table
Definition rs_device.hpp:353
const unsigned char * rs2_get_raw_data(const rs2_raw_data_buffer *buffer, rs2_error **error)
int rs2_get_raw_data_size(const rs2_raw_data_buffer *buffer, rs2_error **error)
void rs2_delete_raw_data(const rs2_raw_data_buffer *buffer)
rs2_device * rs2_create_device(const rs2_device_list *info_list, int index, rs2_error **error)
int rs2_get_device_count(const rs2_device_list *info_list, 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)
int rs2_device_is_connected(const rs2_device *device, rs2_error **error)
rs2_calibration_type
Definition rs_device.h:403
void rs2_trigger_device_calibration(rs2_device *dev, rs2_calibration_type type, rs2_error **error)
void rs2_reset_to_factory_calibration(const rs2_device *device, rs2_error **e)
#define RS2_UNSIGNED_UPDATE_MODE_UPDATE
Definition rs_device.h:229
void rs2_set_calibration_table(const rs2_device *device, const void *calibration, int calibration_size, rs2_error **error)
void rs2_delete_device(rs2_device *device)
const rs2_raw_data_buffer * rs2_get_calibration_table(const rs2_device *dev, rs2_error **error)
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
void rs2_write_calibration(const rs2_device *device, rs2_error **e)
void rs2_enter_update_state(const rs2_device *device, rs2_error **error)
int rs2_check_firmware_compatibility(const rs2_device *device, const void *fw_image, int fw_image_size, 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)
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)
int rs2_supports_device_info(const rs2_device *device, rs2_camera_info info, 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)
const rs2_raw_data_buffer * rs2_create_flash_backup_cpp(const rs2_device *device, rs2_update_progress_callback *callback, rs2_error **error)
int rs2_device_list_contains(const rs2_device_list *info_list, const rs2_device *device, 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)
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_hardware_reset(const rs2_device *device, rs2_error **error)
rs2_sensor_list * rs2_query_sensors(const rs2_device *device, rs2_error **error)
const char * rs2_get_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)
void rs2_register_calibration_change_callback_cpp(rs2_device *dev, rs2_calibration_change_callback *callback, rs2_error **error)
rs2_calibration_status
Definition rs_device.h:415
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)
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)
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 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)
void rs2_delete_sensor_list(rs2_sensor_list *info_list)
void rs2_delete_sensor(rs2_sensor *sensor)
rs2_sensor * rs2_create_sensor(const rs2_sensor_list *list, int index, rs2_error **error)
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
@ RS2_CAMERA_INFO_PRODUCT_ID
Definition rs_sensor.h:30
@ RS2_CAMERA_INFO_SERIAL_NUMBER
Definition rs_sensor.h:24
@ RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR
Definition rs_sensor.h:32
@ RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID
Definition rs_sensor.h:35
@ RS2_CAMERA_INFO_NAME
Definition rs_sensor.h:23
@ RS2_EXTENSION_DEBUG
Definition rs_types.h:137
@ RS2_EXTENSION_UPDATABLE
Definition rs_types.h:173
@ RS2_EXTENSION_AUTO_CALIBRATED_DEVICE
Definition rs_types.h:177
@ RS2_EXTENSION_DEVICE_CALIBRATION
Definition rs_types.h:185
@ RS2_EXTENSION_UPDATE_DEVICE
Definition rs_types.h:174
@ RS2_EXTENSION_CALIBRATION_CHANGE_DEVICE
Definition rs_types.h:191
struct rs2_device_list rs2_device_list
Definition rs_types.h:235
struct rs2_error rs2_error
Definition rs_types.h:227
struct rs2_raw_data_buffer rs2_raw_data_buffer
Definition rs_types.h:229
Definition rs_types.hpp:68
Definition rs_types.hpp:92