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  std::stringstream ss;
117  if (stream_index() != 0) ss << " " << stream_index();
118  return ss.str();
119  }
120 
125  bool is_default() const { return _default; }
126 
131  operator bool() const { return _profile != nullptr; }
132 
137  const rs2_stream_profile* get() const { return _profile; }
138 
149  {
150  rs2_error* e = nullptr;
151  rs2_extrinsics res;
152  rs2_get_extrinsics(get(), to.get(), &res, &e);
153  error::handle(e);
154  return res;
155  }
163  {
164  rs2_error* e = nullptr;
165  rs2_register_extrinsics(get(), to.get(), extrinsics, &e);
166  error::handle(e);
167  }
168 
169  bool is_cloned() { return bool(_clone); }
170  explicit stream_profile(const rs2_stream_profile* profile) : _profile(profile)
171  {
172  rs2_error* e = nullptr;
174  error::handle(e);
175 
177  error::handle(e);
178 
179  }
180  operator const rs2_stream_profile*() { return _profile; }
181  explicit operator std::shared_ptr<rs2_stream_profile>() { return _clone; }
182 
183  protected:
184  friend class rs2::sensor;
185  friend class rs2::frame;
186  friend class rs2::pipeline_profile;
188 
190  std::shared_ptr<rs2_stream_profile> _clone;
191 
192  int _index = 0;
193  int _uid = 0;
194  int _framerate = 0;
197 
198  bool _default = false;
199  };
200 
202  {
203  public:
209  : stream_profile(sp)
210  {
211  rs2_error* e = nullptr;
212  if ((rs2_stream_profile_is(sp.get(), RS2_EXTENSION_VIDEO_PROFILE, &e) == 0 && !e))
213  {
214  _profile = nullptr;
215  }
216  error::handle(e);
217 
218  if (_profile)
219  {
220  rs2_get_video_stream_resolution(_profile, &_width, &_height, &e);
221  error::handle(e);
222  }
223  }
224 
225  int width() const
226  {
227  return _width;
228  }
229 
230  int height() const
231  {
232  return _height;
233  }
239  {
240  rs2_error* e = nullptr;
241  rs2_intrinsics intr;
243  error::handle(e);
244  return intr;
245  }
246 
247  using stream_profile::clone;
248 
259  stream_profile clone(rs2_stream type, int index, rs2_format format, int width, int height, const rs2_intrinsics& intr) const
260  {
261  rs2_error* e = nullptr;
262  auto ref = rs2_clone_video_stream_profile(_profile, type, index, format, width, height, &intr, &e);
263  error::handle(e);
264  stream_profile res(ref);
265  res._clone = std::shared_ptr<rs2_stream_profile>(ref, [](rs2_stream_profile* r) { rs2_delete_stream_profile(r); });
266 
267  return res;
268  }
269  private:
270  int _width = 0;
271  int _height = 0;
272  };
273 
274 
276  {
277  public:
283  : stream_profile(sp)
284  {
285  rs2_error* e = nullptr;
286  if ((rs2_stream_profile_is(sp.get(), RS2_EXTENSION_MOTION_PROFILE, &e) == 0 && !e))
287  {
288  _profile = nullptr;
289  }
290  error::handle(e);
291  }
292 
298  {
299  rs2_error* e = nullptr;
301  rs2_get_motion_intrinsics(_profile, &intrin, &e);
302  error::handle(e);
303  return intrin;
304  }
305  };
306 
308  {
309  public:
315  : stream_profile(sp)
316  {
317  rs2_error* e = nullptr;
318  if ((rs2_stream_profile_is(sp.get(), RS2_EXTENSION_POSE_PROFILE, &e) == 0 && !e))
319  {
320  _profile = nullptr;
321  }
322  error::handle(e);
323  }
324  };
325 
330  {
331  public:
332  virtual rs2::frame process(rs2::frame frame) const = 0;
333  virtual ~filter_interface() = default;
334  };
335 
336  class frame
337  {
338  public:
342  frame() : frame_ref(nullptr) {}
347  frame(rs2_frame* ref) : frame_ref(ref)
348  {
349 #ifdef _DEBUG
350  if (ref)
351  {
352  rs2_error* e = nullptr;
353  auto r = rs2_get_frame_number(ref, &e);
354  if (!e)
355  frame_number = r;
356  auto s = rs2_get_frame_stream_profile(ref, &e);
357  if (!e)
358  profile = stream_profile(s);
359  }
360  else
361  {
362  frame_number = 0;
363  profile = stream_profile();
364  }
365 #endif
366  }
371  frame(frame&& other) noexcept : frame_ref(other.frame_ref)
372  {
373  other.frame_ref = nullptr;
374 #ifdef _DEBUG
375  frame_number = other.frame_number;
376  profile = other.profile;
377 #endif
378  }
384  {
385  swap(other);
386  return *this;
387  }
388 
393  frame(const frame& other)
394  : frame_ref(other.frame_ref)
395  {
396  if (frame_ref) add_ref();
397 #ifdef _DEBUG
398  frame_number = other.frame_number;
399  profile = other.profile;
400 #endif
401  }
406  void swap(frame& other)
407  {
408  std::swap(frame_ref, other.frame_ref);
409 
410 #ifdef _DEBUG
411  std::swap(frame_number, other.frame_number);
412  std::swap(profile, other.profile);
413 #endif
414  }
415 
420  {
421  if (frame_ref)
422  {
423  rs2_release_frame(frame_ref);
424  }
425  }
426 
430  void keep() { rs2_keep_frame(frame_ref); }
431 
436  operator bool() const { return frame_ref != nullptr; }
437 
439  {
440  rs2_error* e = nullptr;
441  auto r = rs2_get_frame_sensor(frame_ref, &e);
442  error::handle(e);
443  return r;
444  }
445 
467  double get_timestamp() const
468  {
469  rs2_error* e = nullptr;
470  auto r = rs2_get_frame_timestamp(frame_ref, &e);
471  error::handle(e);
472  return r;
473  }
474 
479  {
480  rs2_error* e = nullptr;
481  auto r = rs2_get_frame_timestamp_domain(frame_ref, &e);
482  error::handle(e);
483  return r;
484  }
485 
491  {
492  rs2_error* e = nullptr;
493  auto r = rs2_get_frame_metadata(frame_ref, frame_metadata, &e);
494  error::handle(e);
495  return r;
496  }
497 
503  {
504  rs2_error* e = nullptr;
505  auto r = rs2_supports_frame_metadata(frame_ref, frame_metadata, &e);
506  error::handle(e);
507  return r != 0;
508  }
509 
514  unsigned long long get_frame_number() const
515  {
516  rs2_error* e = nullptr;
517  auto r = rs2_get_frame_number(frame_ref, &e);
518  error::handle(e);
519  return r;
520  }
521 
526  const int get_data_size() const
527  {
528  rs2_error* e = nullptr;
529  auto r = rs2_get_frame_data_size(frame_ref, &e);
530  error::handle(e);
531  return r;
532  }
533 
538  const void* get_data() const
539  {
540  rs2_error* e = nullptr;
541  auto r = rs2_get_frame_data(frame_ref, &e);
542  error::handle(e);
543  return r;
544  }
545 
551  {
552  rs2_error* e = nullptr;
553  auto s = rs2_get_frame_stream_profile(frame_ref, &e);
554  error::handle(e);
555  return stream_profile(s);
556  }
557 
562  template<class T>
563  bool is() const
564  {
565  T extension(*this);
566  return extension;
567  }
572  template<class T>
573  T as() const
574  {
575  T extension(*this);
576  return extension;
577  }
578 
583  rs2_frame* get() const { return frame_ref; }
584  explicit operator rs2_frame*() { return frame_ref; }
585 
587  {
588  return filter.process(*this);
589  }
590 
591  protected:
597  void add_ref() const
598  {
599  rs2_error* e = nullptr;
600  rs2_frame_add_ref(frame_ref, &e);
601  error::handle(e);
602  }
603 
604  void reset()
605  {
606  if (frame_ref)
607  {
608  rs2_release_frame(frame_ref);
609  }
610  frame_ref = nullptr;
611  }
612 
613  private:
614  friend class rs2::frame_source;
615  friend class rs2::frame_queue;
616  friend class rs2::syncer;
617  friend class rs2::processing_block;
618  friend class rs2::pointcloud;
619  friend class rs2::points;
620 
621  rs2_frame* frame_ref;
622 
623 #ifdef _DEBUG
624  stream_profile profile;
625  unsigned long long frame_number = 0;
626 #endif
627  };
628 
629  class video_frame : public frame
630  {
631  public:
636  video_frame(const frame& f)
637  : frame(f)
638  {
639  rs2_error* e = nullptr;
640  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_VIDEO_FRAME, &e) == 0 && !e))
641  {
642  reset();
643  }
644  error::handle(e);
645  }
646 
647 
652  int get_width() const
653  {
654  rs2_error* e = nullptr;
655  auto r = rs2_get_frame_width(get(), &e);
656  error::handle(e);
657  return r;
658  }
659 
664  int get_height() const
665  {
666  rs2_error* e = nullptr;
667  auto r = rs2_get_frame_height(get(), &e);
668  error::handle(e);
669  return r;
670  }
671 
677  {
678  rs2_error* e = nullptr;
679  auto r = rs2_get_frame_stride_in_bytes(get(), &e);
680  error::handle(e);
681  return r;
682  }
683 
688  int get_bits_per_pixel() const
689  {
690  rs2_error* e = nullptr;
691  auto r = rs2_get_frame_bits_per_pixel(get(), &e);
692  error::handle(e);
693  return r;
694  }
695 
700  int get_bytes_per_pixel() const { return get_bits_per_pixel() / 8; }
701  };
702 
703  struct vertex {
704  float x, y, z;
705  operator const float*() const { return &x; }
706  };
708  float u, v;
709  operator const float*() const { return &u; }
710  };
711 
712  class points : public frame
713  {
714  public:
718  points() : frame(), _size(0) {}
719 
724  points(const frame& f)
725  : frame(f), _size(0)
726  {
727  rs2_error* e = nullptr;
728  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_POINTS, &e) == 0 && !e))
729  {
730  reset();
731  }
732  error::handle(e);
733 
734  if (get())
735  {
736  _size = rs2_get_frame_points_count(get(), &e);
737  error::handle(e);
738  }
739  }
744  const vertex* get_vertices() const
745  {
746  rs2_error* e = nullptr;
747  auto res = rs2_get_frame_vertices(get(), &e);
748  error::handle(e);
749  return (const vertex*)res;
750  }
751 
757  void export_to_ply(const std::string& fname, video_frame texture)
758  {
759  rs2_frame* ptr = nullptr;
760  std::swap(texture.frame_ref, ptr);
761  rs2_error* e = nullptr;
762  rs2_export_to_ply(get(), fname.c_str(), ptr, &e);
763  error::handle(e);
764  }
770  {
771  rs2_error* e = nullptr;
772  auto res = rs2_get_frame_texture_coordinates(get(), &e);
773  error::handle(e);
774  return (const texture_coordinate*)res;
775  }
776 
777  size_t size() const
778  {
779  return _size;
780  }
781 
782  private:
783  size_t _size;
784  };
785 
786  class depth_frame : public video_frame
787  {
788  public:
793  depth_frame(const frame& f)
794  : video_frame(f)
795  {
796  rs2_error* e = nullptr;
797  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DEPTH_FRAME, &e) == 0 && !e))
798  {
799  reset();
800  }
801  error::handle(e);
802  }
803 
810  float get_distance(int x, int y) const
811  {
812  rs2_error * e = nullptr;
813  auto r = rs2_depth_frame_get_distance(get(), x, y, &e);
814  error::handle(e);
815  return r;
816  }
817 
822  float get_units() const
823  {
824  rs2_error * e = nullptr;
825  auto r = rs2_depth_frame_get_units( get(), &e );
826  error::handle( e );
827  return r;
828  }
829  };
830 
832  {
833  public:
839  : depth_frame(f)
840  {
841  rs2_error* e = nullptr;
842  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DISPARITY_FRAME, &e) == 0 && !e))
843  {
844  reset();
845  }
846  error::handle(e);
847  }
852  float get_baseline(void) const
853  {
854  rs2_error * e = nullptr;
855  auto r = rs2_depth_stereo_frame_get_baseline(get(), &e);
856  error::handle(e);
857  return r;
858  }
859  };
860 
861  class motion_frame : public frame
862  {
863  public:
868  motion_frame(const frame& f)
869  : frame(f)
870  {
871  rs2_error* e = nullptr;
872  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_MOTION_FRAME, &e) == 0 && !e))
873  {
874  reset();
875  }
876  error::handle(e);
877  }
883  {
884  auto data = reinterpret_cast<const float*>(get_data());
885  return rs2_vector{ data[0], data[1], data[2] };
886  }
887  };
888 
889  class pose_frame : public frame
890  {
891  public:
896  pose_frame(const frame& f)
897  : frame(f)
898  {
899  rs2_error* e = nullptr;
900  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_POSE_FRAME, &e) == 0 && !e))
901  {
902  reset();
903  }
904  error::handle(e);
905  }
911  {
912  rs2_pose pose_data;
913  rs2_error* e = nullptr;
914  rs2_pose_frame_get_pose_data(get(), &pose_data, &e);
915  error::handle(e);
916  return pose_data;
917  }
918  };
919 
920  class frameset : public frame
921  {
922  public:
926  frameset() :_size(0) {};
931  frameset(const frame& f)
932  : frame(f), _size(0)
933  {
934  rs2_error* e = nullptr;
935  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_COMPOSITE_FRAME, &e) == 0 && !e))
936  {
937  reset();
938  // TODO - consider explicit constructor to move resultion to compile time
939  }
940  error::handle(e);
941 
942  if (get())
943  {
944  _size = rs2_embedded_frames_count(get(), &e);
945  error::handle(e);
946  }
947  }
948 
956  {
957  frame result;
958  foreach_rs([&result, s, f](frame frm) {
959  if (!result && frm.get_profile().stream_type() == s && (f == RS2_FORMAT_ANY || f == frm.get_profile().format()))
960  {
961  result = std::move(frm);
962  }
963  });
964  return result;
965  }
973  {
974  auto frm = first_or_default(s, f);
975  if (!frm) throw error("Frame of requested stream type was not found!");
976  return frm;
977  }
978 
984  {
986  return f.as<depth_frame>();
987  }
993  {
995 
996  if (!f)
997  {
999  if (ir && ir.get_profile().format() == RS2_FORMAT_RGB8)
1000  f = ir;
1001  }
1002  return f;
1003  }
1009  video_frame get_infrared_frame(const size_t index = 0) const
1010  {
1011  frame f;
1012  if (!index)
1013  {
1015  }
1016  else
1017  {
1018  foreach_rs([&f, index](const frame& frm) {
1019  if (frm.get_profile().stream_type() == RS2_STREAM_INFRARED &&
1020  frm.get_profile().stream_index() == index) f = frm;
1021  });
1022  }
1023  return f;
1024  }
1025 
1031  video_frame get_fisheye_frame(const size_t index = 0) const
1032  {
1033  frame f;
1034  if (!index)
1035  {
1037  }
1038  else
1039  {
1040  foreach_rs([&f, index](const frame& frm) {
1041  if (frm.get_profile().stream_type() == RS2_STREAM_FISHEYE &&
1042  frm.get_profile().stream_index() == index) f = frm;
1043  });
1044  }
1045  return f;
1046  }
1047 
1053  pose_frame get_pose_frame(const size_t index = 0) const
1054  {
1055  frame f;
1056  if (!index)
1057  {
1059  }
1060  else
1061  {
1062  foreach_rs([&f, index](const frame& frm) {
1063  if (frm.get_profile().stream_type() == RS2_STREAM_POSE &&
1064  frm.get_profile().stream_index() == index) f = frm;
1065  });
1066  }
1067  return f.as<pose_frame>();
1068  }
1069 
1074  size_t size() const
1075  {
1076  return _size;
1077  }
1078 
1083  template<class T>
1084  void foreach_rs(T action) const
1085  {
1086  rs2_error* e = nullptr;
1087  auto count = size();
1088  for (size_t i = 0; i < count; i++)
1089  {
1090  auto fref = rs2_extract_frame(get(), (int)i, &e);
1091  error::handle(e);
1092 
1093  action(frame(fref));
1094  }
1095  }
1101  frame operator[](size_t index) const
1102  {
1103  rs2_error* e = nullptr;
1104  if (index < size())
1105  {
1106  auto fref = rs2_extract_frame(get(), (int)index, &e);
1107  error::handle(e);
1108  return frame(fref);
1109  }
1110 
1111  throw error("Requested index is out of range!");
1112  }
1113 
1114  class iterator : public std::iterator<std::forward_iterator_tag, frame>
1115  {
1116  public:
1117  iterator(const frameset* owner, size_t index = 0) : _index(index), _owner(owner) {}
1118  iterator& operator++() { ++_index; return *this; }
1119  bool operator==(const iterator& other) const { return _index == other._index; }
1120  bool operator!=(const iterator& other) const { return !(*this == other); }
1121 
1122  frame operator*() { return (*_owner)[_index]; }
1123  private:
1124  size_t _index = 0;
1125  const frameset* _owner;
1126  };
1127 
1128  iterator begin() const { return iterator(this); }
1129  iterator end() const { return iterator(this, size()); }
1130  private:
1131  size_t _size;
1132  };
1133 
1134  template<class T>
1136  {
1137  T on_frame_function;
1138  public:
1139  explicit frame_callback(T on_frame) : on_frame_function(on_frame) {}
1140 
1141  void on_frame(rs2_frame* fref) override
1142  {
1143  on_frame_function(frame{ fref });
1144  }
1145 
1146  void release() override { delete this; }
1147  };
1148 }
1149 #endif // LIBREALSENSE_RS2_FRAME_HPP
Definition: rs_types.hpp:85
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:259
Definition: rs_frame.hpp:275
iterator begin() const
Definition: rs_frame.hpp:1128
frame apply_filter(filter_interface &filter)
Definition: rs_frame.hpp:586
Definition: rs_frame.hpp:22
int get_bytes_per_pixel() const
Definition: rs_frame.hpp:700
depth_frame(const frame &f)
Definition: rs_frame.hpp:793
Definition: rs_frame.hpp:629
Definition: rs_types.hpp:25
void rs2_export_to_ply(const rs2_frame *frame, const char *fname, rs2_frame *texture, rs2_error **error)
Definition: rs_sensor.hpp:103
float rs2_depth_frame_get_units(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:336
void release() override
Definition: rs_frame.hpp:1146
void add_ref() const
Definition: rs_frame.hpp:597
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:972
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:297
int _uid
Definition: rs_frame.hpp:193
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:145
void rs2_get_video_stream_resolution(const rs2_stream_profile *mode, int *width, int *height, rs2_error **error)
Definition: rs_frame.hpp:712
void register_extrinsics_to(const stream_profile &to, rs2_extrinsics extrinsics)
Definition: rs_frame.hpp:162
frame operator*()
Definition: rs_frame.hpp:1122
Definition: rs_frame.hpp:307
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:926
float y
Definition: rs_frame.hpp:704
int _index
Definition: rs_frame.hpp:192
Definition: rs_sensor.h:48
Definition: rs_sensor.h:62
pose_frame get_pose_frame(const size_t index=0) const
Definition: rs_frame.hpp:1053
Definition: rs_sensor.h:52
Definition: rs_types.h:147
frame(frame &&other) noexcept
Definition: rs_frame.hpp:371
Definition: rs_frame.hpp:920
bool is() const
Definition: rs_frame.hpp:92
void export_to_ply(const std::string &fname, video_frame texture)
Definition: rs_frame.hpp:757
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:467
bool is() const
Definition: rs_frame.hpp:563
size_t size() const
Definition: rs_frame.hpp:777
float u
Definition: rs_frame.hpp:708
video_frame get_color_frame() const
Definition: rs_frame.hpp:992
int rs2_supports_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
Definition: rs_processing.hpp:233
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:704
int fps() const
Definition: rs_frame.hpp:49
void reset()
Definition: rs_frame.hpp:604
iterator & operator++()
Definition: rs_frame.hpp:1118
struct rs2_sensor rs2_sensor
Definition: rs_types.h:241
Definition: rs_sensor.h:46
rs2_extrinsics get_extrinsics_to(const stream_profile &to) const
Definition: rs_frame.hpp:148
int rs2_get_frame_height(const rs2_frame *frame, rs2_error **error)
std::shared_ptr< rs2_stream_profile > _clone
Definition: rs_frame.hpp:190
pose_frame(const frame &f)
Definition: rs_frame.hpp:896
void swap(frame &other)
Definition: rs_frame.hpp:406
Definition: rs_types.h:155
Definition: rs_frame.hpp:1114
frame & operator=(frame other)
Definition: rs_frame.hpp:383
Definition: rs_sensor.h:66
Definition: rs_frame.hpp:861
frame_callback(T on_frame)
Definition: rs_frame.hpp:1139
int rs2_get_frame_stride_in_bytes(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:1135
rs2_vector get_motion_data() const
Definition: rs_frame.hpp:882
frame(rs2_frame *ref)
Definition: rs_frame.hpp:347
const rs2_stream_profile * _profile
Definition: rs_frame.hpp:189
frame first_or_default(rs2_stream s, rs2_format f=RS2_FORMAT_ANY) const
Definition: rs_frame.hpp:955
rs2::frame process(rs2::frame frame) const override
Definition: rs_processing.hpp:352
video_frame(const frame &f)
Definition: rs_frame.hpp:636
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:718
float get_distance(int x, int y) const
Definition: rs_frame.hpp:810
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:194
Definition: rs_types.h:148
motion_frame(const frame &f)
Definition: rs_frame.hpp:868
~frame()
Definition: rs_frame.hpp:419
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:1101
Definition: rs_types.h:146
rs2_timestamp_domain rs2_get_frame_timestamp_domain(const rs2_frame *frameset, rs2_error **error)
Definition: rs_types.h:108
rs2_format _format
Definition: rs_frame.hpp:195
void rs2_delete_stream_profile(rs2_stream_profile *mode)
motion_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:282
Definition: rs_types.h:154
void foreach_rs(T action) const
Definition: rs_frame.hpp:1084
rs2_timestamp_domain get_frame_timestamp_domain() const
Definition: rs_frame.hpp:478
T as() const
Definition: rs_frame.hpp:103
T as() const
Definition: rs_frame.hpp:573
video_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:208
struct rs2_stream_profile rs2_stream_profile
Definition: rs_types.h:228
Definition: rs_sensor.h:61
virtual ~filter_interface()=default
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
Definition: rs_processing.hpp:412
bool is_default() const
Definition: rs_frame.hpp:125
void keep()
Definition: rs_frame.hpp:430
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:1009
const texture_coordinate * get_texture_coordinates() const
Definition: rs_frame.hpp:769
int get_bits_per_pixel() const
Definition: rs_frame.hpp:688
bool operator==(const iterator &other) const
Definition: rs_frame.hpp:1119
static void handle(rs2_error *e)
Definition: rs_types.hpp:137
Definition: rs_sensor.h:45
rs2_sensor * get_sensor()
Definition: rs_frame.hpp:438
int rs2_get_frame_data_size(const rs2_frame *frame, rs2_error **error)
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
Definition: rs_processing.hpp:343
int get_height() const
Definition: rs_frame.hpp:664
const rs2_stream_profile * get() const
Definition: rs_frame.hpp:137
bool _default
Definition: rs_frame.hpp:198
Definition: rs_frame.hpp:831
void rs2_get_video_stream_intrinsics(const rs2_stream_profile *mode, rs2_intrinsics *intrinsics, rs2_error **error)
Definition: rs_sensor.h:47
unsigned long long get_frame_number() const
Definition: rs_frame.hpp:514
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:95
Definition: rs_types.h:144
iterator end() const
Definition: rs_frame.hpp:1129
iterator(const frameset *owner, size_t index=0)
Definition: rs_frame.hpp:1117
bool is_cloned()
Definition: rs_frame.hpp:169
3D vector in Euclidean coordinate space
Definition: rs_types.h:97
virtual rs2::frame process(rs2::frame frame) const =0
int get_width() const
Definition: rs_frame.hpp:652
const void * get_data() const
Definition: rs_frame.hpp:538
const char * rs2_stream_to_string(rs2_stream stream)
void on_frame(rs2_frame *fref) override
Definition: rs_frame.hpp:1141
Definition: rs_sensor.h:44
long long rs2_metadata_type
Definition: rs_types.h:256
float get_units() const
Definition: rs_frame.hpp:822
points(const frame &f)
Definition: rs_frame.hpp:724
Definition: rs_frame.hpp:329
Definition: rs_types.h:151
int get_stride_in_bytes() const
Definition: rs_frame.hpp:676
rs2_vertex * rs2_get_frame_vertices(const rs2_frame *frame, rs2_error **error)
disparity_frame(const frame &f)
Definition: rs_frame.hpp:838
int width() const
Definition: rs_frame.hpp:225
void rs2_frame_add_ref(rs2_frame *frame, rs2_error **error)
Video stream intrinsics.
Definition: rs_types.h:58
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:597
int height() const
Definition: rs_frame.hpp:230
rs2_pose get_pose_data() const
Definition: rs_frame.hpp:910
bool operator!=(const iterator &other) const
Definition: rs_frame.hpp:1120
bool operator==(const stream_profile &rhs)
Definition: rs_frame.hpp:79
Motion device intrinsics: scale, bias, and variances.
Definition: rs_types.h:71
depth_frame get_depth_frame() const
Definition: rs_frame.hpp:983
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:170
void rs2_release_frame(rs2_frame *frame)
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:490
frameset(const frame &f)
Definition: rs_frame.hpp:931
Definition: rs_frame.hpp:707
rs2_frame * rs2_extract_frame(rs2_frame *composite, int index, rs2_error **error)
size_t size() const
Definition: rs_frame.hpp:1074
Definition: rs_types.h:156
rs2_metadata_type rs2_get_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
Definition: rs_types.h:157
struct rs2_error rs2_error
Definition: rs_types.h:217
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:502
rs2_stream stream_type() const
Definition: rs_frame.hpp:39
float x
Definition: rs_frame.hpp:704
Definition: rs_frame.hpp:201
Definition: rs_frame.hpp:889
frame(const frame &other)
Definition: rs_frame.hpp:393
rs2_intrinsics get_intrinsics() const
Definition: rs_frame.hpp:238
const int get_data_size() const
Definition: rs_frame.hpp:526
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:1031
rs2_frame * get() const
Definition: rs_frame.hpp:583
void rs2_pose_frame_get_pose_data(const rs2_frame *frame, rs2_pose *pose, rs2_error **error)
frame()
Definition: rs_frame.hpp:342
float v
Definition: rs_frame.hpp:708
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:220
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)
float get_baseline(void) const
Definition: rs_frame.hpp:852
pose_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:314
rs2_stream _type
Definition: rs_frame.hpp:196
Definition: rs_frame.hpp:703
stream_profile get_profile() const
Definition: rs_frame.hpp:550
const vertex * get_vertices() const
Definition: rs_frame.hpp:744
Definition: rs_frame.hpp:786
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