RealSense Cross Platform API
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 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 
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 (!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  }
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 (!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;
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 (!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 
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 
823  class labeled_points : public frame
824  {
825  public:
829  labeled_points() : frame(), _size(0) {}
830 
836  : frame(f), _size(0)
837  {
838  rs2_error* e = nullptr;
839  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_LABELED_POINTS, &e) == 0 && !e))
840  {
841  reset();
842  }
843  error::handle(e);
844 
845  if (get())
846  {
847  _size = rs2_get_frame_labeled_points_count(get(), &e);
848  error::handle(e);
849  }
850  }
851 
856  const vertex* get_vertices() const
857  {
858  rs2_error* e = nullptr;
859  auto res = rs2_get_frame_labeled_vertices(get(), &e);
860  error::handle(e);
861  return (const vertex*)res;
862  }
863 
868  const uint8_t* get_labels() const
869  {
870  rs2_error* e = nullptr;
871  auto res = rs2_get_frame_labels(get(), &e);
872  error::handle(e);
873  return (uint8_t * )res;
874  }
875 
876  // Returns the vertices counts
877  size_t size() const
878  {
879  return _size;
880  }
881 
886  unsigned int get_width() const
887  {
888  rs2_error* e = nullptr;
889  auto r = rs2_get_frame_labeled_points_width(get(), &e);
890  error::handle(e);
891  return r;
892  }
893 
898  unsigned int get_height() const
899  {
900  rs2_error* e = nullptr;
901  auto r = rs2_get_frame_labeled_points_height(get(), &e);
902  error::handle(e);
903  return r;
904  }
905 
910  unsigned int get_bits_per_pixel() const
911  {
912  rs2_error* e = nullptr;
914  error::handle(e);
915  return r;
916  }
917 
918  private:
919  size_t _size;
920  };
921 
922  class depth_frame : public video_frame
923  {
924  public:
929  depth_frame(const frame& f)
930  : video_frame(f)
931  {
932  rs2_error* e = nullptr;
933  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DEPTH_FRAME, &e) == 0 && !e))
934  {
935  reset();
936  }
937  error::handle(e);
938  }
939 
946  float get_distance(int x, int y) const
947  {
948  rs2_error * e = nullptr;
949  auto r = rs2_depth_frame_get_distance(get(), x, y, &e);
950  error::handle(e);
951  return r;
952  }
953 
958  float get_units() const
959  {
960  rs2_error * e = nullptr;
961  auto r = rs2_depth_frame_get_units( get(), &e );
962  error::handle( e );
963  return r;
964  }
965  };
966 
968  {
969  public:
975  : depth_frame(f)
976  {
977  rs2_error* e = nullptr;
978  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_DISPARITY_FRAME, &e) == 0 && !e))
979  {
980  reset();
981  }
982  error::handle(e);
983  }
988  float get_baseline(void) const
989  {
990  rs2_error * e = nullptr;
991  auto r = rs2_depth_stereo_frame_get_baseline(get(), &e);
992  error::handle(e);
993  return r;
994  }
995  };
996 
997  class motion_frame : public frame
998  {
999  public:
1005  : frame(f)
1006  {
1007  rs2_error* e = nullptr;
1008  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_MOTION_FRAME, &e) == 0 && !e))
1009  {
1010  reset();
1011  }
1012  error::handle(e);
1013  }
1020  {
1021  auto data = reinterpret_cast<const float*>(get_data());
1022  return rs2_vector{ data[0], data[1], data[2] };
1023  }
1030  {
1031  return *reinterpret_cast< rs2_combined_motion const * >( get_data() );
1032  }
1033  };
1034 
1035  class pose_frame : public frame
1036  {
1037  public:
1042  pose_frame(const frame& f)
1043  : frame(f)
1044  {
1045  rs2_error* e = nullptr;
1046  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_POSE_FRAME, &e) == 0 && !e))
1047  {
1048  reset();
1049  }
1050  error::handle(e);
1051  }
1057  {
1058  rs2_pose pose_data;
1059  rs2_error* e = nullptr;
1060  rs2_pose_frame_get_pose_data(get(), &pose_data, &e);
1061  error::handle(e);
1062  return pose_data;
1063  }
1064  };
1065 
1066  class frameset : public frame
1067  {
1068  public:
1072  frameset() :_size(0) {};
1077  frameset(const frame& f)
1078  : frame(f), _size(0)
1079  {
1080  rs2_error* e = nullptr;
1081  if (!f || (rs2_is_frame_extendable_to(f.get(), RS2_EXTENSION_COMPOSITE_FRAME, &e) == 0 && !e))
1082  {
1083  reset();
1084  // TODO - consider explicit constructor to move resultion to compile time
1085  }
1086  error::handle(e);
1087 
1088  if (get())
1089  {
1090  _size = rs2_embedded_frames_count(get(), &e);
1091  error::handle(e);
1092  }
1093  }
1094 
1102  {
1103  frame result;
1104  foreach_rs([&result, s, f](frame frm) {
1105  if (!result && frm.get_profile().stream_type() == s && (f == RS2_FORMAT_ANY || f == frm.get_profile().format()))
1106  {
1107  result = std::move(frm);
1108  }
1109  });
1110  return result;
1111  }
1119  {
1120  auto frm = first_or_default(s, f);
1121  if (!frm) throw error("Frame of requested stream type was not found!");
1122  return frm;
1123  }
1124 
1130  {
1132  return f.as<depth_frame>();
1133  }
1138  video_frame get_color_frame( const size_t index = 0 ) const
1139  {
1140  frame f;
1141 
1142  foreach_rs( [&f, index]( const frame & frm ) {
1143  if( !f && frm.get_profile().stream_type() == RS2_STREAM_COLOR &&
1144  frm.get_profile().stream_index() == index )
1145  f = frm;
1146  } );
1147 
1148  if( ! f )
1149  {
1150  // Color frame can also come from infrared sensor
1151  foreach_rs( [&f, index]( const frame & frm ) {
1152  if( !f && frm.get_profile().stream_type() == RS2_STREAM_INFRARED &&
1153  frm.get_profile().stream_index() == index &&
1154  frm.get_profile().format() == RS2_FORMAT_RGB8 )
1155  f = frm;
1156  } );
1157  }
1158 
1159  return f;
1160  }
1161 
1163  {
1165 
1166  return f.as<labeled_points>();
1167  }
1173  video_frame get_infrared_frame(const size_t index = 0) const
1174  {
1175  frame f;
1176  if (!index)
1177  {
1179  }
1180  else
1181  {
1182  foreach_rs([&f, index](const frame& frm) {
1183  if( !f && frm.get_profile().stream_type() == RS2_STREAM_INFRARED &&
1184  frm.get_profile().stream_index() == index )
1185  f = frm;
1186  });
1187  }
1188  return f;
1189  }
1190 
1196  video_frame get_fisheye_frame(const size_t index = 0) const
1197  {
1198  frame f;
1199  if (!index)
1200  {
1202  }
1203  else
1204  {
1205  foreach_rs([&f, index](const frame& frm) {
1206  if (frm.get_profile().stream_type() == RS2_STREAM_FISHEYE &&
1207  frm.get_profile().stream_index() == index) f = frm;
1208  });
1209  }
1210  return f;
1211  }
1212 
1218  pose_frame get_pose_frame(const size_t index = 0) const
1219  {
1220  frame f;
1221  if (!index)
1222  {
1224  }
1225  else
1226  {
1227  foreach_rs([&f, index](const frame& frm) {
1228  if (frm.get_profile().stream_type() == RS2_STREAM_POSE &&
1229  frm.get_profile().stream_index() == index) f = frm;
1230  });
1231  }
1232  return f.as<pose_frame>();
1233  }
1234 
1239  size_t size() const
1240  {
1241  return _size;
1242  }
1243 
1248  template<class T>
1249  void foreach_rs(T action) const
1250  {
1251  rs2_error* e = nullptr;
1252  auto count = size();
1253  for (size_t i = 0; i < count; i++)
1254  {
1255  auto fref = rs2_extract_frame(get(), (int)i, &e);
1256  error::handle(e);
1257 
1258  action(frame(fref));
1259  }
1260  }
1266  frame operator[](size_t index) const
1267  {
1268  rs2_error* e = nullptr;
1269  if (index < size())
1270  {
1271  auto fref = rs2_extract_frame(get(), (int)index, &e);
1272  error::handle(e);
1273  return frame(fref);
1274  }
1275 
1276  throw error("Requested index is out of range!");
1277  }
1278 
1279  class iterator
1280  {
1281  public:
1282  // inheriting from std::iterator template is deprecated in C++17, this is the new way to define an iterator
1283  // go to https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/ for more info
1284  using iterator_category = std::forward_iterator_tag;
1286  using difference_type = std::ptrdiff_t;
1287  using pointer = frame*;
1288  using reference = frame&;
1289 
1290  iterator(const frameset* owner, size_t index = 0) : _index(index), _owner(owner) {}
1291  iterator& operator++() { ++_index; return *this; }
1292  bool operator==(const iterator& other) const { return _index == other._index; }
1293  bool operator!=(const iterator& other) const { return !(*this == other); }
1294 
1295  frame operator*() { return (*_owner)[_index]; }
1296  private:
1297  size_t _index = 0;
1298  const frameset* _owner;
1299  };
1300 
1301  iterator begin() const { return iterator(this); }
1302  iterator end() const { return iterator(this, size()); }
1303  private:
1304  size_t _size;
1305  };
1306 
1307  template<class T>
1309  {
1310  T on_frame_function;
1311  public:
1312  explicit frame_callback(T on_frame) : on_frame_function(on_frame) {}
1313 
1314  void on_frame(rs2_frame* fref) override
1315  {
1316  on_frame_function(frame{ fref });
1317  }
1318 
1319  void release() override { delete this; }
1320  };
1321 }
1322 #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:1301
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:929
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:103
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:1319
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:1118
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:1295
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:1072
float y
Definition: rs_frame.hpp:740
int _index
Definition: rs_frame.hpp:201
Definition: rs_sensor.h:52
Definition: rs_sensor.h:70
const vertex * get_vertices() const
Definition: rs_frame.hpp:856
rs2_calib_target_type
Calibration target type.
Definition: rs_frame.h:169
pose_frame get_pose_frame(const size_t index=0) const
Definition: rs_frame.hpp:1218
Definition: rs_sensor.h:56
Definition: rs_types.h:150
frame(frame &&other) noexcept
Definition: rs_frame.hpp:389
Definition: rs_frame.hpp:1066
Definition: rs_types.h:198
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)
rs2_vertex * rs2_get_frame_labeled_vertices(const rs2_frame *frame, rs2_error **error)
double get_timestamp() const
Definition: rs_frame.hpp:485
labeled_points get_labeled_point_cloud_frame() const
Definition: rs_frame.hpp:1162
bool is() const
Definition: rs_frame.hpp:581
size_t size() const
Definition: rs_frame.hpp:813
float u
Definition: rs_frame.hpp:744
int rs2_supports_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
Definition: rs_processing.hpp:250
size_t size() const
Definition: rs_frame.hpp:877
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
Definition: rs_frame.hpp:823
void reset()
Definition: rs_frame.hpp:622
iterator & operator++()
Definition: rs_frame.hpp:1291
struct rs2_sensor rs2_sensor
Definition: rs_types.h:300
labeled_points(const frame &f)
Definition: rs_frame.hpp:835
Definition: rs_sensor.h:50
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:1042
void swap(frame &other)
Definition: rs_frame.hpp:424
Definition: rs_types.h:158
Definition: rs_frame.hpp:1279
frame & operator=(frame other)
Definition: rs_frame.hpp:401
Definition: rs_sensor.h:74
Definition: rs_frame.hpp:997
frame_callback(T on_frame)
Definition: rs_frame.hpp:1312
int rs2_get_frame_stride_in_bytes(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:1308
rs2_vector get_motion_data() const
Definition: rs_frame.hpp:1019
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:1101
rs2::frame process(rs2::frame frame) const override
Definition: rs_processing.hpp:369
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)
void * rs2_get_frame_labels(const rs2_frame *frame, rs2_error **error)
points()
Definition: rs_frame.hpp:754
std::forward_iterator_tag iterator_category
Definition: rs_frame.hpp:1284
float get_distance(int x, int y) const
Definition: rs_frame.hpp:946
video_frame get_color_frame(const size_t index=0) const
Definition: rs_frame.hpp:1138
Definition: rs_processing.hpp:17
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:1004
~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:1266
RS2_STREAM_MOTION / RS2_FORMAT_COMBINED_MOTION content is similar to ROS2&#39;s Imu message.
Definition: rs_sensor.h:115
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:1249
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:287
Definition: rs_sensor.h:69
unsigned int get_width() const
Definition: rs_frame.hpp:886
virtual ~filter_interface()=default
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:67
unsigned int rs2_get_frame_labeled_points_height(const rs2_frame *frame, rs2_error **error)
Definition: rs_processing.hpp:429
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:1173
const texture_coordinate * get_texture_coordinates() const
Definition: rs_frame.hpp:805
int get_bits_per_pixel() const
Definition: rs_frame.hpp:706
unsigned int get_height() const
Definition: rs_frame.hpp:898
bool operator==(const video_stream_profile &other) const
Definition: rs_frame.hpp:258
bool operator==(const iterator &other) const
Definition: rs_frame.hpp:1292
static void handle(rs2_error *e)
Definition: rs_types.hpp:167
Definition: rs_sensor.h:49
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:1029
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:46
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)
const uint8_t * get_labels() const
Definition: rs_frame.hpp:868
Definition: rs_processing.hpp:360
int get_height() const
Definition: rs_frame.hpp:682
unsigned int rs2_get_frame_labeled_points_bits_per_pixel(const rs2_frame *frame, rs2_error **error)
const rs2_stream_profile * get() const
Definition: rs_frame.hpp:146
bool _default
Definition: rs_frame.hpp:207
Definition: rs_frame.hpp:967
void rs2_get_video_stream_intrinsics(const rs2_stream_profile *mode, rs2_intrinsics *intrinsics, rs2_error **error)
Definition: rs_sensor.h:51
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:108
Definition: rs_types.h:147
iterator end() const
Definition: rs_frame.hpp:1302
iterator(const frameset *owner, size_t index=0)
Definition: rs_frame.hpp:1290
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:1314
Definition: rs_sensor.h:48
long long rs2_metadata_type
Definition: rs_types.h:324
float get_units() const
Definition: rs_frame.hpp:958
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
unsigned int rs2_get_frame_labeled_points_width(const rs2_frame *frame, rs2_error **error)
rs2_vertex * rs2_get_frame_vertices(const rs2_frame *frame, rs2_error **error)
disparity_frame(const frame &f)
Definition: rs_frame.hpp:974
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:672
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:1056
bool operator!=(const iterator &other) const
Definition: rs_frame.hpp:1293
unsigned int get_bits_per_pixel() const
Definition: rs_frame.hpp:910
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:1129
Definition: rs_processing.hpp:133
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:1077
Definition: rs_frame.hpp:743
int rs2_get_frame_labeled_points_count(const rs2_frame *frame, rs2_error **error)
rs2_frame * rs2_extract_frame(rs2_frame *composite, int index, rs2_error **error)
size_t size() const
Definition: rs_frame.hpp:1239
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
labeled_points()
Definition: rs_frame.hpp:829
struct rs2_error rs2_error
Definition: rs_types.h:276
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:1035
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:1196
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
Definition: rs_sensor.h:61
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:279
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)
std::ptrdiff_t difference_type
Definition: rs_frame.hpp:1286
float get_baseline(void) const
Definition: rs_frame.hpp:988
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:922
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