Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
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 Intel Corporation. All Rights Reserved.
3 
4 #ifndef LIBREALSENSE_RS2_FRAME_HPP
5 #define LIBREALSENSE_RS2_FRAME_HPP
6 
7 #include "rs_types.hpp"
8 
9 namespace 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;
20  class video_stream_profile;
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);
67  error::handle(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  }
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;
195  friend class rs2::pipeline_profile;
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 ((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  }
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 
265  using stream_profile::clone;
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 ((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;
319  rs2_get_motion_intrinsics(_profile, &intrin, &e);
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 ((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 
348  {
349  public:
350  virtual rs2::frame process(rs2::frame frame) const = 0;
351  virtual ~filter_interface() = default;
352  };
353 
354  class frame
355  {
356  public:
360  frame() : frame_ref(nullptr) {}
365  frame(rs2_frame* ref) : frame_ref(ref)
366  {
367 #ifdef _DEBUG
368  if (ref)
369  {
370  rs2_error* e = nullptr;
371  auto r = rs2_get_frame_number(ref, &e);
372  if (!e)
373  frame_number = r;
374  auto s = rs2_get_frame_stream_profile(ref, &e);
375  if (!e)
376  profile = stream_profile(s);
377  }
378  else
379  {
380  frame_number = 0;
381  profile = stream_profile();
382  }
383 #endif
384  }
389  frame(frame&& other) noexcept : frame_ref(other.frame_ref)
390  {
391  other.frame_ref = nullptr;
392 #ifdef _DEBUG
393  frame_number = other.frame_number;
394  profile = other.profile;
395 #endif
396  }
402  {
403  swap(other);
404  return *this;
405  }
406 
411  frame(const frame& other)
412  : frame_ref(other.frame_ref)
413  {
414  if (frame_ref) add_ref();
415 #ifdef _DEBUG
416  frame_number = other.frame_number;
417  profile = other.profile;
418 #endif
419  }
424  void swap(frame& other)
425  {
426  std::swap(frame_ref, other.frame_ref);
427 
428 #ifdef _DEBUG
429  std::swap(frame_number, other.frame_number);
430  std::swap(profile, other.profile);
431 #endif
432  }
433 
438  {
439  if (frame_ref)
440  {
441  rs2_release_frame(frame_ref);
442  }
443  }
444 
448  void keep() { rs2_keep_frame(frame_ref); }
449 
454  operator bool() const { return frame_ref != nullptr; }
455 
457  {
458  rs2_error* e = nullptr;
459  auto r = rs2_get_frame_sensor(frame_ref, &e);
460  error::handle(e);
461  return r;
462  }
463 
485  double get_timestamp() const
486  {
487  rs2_error* e = nullptr;
488  auto r = rs2_get_frame_timestamp(frame_ref, &e);
489  error::handle(e);
490  return r;
491  }
492 
497  {
498  rs2_error* e = nullptr;
499  auto r = rs2_get_frame_timestamp_domain(frame_ref, &e);
500  error::handle(e);
501  return r;
502  }
503 
509  {
510  rs2_error* e = nullptr;
511  auto r = rs2_get_frame_metadata(frame_ref, frame_metadata, &e);
512  error::handle(e);
513  return r;
514  }
515 
521  {
522  rs2_error* e = nullptr;
523  auto r = rs2_supports_frame_metadata(frame_ref, frame_metadata, &e);
524  error::handle(e);
525  return r != 0;
526  }
527 
532  unsigned long long get_frame_number() const
533  {
534  rs2_error* e = nullptr;
535  auto r = rs2_get_frame_number(frame_ref, &e);
536  error::handle(e);
537  return r;
538  }
539 
544  const int get_data_size() const
545  {
546  rs2_error* e = nullptr;
547  auto r = rs2_get_frame_data_size(frame_ref, &e);
548  error::handle(e);
549  return r;
550  }
551 
556  const void* get_data() const
557  {
558  rs2_error* e = nullptr;
559  auto r = rs2_get_frame_data(frame_ref, &e);
560  error::handle(e);
561  return r;
562  }
563 
569  {
570  rs2_error* e = nullptr;
571  auto s = rs2_get_frame_stream_profile(frame_ref, &e);
572  error::handle(e);
573  return stream_profile(s);
574  }
575 
580  template<class T>
581  bool is() const
582  {
583  T extension(*this);
584  return extension;
585  }
590  template<class T>
591  T as() const
592  {
593  T extension(*this);
594  return extension;
595  }
596 
601  rs2_frame* get() const { return frame_ref; }
602  explicit operator rs2_frame*() { return frame_ref; }
603 
605  {
606  return filter.process(*this);
607  }
608 
609  protected:
615  void add_ref() const
616  {
617  rs2_error* e = nullptr;
618  rs2_frame_add_ref(frame_ref, &e);
619  error::handle(e);
620  }
621 
622  void reset()
623  {
624  if (frame_ref)
625  {
626  rs2_release_frame(frame_ref);
627  }
628  frame_ref = nullptr;
629  }
630 
631  private:
632  friend class rs2::frame_source;
633  friend class rs2::frame_queue;
634  friend class rs2::syncer;
635  friend class rs2::processing_block;
636  friend class rs2::pointcloud;
637  friend class rs2::points;
638 
639  rs2_frame* frame_ref;
640 
641 #ifdef _DEBUG
642  stream_profile profile;
643  unsigned long long frame_number = 0;
644 #endif
645  };
646 
647  class video_frame : public frame
648  {
649  public:
654  video_frame(const frame& f)
655  : frame(f)
656  {
657  rs2_error* e = nullptr;
658  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_VIDEO_FRAME, &e) == 0 && !e))
659  {
660  reset();
661  }
662  error::handle(e);
663  }
664 
665 
670  int get_width() const
671  {
672  rs2_error* e = nullptr;
673  auto r = rs2_get_frame_width(get(), &e);
674  error::handle(e);
675  return r;
676  }
677 
682  int get_height() const
683  {
684  rs2_error* e = nullptr;
685  auto r = rs2_get_frame_height(get(), &e);
686  error::handle(e);
687  return r;
688  }
689 
695  {
696  rs2_error* e = nullptr;
697  auto r = rs2_get_frame_stride_in_bytes(get(), &e);
698  error::handle(e);
699  return r;
700  }
701 
706  int get_bits_per_pixel() const
707  {
708  rs2_error* e = nullptr;
709  auto r = rs2_get_frame_bits_per_pixel(get(), &e);
710  error::handle(e);
711  return r;
712  }
713 
718  int get_bytes_per_pixel() const { return get_bits_per_pixel() / 8; }
719 
730  bool extract_target_dimensions(rs2_calib_target_type calib_type, float* target_dims, unsigned int target_dims_size) const
731  {
732  rs2_error* e = nullptr;
733  rs2_extract_target_dimensions(get(), calib_type, target_dims, target_dims_size, &e);
734  error::handle(e);
735  return (e == nullptr);
736  }
737  };
738 
739  struct vertex {
740  float x, y, z;
741  operator const float*() const { return &x; }
742  };
744  float u, v;
745  operator const float*() const { return &u; }
746  };
747 
748  class points : public frame
749  {
750  public:
754  points() : frame(), _size(0) {}
755 
760  points(const frame& f)
761  : frame(f), _size(0)
762  {
763  rs2_error* e = nullptr;
764  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_POINTS, &e) == 0 && !e))
765  {
766  reset();
767  }
768  error::handle(e);
769 
770  if (get())
771  {
772  _size = rs2_get_frame_points_count(get(), &e);
773  error::handle(e);
774  }
775  }
780  const vertex* get_vertices() const
781  {
782  rs2_error* e = nullptr;
783  auto res = rs2_get_frame_vertices(get(), &e);
784  error::handle(e);
785  return (const vertex*)res;
786  }
787 
793  void export_to_ply(const std::string& fname, video_frame texture)
794  {
795  rs2_frame* ptr = nullptr;
796  std::swap(texture.frame_ref, ptr);
797  rs2_error* e = nullptr;
798  rs2_export_to_ply(get(), fname.c_str(), ptr, &e);
799  error::handle(e);
800  }
806  {
807  rs2_error* e = nullptr;
808  auto res = rs2_get_frame_texture_coordinates(get(), &e);
809  error::handle(e);
810  return (const texture_coordinate*)res;
811  }
812 
813  size_t size() const
814  {
815  return _size;
816  }
817 
818  private:
819  size_t _size;
820  };
821 
822  class depth_frame : public video_frame
823  {
824  public:
829  depth_frame(const frame& f)
830  : video_frame(f)
831  {
832  rs2_error* e = nullptr;
833  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DEPTH_FRAME, &e) == 0 && !e))
834  {
835  reset();
836  }
837  error::handle(e);
838  }
839 
846  float get_distance(int x, int y) const
847  {
848  rs2_error * e = nullptr;
849  auto r = rs2_depth_frame_get_distance(get(), x, y, &e);
850  error::handle(e);
851  return r;
852  }
853 
858  float get_units() const
859  {
860  rs2_error * e = nullptr;
861  auto r = rs2_depth_frame_get_units( get(), &e );
862  error::handle( e );
863  return r;
864  }
865  };
866 
868  {
869  public:
875  : depth_frame(f)
876  {
877  rs2_error* e = nullptr;
878  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DISPARITY_FRAME, &e) == 0 && !e))
879  {
880  reset();
881  }
882  error::handle(e);
883  }
888  float get_baseline(void) const
889  {
890  rs2_error * e = nullptr;
891  auto r = rs2_depth_stereo_frame_get_baseline(get(), &e);
892  error::handle(e);
893  return r;
894  }
895  };
896 
897  class motion_frame : public frame
898  {
899  public:
904  motion_frame(const frame& f)
905  : frame(f)
906  {
907  rs2_error* e = nullptr;
908  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_MOTION_FRAME, &e) == 0 && !e))
909  {
910  reset();
911  }
912  error::handle(e);
913  }
920  {
921  auto data = reinterpret_cast<const float*>(get_data());
922  return rs2_vector{ data[0], data[1], data[2] };
923  }
930  {
931  return *reinterpret_cast< rs2_combined_motion const * >( get_data() );
932  }
933  };
934 
935  class pose_frame : public frame
936  {
937  public:
942  pose_frame(const frame& f)
943  : frame(f)
944  {
945  rs2_error* e = nullptr;
946  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_POSE_FRAME, &e) == 0 && !e))
947  {
948  reset();
949  }
950  error::handle(e);
951  }
957  {
958  rs2_pose pose_data;
959  rs2_error* e = nullptr;
960  rs2_pose_frame_get_pose_data(get(), &pose_data, &e);
961  error::handle(e);
962  return pose_data;
963  }
964  };
965 
966  class frameset : public frame
967  {
968  public:
972  frameset() :_size(0) {};
977  frameset(const frame& f)
978  : frame(f), _size(0)
979  {
980  rs2_error* e = nullptr;
981  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_COMPOSITE_FRAME, &e) == 0 && !e))
982  {
983  reset();
984  // TODO - consider explicit constructor to move resultion to compile time
985  }
986  error::handle(e);
987 
988  if (get())
989  {
990  _size = rs2_embedded_frames_count(get(), &e);
991  error::handle(e);
992  }
993  }
994 
1002  {
1003  frame result;
1004  foreach_rs([&result, s, f](frame frm) {
1005  if (!result && frm.get_profile().stream_type() == s && (f == RS2_FORMAT_ANY || f == frm.get_profile().format()))
1006  {
1007  result = std::move(frm);
1008  }
1009  });
1010  return result;
1011  }
1019  {
1020  auto frm = first_or_default(s, f);
1021  if (!frm) throw error("Frame of requested stream type was not found!");
1022  return frm;
1023  }
1024 
1030  {
1032  return f.as<depth_frame>();
1033  }
1039  {
1041 
1042  if (!f)
1043  {
1045  if (ir && ir.get_profile().format() == RS2_FORMAT_RGB8)
1046  f = ir;
1047  }
1048  return f;
1049  }
1055  video_frame get_infrared_frame(const size_t index = 0) const
1056  {
1057  frame f;
1058  if (!index)
1059  {
1061  }
1062  else
1063  {
1064  foreach_rs([&f, index](const frame& frm) {
1065  if (frm.get_profile().stream_type() == RS2_STREAM_INFRARED &&
1066  frm.get_profile().stream_index() == index) f = frm;
1067  });
1068  }
1069  return f;
1070  }
1071 
1077  video_frame get_fisheye_frame(const size_t index = 0) const
1078  {
1079  frame f;
1080  if (!index)
1081  {
1083  }
1084  else
1085  {
1086  foreach_rs([&f, index](const frame& frm) {
1087  if (frm.get_profile().stream_type() == RS2_STREAM_FISHEYE &&
1088  frm.get_profile().stream_index() == index) f = frm;
1089  });
1090  }
1091  return f;
1092  }
1093 
1099  pose_frame get_pose_frame(const size_t index = 0) const
1100  {
1101  frame f;
1102  if (!index)
1103  {
1105  }
1106  else
1107  {
1108  foreach_rs([&f, index](const frame& frm) {
1109  if (frm.get_profile().stream_type() == RS2_STREAM_POSE &&
1110  frm.get_profile().stream_index() == index) f = frm;
1111  });
1112  }
1113  return f.as<pose_frame>();
1114  }
1115 
1120  size_t size() const
1121  {
1122  return _size;
1123  }
1124 
1129  template<class T>
1130  void foreach_rs(T action) const
1131  {
1132  rs2_error* e = nullptr;
1133  auto count = size();
1134  for (size_t i = 0; i < count; i++)
1135  {
1136  auto fref = rs2_extract_frame(get(), (int)i, &e);
1137  error::handle(e);
1138 
1139  action(frame(fref));
1140  }
1141  }
1147  frame operator[](size_t index) const
1148  {
1149  rs2_error* e = nullptr;
1150  if (index < size())
1151  {
1152  auto fref = rs2_extract_frame(get(), (int)index, &e);
1153  error::handle(e);
1154  return frame(fref);
1155  }
1156 
1157  throw error("Requested index is out of range!");
1158  }
1159 
1160  class iterator
1161  {
1162  public:
1163  // inheriting from std::iterator template is deprecated in C++17, this is the new way to define an iterator
1164  // go to https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/ for more info
1165  using iterator_category = std::forward_iterator_tag;
1167  using difference_type = std::ptrdiff_t;
1168  using pointer = frame*;
1169  using reference = frame&;
1170 
1171  iterator(const frameset* owner, size_t index = 0) : _index(index), _owner(owner) {}
1172  iterator& operator++() { ++_index; return *this; }
1173  bool operator==(const iterator& other) const { return _index == other._index; }
1174  bool operator!=(const iterator& other) const { return !(*this == other); }
1175 
1176  frame operator*() { return (*_owner)[_index]; }
1177  private:
1178  size_t _index = 0;
1179  const frameset* _owner;
1180  };
1181 
1182  iterator begin() const { return iterator(this); }
1183  iterator end() const { return iterator(this, size()); }
1184  private:
1185  size_t _size;
1186  };
1187 
1188  template<class T>
1190  {
1191  T on_frame_function;
1192  public:
1193  explicit frame_callback(T on_frame) : on_frame_function(on_frame) {}
1194 
1195  void on_frame(rs2_frame* fref) override
1196  {
1197  on_frame_function(frame{ fref });
1198  }
1199 
1200  void release() override { delete this; }
1201  };
1202 }
1203 #endif // LIBREALSENSE_RS2_FRAME_HPP
Definition: rs_types.hpp:115
void rs2_register_extrinsics(const rs2_stream_profile *from, const rs2_stream_profile *to, rs2_extrinsics extrin, rs2_error **error)
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
Definition: rs_frame.hpp:293
iterator begin() const
Definition: rs_frame.hpp:1182
frame apply_filter(filter_interface &filter)
Definition: rs_frame.hpp:604
Definition: rs_frame.hpp:22
int get_bytes_per_pixel() const
Definition: rs_frame.hpp:718
depth_frame(const frame &f)
Definition: rs_frame.hpp:829
Definition: rs_frame.hpp:647
Definition: rs_types.hpp:26
void rs2_export_to_ply(const rs2_frame *frame, const char *fname, rs2_frame *texture, rs2_error **error)
Definition: rs_sensor.hpp:102
float rs2_depth_frame_get_units(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:354
video_stream_profile()
Definition: rs_frame.hpp:213
void release() override
Definition: rs_frame.hpp:1200
void add_ref() const
Definition: rs_frame.hpp:615
int rs2_get_frame_points_count(const rs2_frame *frame, rs2_error **error)
frame first(rs2_stream s, rs2_format f=RS2_FORMAT_ANY) const
Definition: rs_frame.hpp:1018
const rs2_stream_profile * rs2_get_frame_stream_profile(const rs2_frame *frame, rs2_error **error)
rs2_sensor * rs2_get_frame_sensor(const rs2_frame *frame, rs2_error **error)
rs2_motion_device_intrinsic get_motion_intrinsics() const
Definition: rs_frame.hpp:315
int _uid
Definition: rs_frame.hpp:202
stream_profile()
Definition: rs_frame.hpp:28
Definition: rs_pipeline.hpp:18
int rs2_is_frame_extendable_to(const rs2_frame *frame, rs2_extension extension_type, rs2_error **error)
rs2_format format() const
Definition: rs_frame.hpp:44
Definition: rs_types.h:148
void rs2_get_video_stream_resolution(const rs2_stream_profile *mode, int *width, int *height, rs2_error **error)
Definition: rs_frame.hpp:748
void register_extrinsics_to(const stream_profile &to, rs2_extrinsics extrinsics)
Definition: rs_frame.hpp:171
frame operator*()
Definition: rs_frame.hpp:1176
Definition: rs_frame.hpp:325
void rs2_keep_frame(rs2_frame *frame)
void rs2_get_extrinsics(const rs2_stream_profile *from, const rs2_stream_profile *to, rs2_extrinsics *extrin, rs2_error **error)
std::string stream_name() const
Definition: rs_frame.hpp:113
frameset()
Definition: rs_frame.hpp:972
float y
Definition: rs_frame.hpp:740
int _index
Definition: rs_frame.hpp:201
Definition: rs_sensor.h:50
Definition: rs_sensor.h:65
rs2_calib_target_type
Calibration target type.
Definition: rs_frame.h:84
pose_frame get_pose_frame(const size_t index=0) const
Definition: rs_frame.hpp:1099
Definition: rs_sensor.h:54
Definition: rs_types.h:150
frame(frame &&other) noexcept
Definition: rs_frame.hpp:389
Definition: rs_frame.hpp:966
bool is() const
Definition: rs_frame.hpp:92
void export_to_ply(const std::string &fname, video_frame texture)
Definition: rs_frame.hpp:793
rs2_time_t rs2_get_frame_timestamp(const rs2_frame *frame, rs2_error **error)
int rs2_stream_profile_is(const rs2_stream_profile *mode, rs2_extension type, rs2_error **error)
Definition: rs_context.hpp:11
rs2_pixel * rs2_get_frame_texture_coordinates(const rs2_frame *frame, rs2_error **error)
double get_timestamp() const
Definition: rs_frame.hpp:485
bool is() const
Definition: rs_frame.hpp:581
size_t size() const
Definition: rs_frame.hpp:813
float u
Definition: rs_frame.hpp:744
video_frame get_color_frame() const
Definition: rs_frame.hpp:1038
int rs2_supports_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
Definition: rs_processing.hpp:251
rs2_stream_profile * rs2_clone_stream_profile(const rs2_stream_profile *mode, rs2_stream stream, int index, rs2_format format, rs2_error **error)
float z
Definition: rs_frame.hpp:740
int fps() const
Definition: rs_frame.hpp:49
void reset()
Definition: rs_frame.hpp:622
iterator & operator++()
Definition: rs_frame.hpp:1172
struct rs2_sensor rs2_sensor
Definition: rs_types.h:255
Definition: rs_sensor.h:48
rs2_extrinsics get_extrinsics_to(const stream_profile &to) const
Definition: rs_frame.hpp:157
int rs2_get_frame_height(const rs2_frame *frame, rs2_error **error)
std::shared_ptr< rs2_stream_profile > _clone
Definition: rs_frame.hpp:199
pose_frame(const frame &f)
Definition: rs_frame.hpp:942
void swap(frame &other)
Definition: rs_frame.hpp:424
Definition: rs_types.h:158
Definition: rs_frame.hpp:1160
frame & operator=(frame other)
Definition: rs_frame.hpp:401
Definition: rs_sensor.h:69
Definition: rs_frame.hpp:897
frame_callback(T on_frame)
Definition: rs_frame.hpp:1193
int rs2_get_frame_stride_in_bytes(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:1189
rs2_vector get_motion_data() const
Definition: rs_frame.hpp:919
frame(rs2_frame *ref)
Definition: rs_frame.hpp:365
const rs2_stream_profile * _profile
Definition: rs_frame.hpp:198
frame first_or_default(rs2_stream s, rs2_format f=RS2_FORMAT_ANY) const
Definition: rs_frame.hpp:1001
rs2::frame process(rs2::frame frame) const override
Definition: rs_processing.hpp:370
video_frame(const frame &f)
Definition: rs_frame.hpp:654
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)
points()
Definition: rs_frame.hpp:754
std::forward_iterator_tag iterator_category
Definition: rs_frame.hpp:1165
float get_distance(int x, int y) const
Definition: rs_frame.hpp:846
Definition: rs_processing.hpp:18
int rs2_embedded_frames_count(rs2_frame *composite, rs2_error **error)
int rs2_is_stream_profile_default(const rs2_stream_profile *mode, rs2_error **error)
int _framerate
Definition: rs_frame.hpp:203
Definition: rs_types.h:151
motion_frame(const frame &f)
Definition: rs_frame.hpp:904
~frame()
Definition: rs_frame.hpp:437
int rs2_get_frame_width(const rs2_frame *frame, rs2_error **error)
float rs2_depth_frame_get_distance(const rs2_frame *frame_ref, int x, int y, rs2_error **error)
frame operator[](size_t index) const
Definition: rs_frame.hpp:1147
RS2_STREAM_MOTION / RS2_FORMAT_COMBINED_MOTION content is similar to ROS2&#39;s Imu message.
Definition: rs_sensor.h:110
Definition: rs_types.h:149
rs2_timestamp_domain rs2_get_frame_timestamp_domain(const rs2_frame *frameset, rs2_error **error)
Definition: rs_types.h:110
rs2_format _format
Definition: rs_frame.hpp:204
void rs2_delete_stream_profile(rs2_stream_profile *mode)
motion_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:300
Definition: rs_types.h:157
void foreach_rs(T action) const
Definition: rs_frame.hpp:1130
rs2_timestamp_domain get_frame_timestamp_domain() const
Definition: rs_frame.hpp:496
bool extract_target_dimensions(rs2_calib_target_type calib_type, float *target_dims, unsigned int target_dims_size) const
Definition: rs_frame.hpp:730
T as() const
Definition: rs_frame.hpp:103
T as() const
Definition: rs_frame.hpp:591
video_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:219
struct rs2_stream_profile rs2_stream_profile
Definition: rs_types.h:242
Definition: rs_sensor.h:64
virtual ~filter_interface()=default
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:62
Definition: rs_processing.hpp:430
bool is_default() const
Definition: rs_frame.hpp:134
void keep()
Definition: rs_frame.hpp:448
unsigned long long rs2_get_frame_number(const rs2_frame *frame, rs2_error **error)
int stream_index() const
Definition: rs_frame.hpp:34
video_frame get_infrared_frame(const size_t index=0) const
Definition: rs_frame.hpp:1055
const texture_coordinate * get_texture_coordinates() const
Definition: rs_frame.hpp:805
int get_bits_per_pixel() const
Definition: rs_frame.hpp:706
bool operator==(const video_stream_profile &other) const
Definition: rs_frame.hpp:258
bool operator==(const iterator &other) const
Definition: rs_frame.hpp:1173
static void handle(rs2_error *e)
Definition: rs_types.hpp:167
Definition: rs_sensor.h:47
rs2_sensor * get_sensor()
Definition: rs_frame.hpp:456
int rs2_get_frame_data_size(const rs2_frame *frame, rs2_error **error)
rs2_combined_motion get_combined_motion_data() const
Definition: rs_frame.hpp:929
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:44
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)
Definition: rs_processing.hpp:361
int get_height() const
Definition: rs_frame.hpp:682
const rs2_stream_profile * get() const
Definition: rs_frame.hpp:146
bool _default
Definition: rs_frame.hpp:207
Definition: rs_frame.hpp:867
void rs2_get_video_stream_intrinsics(const rs2_stream_profile *mode, rs2_intrinsics *intrinsics, rs2_error **error)
Definition: rs_sensor.h:49
unsigned long long get_frame_number() const
Definition: rs_frame.hpp:532
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:103
Definition: rs_types.h:147
iterator end() const
Definition: rs_frame.hpp:1183
iterator(const frameset *owner, size_t index=0)
Definition: rs_frame.hpp:1171
bool is_cloned()
Definition: rs_frame.hpp:178
3D vector in Euclidean coordinate space
Definition: rs_types.h:99
virtual rs2::frame process(rs2::frame frame) const =0
int get_width() const
Definition: rs_frame.hpp:670
const void * get_data() const
Definition: rs_frame.hpp:556
const char * rs2_stream_to_string(rs2_stream stream)
void on_frame(rs2_frame *fref) override
Definition: rs_frame.hpp:1195
Definition: rs_sensor.h:46
long long rs2_metadata_type
Definition: rs_types.h:277
float get_units() const
Definition: rs_frame.hpp:858
points(const frame &f)
Definition: rs_frame.hpp:760
Definition: rs_frame.hpp:347
Definition: rs_types.h:154
int get_stride_in_bytes() const
Definition: rs_frame.hpp:694
rs2_vertex * rs2_get_frame_vertices(const rs2_frame *frame, rs2_error **error)
disparity_frame(const frame &f)
Definition: rs_frame.hpp:874
int width() const
Definition: rs_frame.hpp:236
void rs2_frame_add_ref(rs2_frame *frame, rs2_error **error)
Video stream intrinsics.
Definition: rs_types.h:60
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)
Definition: rs_processing.hpp:641
int height() const
Definition: rs_frame.hpp:241
const char * rs2_get_stream_profile_name(const rs2_stream_profile *profile, rs2_error **error)
rs2_pose get_pose_data() const
Definition: rs_frame.hpp:956
bool operator!=(const iterator &other) const
Definition: rs_frame.hpp:1174
bool operator==(const stream_profile &rhs)
Definition: rs_frame.hpp:79
Motion device intrinsics: scale, bias, and variances.
Definition: rs_types.h:73
depth_frame get_depth_frame() const
Definition: rs_frame.hpp:1029
Definition: rs_processing.hpp:134
float rs2_depth_stereo_frame_get_baseline(const rs2_frame *frame_ref, rs2_error **error)
stream_profile(const rs2_stream_profile *profile)
Definition: rs_frame.hpp:179
void rs2_release_frame(rs2_frame *frame)
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:508
frameset(const frame &f)
Definition: rs_frame.hpp:977
Definition: rs_frame.hpp:743
rs2_frame * rs2_extract_frame(rs2_frame *composite, int index, rs2_error **error)
size_t size() const
Definition: rs_frame.hpp:1120
Definition: rs_types.h:159
rs2_metadata_type rs2_get_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
Definition: rs_types.h:160
struct rs2_error rs2_error
Definition: rs_types.h:231
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:520
rs2_stream stream_type() const
Definition: rs_frame.hpp:39
float x
Definition: rs_frame.hpp:740
Definition: rs_frame.hpp:210
Definition: rs_frame.hpp:935
frame(const frame &other)
Definition: rs_frame.hpp:411
rs2_intrinsics get_intrinsics() const
Definition: rs_frame.hpp:249
const int get_data_size() const
Definition: rs_frame.hpp:544
void rs2_get_motion_intrinsics(const rs2_stream_profile *mode, rs2_motion_device_intrinsic *intrinsics, rs2_error **error)
video_frame get_fisheye_frame(const size_t index=0) const
Definition: rs_frame.hpp:1077
rs2_frame * get() const
Definition: rs_frame.hpp:601
void rs2_pose_frame_get_pose_data(const rs2_frame *frame, rs2_pose *pose, rs2_error **error)
frame()
Definition: rs_frame.hpp:360
float v
Definition: rs_frame.hpp:744
stream_profile clone(rs2_stream type, int index, rs2_format format) const
Definition: rs_frame.hpp:63
int rs2_get_frame_bits_per_pixel(const rs2_frame *frame, 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:29
struct rs2_frame rs2_frame
Definition: rs_types.h:234
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)
std::ptrdiff_t difference_type
Definition: rs_frame.hpp:1167
float get_baseline(void) const
Definition: rs_frame.hpp:888
pose_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:332
rs2_stream _type
Definition: rs_frame.hpp:205
Definition: rs_frame.hpp:739
stream_profile get_profile() const
Definition: rs_frame.hpp:568
const vertex * get_vertices() const
Definition: rs_frame.hpp:780
Definition: rs_frame.hpp:822
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
Definition: rs_frame.h:19
int unique_id() const
Definition: rs_frame.hpp:54