RealSense Cross Platform API
RealSense Cross-platform API
Loading...
Searching...
No Matches
rs_frame.hpp
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
4#ifndef LIBREALSENSE_RS2_FRAME_HPP
5#define LIBREALSENSE_RS2_FRAME_HPP
6
7#include "rs_types.hpp"
8
9namespace rs2
10{
11 class frame_source;
12 class frame_queue;
13 class syncer;
14 class processing_block;
15 class pointcloud;
16 class sensor;
17 class frame;
18 class pipeline_profile;
19 class points;
21
23 {
24 public:
28 stream_profile() : _profile(nullptr) {}
29
34 int stream_index() const { return _index; }
39 rs2_stream stream_type() const { return _type; }
44 rs2_format format() const { return _format; }
49 int fps() const { return _framerate; }
54 int unique_id() const { return _uid; }
55
64 {
65 rs2_error* e = nullptr;
66 auto ref = rs2_clone_stream_profile(_profile, type, index, format, &e);
68 stream_profile res(ref);
69 res._clone = std::shared_ptr<rs2_stream_profile>(ref, [](rs2_stream_profile* r) { rs2_delete_stream_profile(r); });
70
71 return res;
72 }
73
79 bool operator==(const stream_profile& rhs)
80 {
81 return stream_index() == rhs.stream_index() &&
82 stream_type() == rhs.stream_type() &&
83 format() == rhs.format() &&
84 fps() == rhs.fps();
85 }
86
91 template<class T>
92 bool is() const
93 {
94 T extension(*this);
95 return extension;
96 }
97
102 template<class T>
103 T as() const
104 {
105 T extension(*this);
106 return extension;
107 }
108
113 std::string stream_name() const
114 {
115 rs2_error * e = nullptr;
116 std::string name = rs2_get_stream_profile_name( _profile, &e );
117
118 if( name.empty() )
119 {
120 std::stringstream ss;
122 if( stream_index() != 0 )
123 ss << " " << stream_index();
124 name = ss.str();
125 }
126
127 return name;
128 }
129
134 bool is_default() const { return _default; }
135
140 operator bool() const { return _profile != nullptr; }
141
146 const rs2_stream_profile* get() const { return _profile; }
147
158 {
159 rs2_error* e = nullptr;
160 rs2_extrinsics res;
161 rs2_get_extrinsics(get(), to.get(), &res, &e);
162 error::handle(e);
163 return res;
164 }
165
172 {
173 rs2_error* e = nullptr;
174 rs2_register_extrinsics(get(), to.get(), extrinsics, &e);
175 error::handle(e);
176 }
177
178 bool is_cloned() { return bool(_clone); }
179 explicit stream_profile(const rs2_stream_profile* profile) : _profile(profile)
180 {
181 rs2_error* e = nullptr;
183 error::handle(e);
184
186 error::handle(e);
187
188 }
189 operator const rs2_stream_profile*() { return _profile; }
190 explicit operator std::shared_ptr<rs2_stream_profile>() { return _clone; }
191
192 protected:
193 friend class rs2::sensor;
194 friend class rs2::frame;
197
199 std::shared_ptr<rs2_stream_profile> _clone;
200
201 int _index = 0;
202 int _uid = 0;
203 int _framerate = 0;
206
207 bool _default = false;
208 };
209
211 {
212 public:
214
220 : stream_profile(sp)
221 {
222 rs2_error* e = nullptr;
223 if (!sp || (rs2_stream_profile_is(sp.get(), RS2_EXTENSION_VIDEO_PROFILE, &e) == 0 && !e))
224 {
225 _profile = nullptr;
226 }
227 error::handle(e);
228
229 if (_profile)
230 {
231 rs2_get_video_stream_resolution(_profile, &_width, &_height, &e);
232 error::handle(e);
233 }
234 }
235
236 int width() const
237 {
238 return _width;
239 }
240
241 int height() const
242 {
243 return _height;
244 }
245
250 {
251 rs2_error* e = nullptr;
252 rs2_intrinsics intr;
254 error::handle(e);
255 return intr;
256 }
257
258 bool operator==(const video_stream_profile& other) const
259 {
260 return (((stream_profile&)*this)==other &&
261 width() == other.width() &&
262 height() == other.height());
263 }
264
266
277 stream_profile clone(rs2_stream type, int index, rs2_format format, int width, int height, const rs2_intrinsics& intr) const
278 {
279 rs2_error* e = nullptr;
280 auto ref = rs2_clone_video_stream_profile(_profile, type, index, format, width, height, &intr, &e);
281 error::handle(e);
282 stream_profile res(ref);
283 res._clone = std::shared_ptr<rs2_stream_profile>(ref, [](rs2_stream_profile* r) { rs2_delete_stream_profile(r); });
284
285 return res;
286 }
287 private:
288 int _width = 0;
289 int _height = 0;
290 };
291
292
294 {
295 public:
301 : stream_profile(sp)
302 {
303 rs2_error* e = nullptr;
304 if (!sp || (rs2_stream_profile_is(sp.get(), RS2_EXTENSION_MOTION_PROFILE, &e) == 0 && !e))
305 {
306 _profile = nullptr;
307 }
308 error::handle(e);
309 }
310
316 {
317 rs2_error* e = nullptr;
320 error::handle(e);
321 return intrin;
322 }
323 };
324
326 {
327 public:
333 : stream_profile(sp)
334 {
335 rs2_error* e = nullptr;
336 if (!sp || (rs2_stream_profile_is(sp.get(), RS2_EXTENSION_POSE_PROFILE, &e) == 0 && !e))
337 {
338 _profile = nullptr;
339 }
340 error::handle(e);
341 }
342 };
343
345 {
346 public:
348 : stream_profile(sp)
349 {
350 rs2_error* e = nullptr;
351 if (!sp || (rs2_stream_profile_is(sp.get(), RS2_EXTENSION_INFERENCE_PROFILE, &e) == 0 && !e))
352 {
353 _profile = nullptr;
354 }
355 error::handle(e);
356 }
357 };
358
363 {
364 public:
365 virtual rs2::frame process(rs2::frame frame) const = 0;
366 virtual ~filter_interface() = default;
367 };
368
369 class frame
370 {
371 public:
375 frame() : frame_ref(nullptr) {}
380 frame(rs2_frame* ref) : frame_ref(ref)
381 {
382#ifdef _DEBUG
383 if (ref)
384 {
385 rs2_error* e = nullptr;
386 auto r = rs2_get_frame_number(ref, &e);
387 if (!e)
388 frame_number = r;
389 auto s = rs2_get_frame_stream_profile(ref, &e);
390 if (!e)
391 profile = stream_profile(s);
392 }
393 else
394 {
395 frame_number = 0;
396 profile = stream_profile();
397 }
398#endif
399 }
400
404 frame(frame&& other) noexcept : frame_ref(other.frame_ref)
405 {
406 other.frame_ref = nullptr;
407#ifdef _DEBUG
408 frame_number = other.frame_number;
409 profile = other.profile;
410#endif
411 }
412
417 {
418 swap(other);
419 return *this;
420 }
421
426 frame(const frame& other)
427 : frame_ref(other.frame_ref)
428 {
429 if (frame_ref) add_ref();
430#ifdef _DEBUG
431 frame_number = other.frame_number;
432 profile = other.profile;
433#endif
434 }
435
439 void swap(frame& other)
440 {
441 std::swap(frame_ref, other.frame_ref);
442
443#ifdef _DEBUG
444 std::swap(frame_number, other.frame_number);
445 std::swap(profile, other.profile);
446#endif
447 }
448
453 {
454 if (frame_ref)
455 {
456 rs2_release_frame(frame_ref);
457 }
458 }
459
463 void keep() { rs2_keep_frame(frame_ref); }
464
469 operator bool() const { return frame_ref != nullptr; }
470
472 {
473 rs2_error* e = nullptr;
474 auto r = rs2_get_frame_sensor(frame_ref, &e);
475 error::handle(e);
476 return r;
477 }
478
500 double get_timestamp() const
501 {
502 rs2_error* e = nullptr;
503 auto r = rs2_get_frame_timestamp(frame_ref, &e);
504 error::handle(e);
505 return r;
506 }
507
512 {
513 rs2_error* e = nullptr;
514 auto r = rs2_get_frame_timestamp_domain(frame_ref, &e);
515 error::handle(e);
516 return r;
517 }
518
524 {
525 rs2_error* e = nullptr;
526 auto r = rs2_get_frame_metadata(frame_ref, frame_metadata, &e);
527 error::handle(e);
528 return r;
529 }
530
536 {
537 rs2_error* e = nullptr;
538 auto r = rs2_supports_frame_metadata(frame_ref, frame_metadata, &e);
539 error::handle(e);
540 return r != 0;
541 }
542
547 unsigned long long get_frame_number() const
548 {
549 rs2_error* e = nullptr;
550 auto r = rs2_get_frame_number(frame_ref, &e);
551 error::handle(e);
552 return r;
553 }
554
559 const int get_data_size() const
560 {
561 rs2_error* e = nullptr;
562 auto r = rs2_get_frame_data_size(frame_ref, &e);
563 error::handle(e);
564 return r;
565 }
566
571 const void* get_data() const
572 {
573 rs2_error* e = nullptr;
574 auto r = rs2_get_frame_data(frame_ref, &e);
575 error::handle(e);
576 return r;
577 }
578
584 {
585 rs2_error* e = nullptr;
586 auto s = rs2_get_frame_stream_profile(frame_ref, &e);
587 error::handle(e);
588 return stream_profile(s);
589 }
590
595 template<class T>
596 bool is() const
597 {
598 T extension(*this);
599 return extension;
600 }
601
605 template<class T>
606 T as() const
607 {
608 T extension(*this);
609 return extension;
610 }
611
616 rs2_frame* get() const { return frame_ref; }
617 explicit operator rs2_frame*() { return frame_ref; }
618
620 {
621 return filter.process(*this);
622 }
623
624 protected:
630 void add_ref() const
631 {
632 rs2_error* e = nullptr;
633 rs2_frame_add_ref(frame_ref, &e);
634 error::handle(e);
635 }
636
637 void reset()
638 {
639 if (frame_ref)
640 {
641 rs2_release_frame(frame_ref);
642 }
643 frame_ref = nullptr;
644 }
645
646 private:
647 friend class rs2::frame_source;
648 friend class rs2::frame_queue;
649 friend class rs2::syncer;
651 friend class rs2::pointcloud;
652 friend class rs2::points;
653
654 rs2_frame* frame_ref;
655
656#ifdef _DEBUG
657 stream_profile profile;
658 unsigned long long frame_number = 0;
659#endif
660 };
661
662 class video_frame : public frame
663 {
664 public:
670 : frame(f)
671 {
672 rs2_error* e = nullptr;
673 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_VIDEO_FRAME, &e) == 0 && !e))
674 {
675 reset();
676 }
677 error::handle(e);
678 }
679
680
685 int get_width() const
686 {
687 rs2_error* e = nullptr;
688 auto r = rs2_get_frame_width(get(), &e);
689 error::handle(e);
690 return r;
691 }
692
697 int get_height() const
698 {
699 rs2_error* e = nullptr;
700 auto r = rs2_get_frame_height(get(), &e);
701 error::handle(e);
702 return r;
703 }
704
710 {
711 rs2_error* e = nullptr;
712 auto r = rs2_get_frame_stride_in_bytes(get(), &e);
713 error::handle(e);
714 return r;
715 }
716
722 {
723 rs2_error* e = nullptr;
724 auto r = rs2_get_frame_bits_per_pixel(get(), &e);
725 error::handle(e);
726 return r;
727 }
728
733 int get_bytes_per_pixel() const { return get_bits_per_pixel() / 8; }
734
745 bool extract_target_dimensions(rs2_calib_target_type calib_type, float* target_dims, unsigned int target_dims_size) const
746 {
747 rs2_error* e = nullptr;
748 rs2_extract_target_dimensions(get(), calib_type, target_dims, target_dims_size, &e);
749 error::handle(e);
750 return (e == nullptr);
751 }
752 };
753
754 struct vertex {
755 float x, y, z;
756 operator const float*() const { return &x; }
757 };
759 float u, v;
760 operator const float*() const { return &u; }
761 };
762
763 class points : public frame
764 {
765 public:
769 points() : frame(), _size(0) {}
770
775 points(const frame& f)
776 : frame(f), _size(0)
777 {
778 rs2_error* e = nullptr;
779 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_POINTS, &e) == 0 && !e))
780 {
781 reset();
782 }
783 error::handle(e);
784
785 if (get())
786 {
787 _size = rs2_get_frame_points_count(get(), &e);
788 error::handle(e);
789 }
790 }
791
795 const vertex* get_vertices() const
796 {
797 rs2_error* e = nullptr;
798 auto res = rs2_get_frame_vertices(get(), &e);
799 error::handle(e);
800 return (const vertex*)res;
801 }
802
808 void export_to_ply(const std::string& fname, video_frame texture)
809 {
810 rs2_frame* ptr = nullptr;
811 std::swap(texture.frame_ref, ptr);
812 rs2_error* e = nullptr;
813 rs2_export_to_ply(get(), fname.c_str(), ptr, &e);
814 error::handle(e);
815 }
816
821 {
822 rs2_error* e = nullptr;
823 auto res = rs2_get_frame_texture_coordinates(get(), &e);
824 error::handle(e);
825 return (const texture_coordinate*)res;
826 }
827
828 size_t size() const
829 {
830 return _size;
831 }
832
833 private:
834 size_t _size;
835 };
836
837
838 class labeled_points : public frame
839 {
840 public:
844 labeled_points() : frame(), _size(0) {}
845
851 : frame(f), _size(0)
852 {
853 rs2_error* e = nullptr;
854 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_LABELED_POINTS, &e) == 0 && !e))
855 {
856 reset();
857 }
858 error::handle(e);
859
860 if (get())
861 {
863 error::handle(e);
864 }
865 }
866
871 const vertex* get_vertices() const
872 {
873 rs2_error* e = nullptr;
874 auto res = rs2_get_frame_labeled_vertices(get(), &e);
875 error::handle(e);
876 return (const vertex*)res;
877 }
878
883 const uint8_t* get_labels() const
884 {
885 rs2_error* e = nullptr;
886 auto res = rs2_get_frame_labels(get(), &e);
887 error::handle(e);
888 return (uint8_t * )res;
889 }
890
891 // Returns the vertices counts
892 size_t size() const
893 {
894 return _size;
895 }
896
901 unsigned int get_width() const
902 {
903 rs2_error* e = nullptr;
905 error::handle(e);
906 return r;
907 }
908
913 unsigned int get_height() const
914 {
915 rs2_error* e = nullptr;
917 error::handle(e);
918 return r;
919 }
920
925 unsigned int get_bits_per_pixel() const
926 {
927 rs2_error* e = nullptr;
929 error::handle(e);
930 return r;
931 }
932
933 private:
934 size_t _size;
935 };
936
938 {
939 public:
945 : video_frame(f)
946 {
947 rs2_error* e = nullptr;
948 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DEPTH_FRAME, &e) == 0 && !e))
949 {
950 reset();
951 }
952 error::handle(e);
953 }
954
961 float get_distance(int x, int y) const
962 {
963 rs2_error * e = nullptr;
964 auto r = rs2_depth_frame_get_distance(get(), x, y, &e);
965 error::handle(e);
966 return r;
967 }
968
973 float get_units() const
974 {
975 rs2_error * e = nullptr;
976 auto r = rs2_depth_frame_get_units( get(), &e );
977 error::handle( e );
978 return r;
979 }
980 };
981
983 {
984 public:
990 : depth_frame(f)
991 {
992 rs2_error* e = nullptr;
993 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DISPARITY_FRAME, &e) == 0 && !e))
994 {
995 reset();
996 }
997 error::handle(e);
998 }
999
1003 float get_baseline(void) const
1004 {
1005 rs2_error * e = nullptr;
1007 error::handle(e);
1008 return r;
1009 }
1010 };
1011
1012 class motion_frame : public frame
1013 {
1014 public:
1020 : frame(f)
1021 {
1022 rs2_error* e = nullptr;
1023 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_MOTION_FRAME, &e) == 0 && !e))
1024 {
1025 reset();
1026 }
1027 error::handle(e);
1028 }
1029
1035 {
1036 auto data = reinterpret_cast<const float*>(get_data());
1037 return rs2_vector{ data[0], data[1], data[2] };
1038 }
1039
1045 {
1046 return *reinterpret_cast< rs2_combined_motion const * >( get_data() );
1047 }
1048 };
1049
1050 class pose_frame : public frame
1051 {
1052 public:
1058 : frame(f)
1059 {
1060 rs2_error* e = nullptr;
1061 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_POSE_FRAME, &e) == 0 && !e))
1062 {
1063 reset();
1064 }
1065 error::handle(e);
1066 }
1067
1072 {
1073 rs2_pose pose_data;
1074 rs2_error* e = nullptr;
1075 rs2_pose_frame_get_pose_data(get(), &pose_data, &e);
1076 error::handle(e);
1077 return pose_data;
1078 }
1079 };
1080
1081 class inference_frame : public frame
1082 {
1083 public:
1088 {
1089 }
1090
1095 inference_frame( const frame & f ) : frame( f )
1096 {
1097 rs2_error * e = nullptr;
1098 if( ! f || ( rs2_is_frame_extendable_to( f.get(), RS2_EXTENSION_INFERENCE_FRAME, &e ) == 0 && ! e ) )
1099 {
1100 reset();
1101 }
1102 error::handle( e );
1103 }
1104 };
1105
1107 {
1108 public:
1113
1119 : inference_frame(f)
1120 {
1121 rs2_error* e = nullptr;
1123 {
1124 reset();
1125 }
1126 error::handle(e);
1127 }
1128
1133 unsigned int get_detection_count() const
1134 {
1135 rs2_error* e = nullptr;
1137 error::handle(e);
1138 return r;
1139 }
1140
1146 rs2_object_detection get_detection(unsigned int index) const
1147 {
1148 rs2_object_detection detection;
1149 rs2_error* e = nullptr;
1150 rs2_get_frame_object_detection(get(), index, &detection, &e);
1151 error::handle(e);
1152 return detection;
1153 }
1154 };
1155
1156 class frameset : public frame
1157 {
1158 public:
1162 frameset() :_size(0) {};
1167 frameset(const frame& f)
1168 : frame(f), _size(0)
1169 {
1170 rs2_error* e = nullptr;
1171 if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_COMPOSITE_FRAME, &e) == 0 && !e))
1172 {
1173 reset();
1174 // TODO - consider explicit constructor to move resultion to compile time
1175 }
1176 error::handle(e);
1177
1178 if (get())
1179 {
1180 _size = rs2_embedded_frames_count(get(), &e);
1181 error::handle(e);
1182 }
1183 }
1184
1192 {
1193 frame result;
1194 foreach_rs([&result, s, f](frame frm) {
1195 if (!result && frm.get_profile().stream_type() == s && (f == RS2_FORMAT_ANY || f == frm.get_profile().format()))
1196 {
1197 result = std::move(frm);
1198 }
1199 });
1200 return result;
1201 }
1202
1209 {
1210 auto frm = first_or_default(s, f);
1211 if (!frm) throw error("Frame of requested stream type was not found!");
1212 return frm;
1213 }
1214
1220 {
1222 return f.as<depth_frame>();
1223 }
1224
1228 video_frame get_color_frame( const size_t index = 0 ) const
1229 {
1230 frame f;
1231
1232 foreach_rs( [&f, index]( const frame & frm ) {
1233 if( !f && frm.get_profile().stream_type() == RS2_STREAM_COLOR &&
1234 frm.get_profile().stream_index() == index )
1235 f = frm;
1236 } );
1237
1238 if( ! f )
1239 {
1240 // Color frame can also come from infrared sensor
1241 foreach_rs( [&f, index]( const frame & frm ) {
1242 if( !f && frm.get_profile().stream_type() == RS2_STREAM_INFRARED &&
1243 frm.get_profile().stream_index() == index &&
1245 f = frm;
1246 } );
1247 }
1248
1249 return f;
1250 }
1251
1258
1263 video_frame get_infrared_frame(const size_t index = 0) const
1264 {
1265 frame f;
1266 if (!index)
1267 {
1269 }
1270 else
1271 {
1272 foreach_rs([&f, index](const frame& frm) {
1273 if( !f && frm.get_profile().stream_type() == RS2_STREAM_INFRARED &&
1274 frm.get_profile().stream_index() == index )
1275 f = frm;
1276 });
1277 }
1278 return f;
1279 }
1280
1286 video_frame get_fisheye_frame(const size_t index = 0) const
1287 {
1288 frame f;
1289 if (!index)
1290 {
1292 }
1293 else
1294 {
1295 foreach_rs([&f, index](const frame& frm) {
1297 frm.get_profile().stream_index() == index) f = frm;
1298 });
1299 }
1300 return f;
1301 }
1302
1308 pose_frame get_pose_frame(const size_t index = 0) const
1309 {
1310 frame f;
1311 if (!index)
1312 {
1314 }
1315 else
1316 {
1317 foreach_rs([&f, index](const frame& frm) {
1318 if (frm.get_profile().stream_type() == RS2_STREAM_POSE &&
1319 frm.get_profile().stream_index() == index) f = frm;
1320 });
1321 }
1322 return f.as<pose_frame>();
1323 }
1324
1331 {
1332 frame f;
1333 if (!index)
1334 {
1336 }
1337 else
1338 {
1339 foreach_rs([&f, index](const frame& frm) {
1341 frm.get_profile().stream_index() == index) f = frm;
1342 });
1343 }
1344 return f.as<object_detection_frame>();
1345 }
1346
1351 size_t size() const
1352 {
1353 return _size;
1354 }
1355
1360 template<class T>
1361 void foreach_rs(T action) const
1362 {
1363 rs2_error* e = nullptr;
1364 auto count = size();
1365 for (size_t i = 0; i < count; i++)
1366 {
1367 auto fref = rs2_extract_frame(get(), (int)i, &e);
1368 error::handle(e);
1369
1370 action(frame(fref));
1371 }
1372 }
1373
1378 frame operator[](size_t index) const
1379 {
1380 rs2_error* e = nullptr;
1381 if (index < size())
1382 {
1383 auto fref = rs2_extract_frame(get(), (int)index, &e);
1384 error::handle(e);
1385 return frame(fref);
1386 }
1387
1388 throw error("Requested index is out of range!");
1389 }
1390
1392 {
1393 public:
1394 // inheriting from std::iterator template is deprecated in C++17, this is the new way to define an iterator
1395 // go to https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/ for more info
1396 using iterator_category = std::forward_iterator_tag;
1398 using difference_type = std::ptrdiff_t;
1399 using pointer = frame*;
1401
1402 iterator(const frameset* owner, size_t index = 0) : _index(index), _owner(owner) {}
1403 iterator& operator++() { ++_index; return *this; }
1404 bool operator==(const iterator& other) const { return _index == other._index; }
1405 bool operator!=(const iterator& other) const { return !(*this == other); }
1406
1407 frame operator*() { return (*_owner)[_index]; }
1408 private:
1409 size_t _index = 0;
1410 const frameset* _owner;
1411 };
1412
1413 iterator begin() const { return iterator(this); }
1414 iterator end() const { return iterator(this, size()); }
1415 private:
1416 size_t _size;
1417 };
1418
1419 template<class T>
1421 {
1422 T on_frame_function;
1423 public:
1424 explicit frame_callback(T on_frame) : on_frame_function(on_frame) {}
1425
1426 void on_frame(rs2_frame* fref) override
1427 {
1428 on_frame_function(frame{ fref });
1429 }
1430
1431 void release() override { delete this; }
1432 };
1433}
1434#endif // LIBREALSENSE_RS2_FRAME_HPP
Definition rs_frame.hpp:938
float get_units() const
Definition rs_frame.hpp:973
float get_distance(int x, int y) const
Definition rs_frame.hpp:961
depth_frame(const frame &f)
Definition rs_frame.hpp:944
disparity_frame(const frame &f)
Definition rs_frame.hpp:989
float get_baseline(void) const
Definition rs_frame.hpp:1003
Definition rs_types.hpp:116
static void handle(rs2_error *e)
Definition rs_types.hpp:167
Definition rs_frame.hpp:363
virtual rs2::frame process(rs2::frame frame) const =0
virtual ~filter_interface()=default
Definition rs_processing.hpp:361
rs2::frame process(rs2::frame frame) const override
Definition rs_processing.hpp:369
void release() override
Definition rs_frame.hpp:1431
void on_frame(rs2_frame *fref) override
Definition rs_frame.hpp:1426
frame_callback(T on_frame)
Definition rs_frame.hpp:1424
Definition rs_processing.hpp:134
Definition rs_processing.hpp:18
Definition rs_frame.hpp:370
void reset()
Definition rs_frame.hpp:637
frame(rs2_frame *ref)
Definition rs_frame.hpp:380
rs2_timestamp_domain get_frame_timestamp_domain() const
Definition rs_frame.hpp:511
frame & operator=(frame other)
Definition rs_frame.hpp:416
double get_timestamp() const
Definition rs_frame.hpp:500
frame(frame &&other) noexcept
Definition rs_frame.hpp:404
frame()
Definition rs_frame.hpp:375
frame(const frame &other)
Definition rs_frame.hpp:426
void keep()
Definition rs_frame.hpp:463
void swap(frame &other)
Definition rs_frame.hpp:439
frame apply_filter(filter_interface &filter)
Definition rs_frame.hpp:619
~frame()
Definition rs_frame.hpp:452
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition rs_frame.hpp:523
bool is() const
Definition rs_frame.hpp:596
stream_profile get_profile() const
Definition rs_frame.hpp:583
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition rs_frame.hpp:535
const int get_data_size() const
Definition rs_frame.hpp:559
T as() const
Definition rs_frame.hpp:606
const void * get_data() const
Definition rs_frame.hpp:571
unsigned long long get_frame_number() const
Definition rs_frame.hpp:547
rs2_sensor * get_sensor()
Definition rs_frame.hpp:471
rs2_frame * get() const
Definition rs_frame.hpp:616
void add_ref() const
Definition rs_frame.hpp:630
Definition rs_frame.hpp:1392
bool operator!=(const iterator &other) const
Definition rs_frame.hpp:1405
frame * pointer
Definition rs_frame.hpp:1399
iterator & operator++()
Definition rs_frame.hpp:1403
bool operator==(const iterator &other) const
Definition rs_frame.hpp:1404
iterator(const frameset *owner, size_t index=0)
Definition rs_frame.hpp:1402
std::ptrdiff_t difference_type
Definition rs_frame.hpp:1398
frame operator*()
Definition rs_frame.hpp:1407
frame value_type
Definition rs_frame.hpp:1397
frame & reference
Definition rs_frame.hpp:1400
std::forward_iterator_tag iterator_category
Definition rs_frame.hpp:1396
frame first_or_default(rs2_stream s, rs2_format f=RS2_FORMAT_ANY) const
Definition rs_frame.hpp:1191
labeled_points get_labeled_point_cloud_frame() const
Definition rs_frame.hpp:1252
pose_frame get_pose_frame(const size_t index=0) const
Definition rs_frame.hpp:1308
video_frame get_fisheye_frame(const size_t index=0) const
Definition rs_frame.hpp:1286
video_frame get_infrared_frame(const size_t index=0) const
Definition rs_frame.hpp:1263
void foreach_rs(T action) const
Definition rs_frame.hpp:1361
iterator end() const
Definition rs_frame.hpp:1414
object_detection_frame get_object_detection_frame(const size_t index=0) const
Definition rs_frame.hpp:1330
frame operator[](size_t index) const
Definition rs_frame.hpp:1378
depth_frame get_depth_frame() const
Definition rs_frame.hpp:1219
frameset()
Definition rs_frame.hpp:1162
iterator begin() const
Definition rs_frame.hpp:1413
frameset(const frame &f)
Definition rs_frame.hpp:1167
frame first(rs2_stream s, rs2_format f=RS2_FORMAT_ANY) const
Definition rs_frame.hpp:1208
video_frame get_color_frame(const size_t index=0) const
Definition rs_frame.hpp:1228
size_t size() const
Definition rs_frame.hpp:1351
inference_frame(const frame &f)
Definition rs_frame.hpp:1095
inference_frame()
Definition rs_frame.hpp:1087
inference_stream_profile(const stream_profile &sp)
Definition rs_frame.hpp:347
Definition rs_frame.hpp:839
const uint8_t * get_labels() const
Definition rs_frame.hpp:883
unsigned int get_bits_per_pixel() const
Definition rs_frame.hpp:925
size_t size() const
Definition rs_frame.hpp:892
unsigned int get_width() const
Definition rs_frame.hpp:901
unsigned int get_height() const
Definition rs_frame.hpp:913
labeled_points(const frame &f)
Definition rs_frame.hpp:850
const vertex * get_vertices() const
Definition rs_frame.hpp:871
labeled_points()
Definition rs_frame.hpp:844
motion_frame(const frame &f)
Definition rs_frame.hpp:1019
rs2_combined_motion get_combined_motion_data() const
Definition rs_frame.hpp:1044
rs2_vector get_motion_data() const
Definition rs_frame.hpp:1034
motion_stream_profile(const stream_profile &sp)
Definition rs_frame.hpp:300
rs2_motion_device_intrinsic get_motion_intrinsics() const
Definition rs_frame.hpp:315
Definition rs_frame.hpp:1107
object_detection_frame()
Definition rs_frame.hpp:1112
object_detection_frame(const frame &f)
Definition rs_frame.hpp:1118
unsigned int get_detection_count() const
Definition rs_frame.hpp:1133
rs2_object_detection get_detection(unsigned int index) const
Definition rs_frame.hpp:1146
Definition rs_pipeline.hpp:19
Definition rs_processing.hpp:430
Definition rs_frame.hpp:764
points()
Definition rs_frame.hpp:769
const texture_coordinate * get_texture_coordinates() const
Definition rs_frame.hpp:820
size_t size() const
Definition rs_frame.hpp:828
void export_to_ply(const std::string &fname, video_frame texture)
Definition rs_frame.hpp:808
const vertex * get_vertices() const
Definition rs_frame.hpp:795
points(const frame &f)
Definition rs_frame.hpp:775
Definition rs_frame.hpp:1051
pose_frame(const frame &f)
Definition rs_frame.hpp:1057
rs2_pose get_pose_data() const
Definition rs_frame.hpp:1071
pose_stream_profile(const stream_profile &sp)
Definition rs_frame.hpp:332
Definition rs_processing.hpp:251
Definition rs_sensor.hpp:104
Definition rs_frame.hpp:23
rs2_extrinsics get_extrinsics_to(const stream_profile &to) const
Definition rs_frame.hpp:157
rs2_format format() const
Definition rs_frame.hpp:44
stream_profile(const rs2_stream_profile *profile)
Definition rs_frame.hpp:179
rs2_format _format
Definition rs_frame.hpp:204
int _uid
Definition rs_frame.hpp:202
stream_profile()
Definition rs_frame.hpp:28
int _framerate
Definition rs_frame.hpp:203
int stream_index() const
Definition rs_frame.hpp:34
int unique_id() const
Definition rs_frame.hpp:54
bool is_default() const
Definition rs_frame.hpp:134
std::shared_ptr< rs2_stream_profile > _clone
Definition rs_frame.hpp:199
std::string stream_name() const
Definition rs_frame.hpp:113
rs2_stream _type
Definition rs_frame.hpp:205
const rs2_stream_profile * _profile
Definition rs_frame.hpp:198
bool is() const
Definition rs_frame.hpp:92
int fps() const
Definition rs_frame.hpp:49
T as() const
Definition rs_frame.hpp:103
void register_extrinsics_to(const stream_profile &to, rs2_extrinsics extrinsics)
Definition rs_frame.hpp:171
bool _default
Definition rs_frame.hpp:207
rs2_stream stream_type() const
Definition rs_frame.hpp:39
const rs2_stream_profile * get() const
Definition rs_frame.hpp:146
int _index
Definition rs_frame.hpp:201
stream_profile clone(rs2_stream type, int index, rs2_format format) const
Definition rs_frame.hpp:63
bool operator==(const stream_profile &rhs)
Definition rs_frame.hpp:79
bool is_cloned()
Definition rs_frame.hpp:178
Definition rs_processing.hpp:700
Definition rs_frame.hpp:663
int get_bits_per_pixel() const
Definition rs_frame.hpp:721
int get_height() const
Definition rs_frame.hpp:697
video_frame(const frame &f)
Definition rs_frame.hpp:669
int get_stride_in_bytes() const
Definition rs_frame.hpp:709
int get_width() const
Definition rs_frame.hpp:685
int get_bytes_per_pixel() const
Definition rs_frame.hpp:733
bool extract_target_dimensions(rs2_calib_target_type calib_type, float *target_dims, unsigned int target_dims_size) const
Definition rs_frame.hpp:745
Definition rs_frame.hpp:211
stream_profile clone(rs2_stream type, int index, rs2_format format, int width, int height, const rs2_intrinsics &intr) const
Definition rs_frame.hpp:277
int height() const
Definition rs_frame.hpp:241
video_stream_profile()
Definition rs_frame.hpp:213
video_stream_profile(const stream_profile &sp)
Definition rs_frame.hpp:219
int width() const
Definition rs_frame.hpp:236
rs2_intrinsics get_intrinsics() const
Definition rs_frame.hpp:249
bool operator==(const video_stream_profile &other) const
Definition rs_frame.hpp:258
Definition rs_processing_gl.hpp:13
float rs2_depth_frame_get_distance(const rs2_frame *frame_ref, int x, int y, rs2_error **error)
rs2_vertex * rs2_get_frame_labeled_vertices(const rs2_frame *frame, rs2_error **error)
rs2_frame * rs2_extract_frame(rs2_frame *composite, int index, rs2_error **error)
void rs2_extract_target_dimensions(const rs2_frame *frame, rs2_calib_target_type calib_type, float *target_dims, unsigned int target_dims_size, rs2_error **error)
rs2_timestamp_domain rs2_get_frame_timestamp_domain(const rs2_frame *frameset, rs2_error **error)
rs2_time_t rs2_get_frame_timestamp(const rs2_frame *frame, rs2_error **error)
int rs2_get_frame_data_size(const rs2_frame *frame, rs2_error **error)
rs2_vertex * rs2_get_frame_vertices(const rs2_frame *frame, rs2_error **error)
int rs2_get_frame_points_count(const rs2_frame *frame, rs2_error **error)
void rs2_release_frame(rs2_frame *frame)
unsigned long long rs2_get_frame_number(const rs2_frame *frame, rs2_error **error)
unsigned int rs2_get_frame_labeled_points_height(const rs2_frame *frame, rs2_error **error)
unsigned int rs2_get_frame_labeled_points_width(const rs2_frame *frame, rs2_error **error)
int rs2_get_frame_bits_per_pixel(const rs2_frame *frame, rs2_error **error)
int rs2_is_frame_extendable_to(const rs2_frame *frame, rs2_extension extension_type, rs2_error **error)
const rs2_stream_profile * rs2_get_frame_stream_profile(const rs2_frame *frame, rs2_error **error)
unsigned int rs2_get_frame_labeled_points_bits_per_pixel(const rs2_frame *frame, rs2_error **error)
rs2_metadata_type rs2_get_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
int rs2_get_frame_height(const rs2_frame *frame, rs2_error **error)
void rs2_frame_add_ref(rs2_frame *frame, rs2_error **error)
int rs2_get_frame_labeled_points_count(const rs2_frame *frame, rs2_error **error)
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
Definition rs_frame.h:20
int rs2_supports_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
rs2_pixel * rs2_get_frame_texture_coordinates(const rs2_frame *frame, rs2_error **error)
void rs2_export_to_ply(const rs2_frame *frame, const char *fname, rs2_frame *texture, rs2_error **error)
rs2_frame_metadata_value
Per-Frame-Metadata is the set of read-only properties that might be exposed for each individual frame...
Definition rs_frame.h:30
void rs2_keep_frame(rs2_frame *frame)
int rs2_get_frame_stride_in_bytes(const rs2_frame *frame, rs2_error **error)
void rs2_pose_frame_get_pose_data(const rs2_frame *frame, rs2_pose *pose, rs2_error **error)
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)
int rs2_embedded_frames_count(rs2_frame *composite, rs2_error **error)
rs2_sensor * rs2_get_frame_sensor(const rs2_frame *frame, rs2_error **error)
int rs2_get_frame_width(const rs2_frame *frame, rs2_error **error)
unsigned int rs2_get_frame_object_detection_count(const rs2_frame *frame, rs2_error **error)
void rs2_get_frame_object_detection(const rs2_frame *frame, unsigned int index, rs2_object_detection *detection, rs2_error **error)
float rs2_depth_frame_get_units(const rs2_frame *frame, rs2_error **error)
const char * rs2_get_stream_profile_name(const rs2_stream_profile *profile, rs2_error **error)
void * rs2_get_frame_labels(const rs2_frame *frame, rs2_error **error)
rs2_calib_target_type
Calibration target type.
Definition rs_frame.h:170
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition rs_sensor.h:48
@ RS2_STREAM_DEPTH
Definition rs_sensor.h:50
@ RS2_STREAM_ANY
Definition rs_sensor.h:49
@ RS2_STREAM_INFRARED
Definition rs_sensor.h:52
@ RS2_STREAM_LABELED_POINT_CLOUD
Definition rs_sensor.h:62
@ RS2_STREAM_OBJECT_DETECTION
Definition rs_sensor.h:63
@ RS2_STREAM_COLOR
Definition rs_sensor.h:51
@ RS2_STREAM_POSE
Definition rs_sensor.h:57
@ RS2_STREAM_FISHEYE
Definition rs_sensor.h:53
void rs2_get_motion_intrinsics(const rs2_stream_profile *mode, rs2_motion_device_intrinsic *intrinsics, rs2_error **error)
float rs2_depth_stereo_frame_get_baseline(const rs2_frame *frame_ref, rs2_error **error)
void rs2_delete_stream_profile(rs2_stream_profile *mode)
const char * rs2_stream_to_string(rs2_stream stream)
int rs2_stream_profile_is(const rs2_stream_profile *mode, rs2_extension type, rs2_error **error)
void rs2_get_video_stream_resolution(const rs2_stream_profile *mode, int *width, int *height, rs2_error **error)
rs2_stream_profile * rs2_clone_video_stream_profile(const rs2_stream_profile *mode, rs2_stream stream, int index, rs2_format format, int width, int height, const rs2_intrinsics *intr, rs2_error **error)
int rs2_is_stream_profile_default(const rs2_stream_profile *mode, rs2_error **error)
void rs2_get_stream_profile_data(const rs2_stream_profile *mode, rs2_stream *stream, rs2_format *format, int *index, int *unique_id, int *framerate, rs2_error **error)
void rs2_get_extrinsics(const rs2_stream_profile *from, const rs2_stream_profile *to, rs2_extrinsics *extrin, rs2_error **error)
void rs2_get_video_stream_intrinsics(const rs2_stream_profile *mode, rs2_intrinsics *intrinsics, rs2_error **error)
rs2_format
A stream's format identifies how binary data is encoded within a frame.
Definition rs_sensor.h:70
@ RS2_FORMAT_RGB8
Definition rs_sensor.h:76
@ RS2_FORMAT_Z16
Definition rs_sensor.h:72
@ RS2_FORMAT_ANY
Definition rs_sensor.h:71
void rs2_register_extrinsics(const rs2_stream_profile *from, const rs2_stream_profile *to, rs2_extrinsics extrin, rs2_error **error)
rs2_stream_profile * rs2_clone_stream_profile(const rs2_stream_profile *mode, rs2_stream stream, int index, rs2_format format, rs2_error **error)
struct rs2_sensor rs2_sensor
Definition rs_types.h:317
struct rs2_stream_profile rs2_stream_profile
Definition rs_types.h:304
@ RS2_EXTENSION_MOTION_FRAME
Definition rs_types.h:160
@ RS2_EXTENSION_MOTION_PROFILE
Definition rs_types.h:170
@ RS2_EXTENSION_DISPARITY_FRAME
Definition rs_types.h:169
@ RS2_EXTENSION_POSE_PROFILE
Definition rs_types.h:172
@ RS2_EXTENSION_VIDEO_PROFILE
Definition rs_types.h:166
@ RS2_EXTENSION_VIDEO_FRAME
Definition rs_types.h:159
@ RS2_EXTENSION_INFERENCE_PROFILE
Definition rs_types.h:219
@ RS2_EXTENSION_COMPOSITE_FRAME
Definition rs_types.h:161
@ RS2_EXTENSION_OBJECT_DETECTION_FRAME
Definition rs_types.h:216
@ RS2_EXTENSION_DEPTH_FRAME
Definition rs_types.h:163
@ RS2_EXTENSION_LABELED_POINTS
Definition rs_types.h:210
@ RS2_EXTENSION_INFERENCE_FRAME
Definition rs_types.h:215
@ RS2_EXTENSION_POINTS
Definition rs_types.h:162
@ RS2_EXTENSION_POSE_FRAME
Definition rs_types.h:171
struct rs2_error rs2_error
Definition rs_types.h:293
long long rs2_metadata_type
Definition rs_types.h:341
struct rs2_frame rs2_frame
Definition rs_types.h:296
Definition rs_frame.hpp:758
float v
Definition rs_frame.hpp:759
float u
Definition rs_frame.hpp:759
Definition rs_frame.hpp:754
float y
Definition rs_frame.hpp:755
float x
Definition rs_frame.hpp:755
float z
Definition rs_frame.hpp:755
RS2_STREAM_MOTION / RS2_FORMAT_COMBINED_MOTION content is similar to ROS2's Imu message.
Definition rs_sensor.h:119
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented.
Definition rs_sensor.h:112
Definition rs_types.hpp:27
Video stream intrinsics.
Definition rs_types.h:61
Motion device intrinsics: scale, bias, and variances.
Definition rs_types.h:74
Object detection result from algorithm.
Definition rs_types.h:124
Definition rs_types.h:111
3D vector in Euclidean coordinate space
Definition rs_types.h:100