RealSense Cross Platform API
RealSense Cross-platform API
rs_processing.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_PROCESSING_HPP
5 #define LIBREALSENSE_RS2_PROCESSING_HPP
6 
7 #include "rs_frame.hpp"
8 #include "rs_options.hpp"
9 
10 namespace rs2
11 {
18  {
19  public:
33  const frame& original,
34  int new_bpp = 0,
35  int new_width = 0,
36  int new_height = 0,
37  int new_stride = 0,
38  rs2_extension frame_type = RS2_EXTENSION_VIDEO_FRAME) const
39  {
40  rs2_error* e = nullptr;
41  auto result = rs2_allocate_synthetic_video_frame(_source, profile.get(),
42  original.get(), new_bpp, new_width, new_height, new_stride, frame_type, &e);
43  error::handle(e);
44  return result;
45  }
46 
56  const frame& original,
57  rs2_extension frame_type = RS2_EXTENSION_MOTION_FRAME) const
58  {
59  rs2_error* e = nullptr;
60  auto result = rs2_allocate_synthetic_motion_frame(_source, profile.get(),
61  original.get(), frame_type, &e);
62  error::handle(e);
63  return result;
64  }
65 
67  const frame& original) const
68  {
69  rs2_error* e = nullptr;
70  auto result = rs2_allocate_points(_source, profile.get(), original.get(), &e);
71  error::handle(e);
72  return result;
73  }
74 
81  frame allocate_composite_frame(std::vector<frame> frames) const
82  {
83  rs2_error* e = nullptr;
84 
85  std::vector<rs2_frame*> refs(frames.size(), (rs2_frame*)nullptr);
86  for (size_t i = 0; i < frames.size(); i++)
87  std::swap(refs[i], frames[i].frame_ref);
88 
89  auto result = rs2_allocate_composite_frame(_source, refs.data(), (int)refs.size(), &e);
90  error::handle(e);
91  return result;
92  }
98  void frame_ready(frame result) const
99  {
100  rs2_error* e = nullptr;
101  rs2_synthetic_frame_ready(_source, result.get(), &e);
102  error::handle(e);
103  result.frame_ref = nullptr;
104  }
105 
107  private:
108  template<class T>
110 
111  frame_source(rs2_source* source) : _source(source) {}
112  frame_source(const frame_source&) = delete;
113 
114  };
115 
116  template<class T>
118  {
119  T on_frame_function;
120  public:
121  explicit frame_processor_callback(T on_frame) : on_frame_function(on_frame) {}
122 
123  void on_frame(rs2_frame* f, rs2_source * source) override
124  {
125  frame_source src(source);
126  frame frm(f);
127  on_frame_function(std::move(frm), src);
128  }
129 
130  void release() override { delete this; }
131  };
132 
134  {
135  public:
142  explicit frame_queue(unsigned int capacity, bool keep_frames = false) : _capacity(capacity), _keep(keep_frames)
143  {
144  rs2_error* e = nullptr;
145  _queue = std::shared_ptr<rs2_frame_queue>(
148  error::handle(e);
149  }
150 
152 
157  void enqueue(frame f) const
158  {
159  if (_keep) f.keep();
160  rs2_enqueue_frame(f.frame_ref, _queue.get()); // noexcept
161  f.frame_ref = nullptr; // frame has been essentially moved from
162  }
163 
168  frame wait_for_frame(unsigned int timeout_ms = 5000) const
169  {
170  rs2_error* e = nullptr;
171  auto frame_ref = rs2_wait_for_frame(_queue.get(), timeout_ms, &e);
172  error::handle(e);
173  return{ frame_ref };
174  }
175 
181  template<typename T>
182  typename std::enable_if<std::is_base_of<rs2::frame, T>::value, bool>::type poll_for_frame(T* output) const
183  {
184  rs2_error* e = nullptr;
185  rs2_frame* frame_ref = nullptr;
186  auto res = rs2_poll_for_frame(_queue.get(), &frame_ref, &e);
187  error::handle(e);
188  frame f{ frame_ref };
189  if (res) *output = f;
190  return res > 0;
191  }
192 
193  template<typename T>
194  typename std::enable_if<std::is_base_of<rs2::frame, T>::value, bool>::type try_wait_for_frame(T* output, unsigned int timeout_ms = 5000) const
195  {
196  rs2_error* e = nullptr;
197  rs2_frame* frame_ref = nullptr;
198  auto res = rs2_try_wait_for_frame(_queue.get(), timeout_ms, &frame_ref, &e);
199  error::handle(e);
200  frame f{ frame_ref };
201  if (res) *output = f;
202  return res > 0;
203  }
207  void operator()(frame f) const
208  {
209  enqueue(std::move(f));
210  }
211 
216  size_t size() const
217  {
218  rs2_error* e = nullptr;
219  auto res = rs2_frame_queue_size(_queue.get(), &e);
220  error::handle(e);
221  return static_cast<size_t>(res);
222  }
223 
228  size_t capacity() const { return _capacity; }
233  bool keep_frames() const { return _keep; }
234 
239  std::shared_ptr<rs2_frame_queue> get() { return _queue; }
240 
241  private:
242  std::shared_ptr<rs2_frame_queue> _queue;
243  size_t _capacity;
244  bool _keep;
245  };
246 
250  class processing_block : public options
251  {
252  public:
253  using options::supports;
254 
260  template<class S>
261  void start(S on_frame)
262  {
263  rs2_error* e = nullptr;
264  rs2_start_processing(get(), new frame_callback<S>(on_frame), &e);
265  error::handle(e);
266  }
273  template<class S>
274  S& operator>>(S& on_frame)
275  {
276  start(on_frame);
277  return on_frame;
278  }
284  void invoke(frame f) const
285  {
286  rs2_frame* ptr = nullptr;
287  std::swap(f.frame_ref, ptr);
288 
289  rs2_error* e = nullptr;
290  rs2_process_frame(get(), ptr, &e);
291  error::handle(e);
292  }
298  processing_block(std::shared_ptr<rs2_processing_block> block)
299  : options((rs2_options*)block.get()), _block(block)
300  {
301  }
302 
308  template<class S>
309  processing_block(S processing_function)
310  {
311  rs2_error* e = nullptr;
312  _block = std::shared_ptr<rs2_processing_block>(
313  rs2_create_processing_block(new frame_processor_callback<S>(processing_function), &e),
316  error::handle(e);
317  }
318 
319  operator rs2_options*() const { return (rs2_options*)get(); }
320  rs2_processing_block* get() const { return _block.get(); }
321 
327  bool supports(rs2_camera_info info) const
328  {
329  rs2_error* e = nullptr;
330  auto is_supported = rs2_supports_processing_block_info(_block.get(), info, &e);
331  error::handle(e);
332  return is_supported > 0;
333  }
334 
340  const char* get_info(rs2_camera_info info) const
341  {
342  rs2_error* e = nullptr;
343  auto result = rs2_get_processing_block_info(_block.get(), info, &e);
344  error::handle(e);
345  return result;
346  }
347  protected:
349  rs2_error * e = nullptr;
351  range.min, range.max, range.step, range.def, &e);
352  error::handle(e);
353  }
354  std::shared_ptr<rs2_processing_block> _block;
355  };
356 
360  class filter : public processing_block, public filter_interface
361  {
362  public:
370  {
371  invoke(frame);
372  rs2::frame f;
373  if (!_queue.poll_for_frame(&f))
374  throw std::runtime_error("Error occured during execution of the processing block! See the log for more info");
375  return f;
376  }
377 
383  filter(std::shared_ptr<rs2_processing_block> block, int queue_size = 1)
384  : processing_block(block),
385  _queue(queue_size)
386  {
387  start(_queue);
388  }
389 
395  template<class S>
396  filter(S processing_function, int queue_size = 1) :
397  processing_block(processing_function),
398  _queue(queue_size)
399  {
400  start(_queue);
401  }
402 
403 
405  rs2_processing_block* get() const { return _block.get(); }
406 
407  template<class T>
408  bool is() const
409  {
410  T extension(*this);
411  return extension;
412  }
413 
414  template<class T>
415  T as() const
416  {
417  T extension(*this);
418  return extension;
419  }
420 
421  operator bool() const { return _block.get() != nullptr; }
422  protected:
424  };
425 
429  class pointcloud : public filter
430  {
431  public:
435  pointcloud() : filter(init(), 1) {}
436 
437  pointcloud(rs2_stream stream, int index = 0) : filter(init(), 1)
438  {
439  set_option(RS2_OPTION_STREAM_FILTER, float(stream));
441  }
448  points calculate(frame depth) const
449  {
450  auto res = process(depth);
451  if (res.as<points>())
452  return res;
453 
454  if (auto set = res.as <frameset>())
455  {
456  for (auto f : set)
457  {
458  if(f.as<points>())
459  return f;
460  }
461  }
462  throw std::runtime_error("Error occured during execution of the processing block! See the log for more info");
463  }
469  void map_to(frame mapped)
470  {
474  process(mapped);
475  }
476 
477  protected:
478  pointcloud(std::shared_ptr<rs2_processing_block> block) : filter(block, 1) {}
479 
480  private:
481  friend class context;
482 
483  std::shared_ptr<rs2_processing_block> init()
484  {
485  rs2_error* e = nullptr;
486 
487  auto block = std::shared_ptr<rs2_processing_block>(
490 
491  error::handle(e);
492 
493  // Redirect options API to the processing block
494  //options::operator=(pb);
495  return block;
496  }
497  };
498 
499  class yuy_decoder : public filter
500  {
501  public:
510  yuy_decoder() : filter(init(), 1) { }
511 
512  protected:
513  yuy_decoder(std::shared_ptr<rs2_processing_block> block) : filter(block, 1) {}
514 
515  private:
516  std::shared_ptr<rs2_processing_block> init()
517  {
518  rs2_error* e = nullptr;
519  auto block = std::shared_ptr<rs2_processing_block>(
522  error::handle(e);
523 
524  return block;
525  }
526  };
527 
528  class m420_decoder : public filter
529  {
530  public:
542  m420_decoder() : filter(init(), 1) { }
543 
544  protected:
545  m420_decoder(std::shared_ptr<rs2_processing_block> block) : filter(block, 1) {}
546 
547  private:
548  std::shared_ptr<rs2_processing_block> init()
549  {
550  rs2_error* e = nullptr;
551  auto block = std::shared_ptr<rs2_processing_block>(
554  error::handle(e);
555 
556  return block;
557  }
558  };
559 
560  class y411_decoder : public filter
561  {
562  public:
569  y411_decoder() : filter(init()) { }
570 
571  protected:
572  y411_decoder(std::shared_ptr<rs2_processing_block> block) : filter(block) {}
573 
574  private:
575  static std::shared_ptr<rs2_processing_block> init()
576  {
577  rs2_error* e = nullptr;
578  auto block = std::shared_ptr<rs2_processing_block>(
581  error::handle(e);
582 
583  return block;
584  }
585  };
586  class threshold_filter : public filter
587  {
588  public:
594  threshold_filter(float min_dist = 0.15f, float max_dist = 4.f)
595  : filter(init(), 1)
596  {
599  }
600 
602  {
603  rs2_error* e = nullptr;
605  {
606  _block.reset();
607  }
608  error::handle(e);
609  }
610 
611  protected:
612  threshold_filter(std::shared_ptr<rs2_processing_block> block) : filter(block, 1) {}
613 
614  private:
615  std::shared_ptr<rs2_processing_block> init()
616  {
617  rs2_error* e = nullptr;
618  auto block = std::shared_ptr<rs2_processing_block>(
621  error::handle(e);
622 
623  return block;
624  }
625  };
626 
627  class units_transform : public filter
628  {
629  public:
633  units_transform() : filter(init(), 1) {}
634 
635  protected:
636  units_transform(std::shared_ptr<rs2_processing_block> block) : filter(block, 1) {}
637 
638  private:
639  std::shared_ptr<rs2_processing_block> init()
640  {
641  rs2_error* e = nullptr;
642  auto block = std::shared_ptr<rs2_processing_block>(
645  error::handle(e);
646 
647  return block;
648  }
649  };
650 
652  {
653  public:
658 
659  private:
660  std::shared_ptr<rs2_processing_block> init()
661  {
662  rs2_error* e = nullptr;
663  auto block = std::shared_ptr<rs2_processing_block>(
666 
667  error::handle(e);
668  return block;
669  }
670  };
671 
672  class syncer
673  {
674  public:
678  syncer(int queue_size = 1)
679  :_results(queue_size)
680  {
681  _sync.start(_results);
682  }
683 
689  frameset wait_for_frames(unsigned int timeout_ms = 5000) const
690  {
691  return frameset(_results.wait_for_frame(timeout_ms));
692  }
693 
699  bool poll_for_frames(frameset* fs) const
700  {
701  frame result;
702  if (_results.poll_for_frame(&result))
703  {
704  *fs = frameset(result);
705  return true;
706  }
707  return false;
708  }
709 
716  bool try_wait_for_frames(frameset* fs, unsigned int timeout_ms = 5000) const
717  {
718  frame result;
719  if (_results.try_wait_for_frame(&result, timeout_ms))
720  {
721  *fs = frameset(result);
722  return true;
723  }
724  return false;
725  }
726 
727  void operator()(frame f) const
728  {
729  _sync.invoke(std::move(f));
730  }
731  private:
732  asynchronous_syncer _sync;
733  frame_queue _results;
734  };
735 
739  class align : public filter
740  {
741  public:
751  align(rs2_stream align_to) : filter(init(align_to), 1) {}
752 
753  using filter::process;
754 
762  {
763  return filter::process(frames);
764  }
765 
766  protected:
767  align(std::shared_ptr<rs2_processing_block> block) : filter(block, 1) {}
768 
769  private:
770  friend class context;
771  std::shared_ptr<rs2_processing_block> init(rs2_stream align_to)
772  {
773  rs2_error* e = nullptr;
774  auto block = std::shared_ptr<rs2_processing_block>(
775  rs2_create_align(align_to, &e),
777  error::handle(e);
778 
779  return block;
780  }
781  };
782 
783  class colorizer : public filter
784  {
785  public:
790  colorizer() : filter(init(), 1) { }
806  colorizer(float color_scheme) : filter(init(), 1)
807  {
808  set_option(RS2_OPTION_COLOR_SCHEME, float(color_scheme));
809  }
816  {
817  return process(depth);
818  }
819 
820  protected:
821  colorizer(std::shared_ptr<rs2_processing_block> block) : filter(block, 1) {}
822 
823  private:
824  std::shared_ptr<rs2_processing_block> init()
825  {
826  rs2_error* e = nullptr;
827  auto block = std::shared_ptr<rs2_processing_block>(
830  error::handle(e);
831 
832  // Redirect options API to the processing block
833  //options::operator=(pb);
834 
835  return block;
836  }
837  };
838 
839  class decimation_filter : public filter
840  {
841  public:
846  decimation_filter() : filter(init(), 1) {}
852  decimation_filter(float magnitude) : filter(init(), 1)
853  {
855  }
856 
858  {
859  rs2_error* e = nullptr;
861  {
862  _block.reset();
863  }
864  error::handle(e);
865  }
866 
867  private:
868  friend class context;
869 
870  std::shared_ptr<rs2_processing_block> init()
871  {
872  rs2_error* e = nullptr;
873  auto block = std::shared_ptr<rs2_processing_block>(
876  error::handle(e);
877 
878  // Redirect options API to the processing block
879  //options::operator=(this);
880 
881  return block;
882  }
883  };
884 
885  class rotation_filter : public filter
886  {
887  public:
893  : filter( init( std::vector< rs2_stream >{ RS2_STREAM_DEPTH } ), 1 )
894  {
895  }
896 
897  rotation_filter( std::vector< rs2_stream > streams_to_rotate )
898  : filter( init( streams_to_rotate ), 1 )
899  {
900  }
901 
902  rotation_filter( std::vector< rs2_stream > streams_to_rotate, float value )
903  : filter( init( streams_to_rotate ), 1 )
904  {
906  }
907 
909  : filter( f )
910  {
911  rs2_error * e = nullptr;
913  {
914  _block.reset();
915  }
916  error::handle( e );
917  }
918 
919  private:
920  friend class context;
921 
922  std::shared_ptr< rs2_processing_block > init( std::vector< rs2_stream > streams_to_rotate )
923  {
924  rs2_error * e = nullptr;
925 
926  rs2_streams_list streams_list;
927  streams_list.list = std::move( streams_to_rotate );
928 
929  auto block = std::shared_ptr< rs2_processing_block >( rs2_create_rotation_filter_block( streams_list, &e ),
931  error::handle( e );
932  return block;
933  }
934  };
935 
936  class temporal_filter : public filter
937  {
938  public:
945  temporal_filter() : filter(init(), 1) {}
963  temporal_filter(float smooth_alpha, float smooth_delta, int persistence_control) : filter(init(), 1)
964  {
965  set_option(RS2_OPTION_HOLES_FILL, float(persistence_control));
966  set_option(RS2_OPTION_FILTER_SMOOTH_ALPHA, float(smooth_alpha));
967  set_option(RS2_OPTION_FILTER_SMOOTH_DELTA, float(smooth_delta));
968  }
969 
971  {
972  rs2_error* e = nullptr;
974  {
975  _block.reset();
976  }
977  error::handle(e);
978  }
979  private:
980  friend class context;
981 
982  std::shared_ptr<rs2_processing_block> init()
983  {
984  rs2_error* e = nullptr;
985  auto block = std::shared_ptr<rs2_processing_block>(
988  error::handle(e);
989 
990  // Redirect options API to the processing block
991  //options::operator=(pb);
992 
993  return block;
994  }
995  };
996 
997  class spatial_filter : public filter
998  {
999  public:
1007  spatial_filter() : filter(init(), 1) { }
1008 
1018  spatial_filter(float smooth_alpha, float smooth_delta, float magnitude, float hole_fill) : filter(init(), 1)
1019  {
1020  set_option(RS2_OPTION_FILTER_SMOOTH_ALPHA, float(smooth_alpha));
1021  set_option(RS2_OPTION_FILTER_SMOOTH_DELTA, float(smooth_delta));
1023  set_option(RS2_OPTION_HOLES_FILL, hole_fill);
1024  }
1025 
1027  {
1028  rs2_error* e = nullptr;
1030  {
1031  _block.reset();
1032  }
1033  error::handle(e);
1034  }
1035  private:
1036  friend class context;
1037 
1038  std::shared_ptr<rs2_processing_block> init()
1039  {
1040  rs2_error* e = nullptr;
1041  auto block = std::shared_ptr<rs2_processing_block>(
1044  error::handle(e);
1045 
1046  // Redirect options API to the processing block
1047  //options::operator=(pb);
1048 
1049  return block;
1050  }
1051  };
1052 
1054  {
1055  public:
1060  disparity_transform(bool transform_to_disparity = true) : filter(init(transform_to_disparity), 1) { }
1061 
1063  {
1064  rs2_error* e = nullptr;
1066  {
1067  _block.reset();
1068  }
1069  error::handle(e);
1070  }
1071  private:
1072  friend class context;
1073  std::shared_ptr<rs2_processing_block> init(bool transform_to_disparity)
1074  {
1075  rs2_error* e = nullptr;
1076  auto block = std::shared_ptr<rs2_processing_block>(
1077  rs2_create_disparity_transform_block(uint8_t(transform_to_disparity), &e),
1079  error::handle(e);
1080 
1081  // Redirect options API to the processing block
1082  //options::operator=(pb);
1083 
1084  return block;
1085  }
1086  };
1087 
1089  {
1090  public:
1095  {}
1096 
1098  {
1099  rs2_error* e = nullptr;
1101  {
1102  _block.reset();
1103  }
1104  error::handle(e);
1105  }
1106 
1107  private:
1108  friend class context;
1109 
1110  std::shared_ptr<rs2_processing_block> init()
1111  {
1112  rs2_error* e = nullptr;
1113  auto block = std::shared_ptr<rs2_processing_block>(
1116  error::handle(e);
1117 
1118  return block;
1119  }
1120  };
1121 
1123  {
1124  public:
1129  hole_filling_filter() : filter(init(), 1) {}
1130 
1139  hole_filling_filter(int mode) : filter(init(), 1)
1140  {
1141  set_option(RS2_OPTION_HOLES_FILL, float(mode));
1142  }
1143 
1145  {
1146  rs2_error* e = nullptr;
1148  {
1149  _block.reset();
1150  }
1151  error::handle(e);
1152  }
1153  private:
1154  friend class context;
1155 
1156  std::shared_ptr<rs2_processing_block> init()
1157  {
1158  rs2_error* e = nullptr;
1159  auto block = std::shared_ptr<rs2_processing_block>(
1162  error::handle(e);
1163 
1164  // Redirect options API to the processing block
1165  //options::operator=(_block);
1166 
1167  return block;
1168  }
1169  };
1170 
1171  class rates_printer : public filter
1172  {
1173  public:
1178  rates_printer() : filter(init(), 1) {}
1179 
1180  private:
1181  friend class context;
1182 
1183  std::shared_ptr<rs2_processing_block> init()
1184  {
1185  rs2_error* e = nullptr;
1186  auto block = std::shared_ptr<rs2_processing_block>(
1189  error::handle(e);
1190 
1191  return block;
1192  }
1193  };
1194 
1195  class hdr_merge : public filter
1196  {
1197  public:
1203  hdr_merge() : filter(init()) {}
1204 
1206  {
1207  rs2_error* e = nullptr;
1209  {
1210  _block.reset();
1211  }
1212  error::handle(e);
1213  }
1214 
1215  private:
1216  friend class context;
1217 
1218  std::shared_ptr<rs2_processing_block> init()
1219  {
1220  rs2_error* e = nullptr;
1221  auto block = std::shared_ptr<rs2_processing_block>(
1224  error::handle(e);
1225 
1226  return block;
1227  }
1228  };
1229 
1231  {
1232  public:
1238 
1244  sequence_id_filter(float sequence_id) : filter(init(), 1)
1245  {
1246  set_option(RS2_OPTION_SEQUENCE_ID, sequence_id);
1247  }
1248 
1250  {
1251  rs2_error* e = nullptr;
1253  {
1254  _block.reset();
1255  }
1256  error::handle(e);
1257  }
1258 
1259  private:
1260  friend class context;
1261 
1262  std::shared_ptr<rs2_processing_block> init()
1263  {
1264  rs2_error* e = nullptr;
1265  auto block = std::shared_ptr<rs2_processing_block>(
1268  error::handle(e);
1269 
1270  return block;
1271  }
1272  };
1273 
1274 
1275  class embedded_filter : public options
1276  {
1277  public:
1278  embedded_filter(std::shared_ptr<rs2_embedded_filter> filter)
1280  , options((rs2_options*)filter.get())
1281  {
1282  }
1283 
1285  {
1286  rs2_error* e = nullptr;
1287  auto filter_type = rs2_get_embedded_filter_type(_embedded_filter.get(), &e);
1288  error::handle(e);
1289  return filter_type;
1290  }
1291 
1292  operator bool() const
1293  {
1294  return _embedded_filter != nullptr;
1295  }
1296 
1297  const std::shared_ptr<rs2_embedded_filter>& get() const
1298  {
1299  return _embedded_filter;
1300  }
1301 
1302  template<class T>
1303  bool is() const
1304  {
1305  T extension(*this);
1306  return extension;
1307  }
1308 
1309  template<class T>
1310  T as() const
1311  {
1312  T extension(*this);
1313  return extension;
1314  }
1315 
1316  protected:
1317  std::shared_ptr<rs2_embedded_filter> _embedded_filter;
1318  };
1319 
1321  {
1322  public:
1325  {
1326  rs2_error* e = nullptr;
1329  {
1330  _embedded_filter.reset();
1331  }
1332  error::handle(e);
1333  }
1334  operator bool() const { return _embedded_filter.get() != nullptr; }
1335  };
1336 
1338  {
1339  public:
1342  {
1343  rs2_error* e = nullptr;
1345  RS2_EXTENSION_TEMPORAL_EMBEDDED_FILTER, &e) == 0 && !e))
1346  {
1347  _embedded_filter.reset();
1348  }
1349  error::handle(e);
1350  }
1351  operator bool() const { return _embedded_filter.get() != nullptr; }
1352  };
1353 }
1354 #endif // LIBREALSENSE_RS2_PROCESSING_HPP
decimation_filter()
Definition: rs_processing.hpp:846
Definition: rs_types.h:195
rs2_processing_block * rs2_create_decimation_filter_block(rs2_error **error)
Definition: rs_frame.hpp:22
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
Definition: rs_sensor.h:22
Definition: rs_frame.hpp:647
Definition: rs_frame.hpp:354
threshold_filter(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:612
rs2_processing_block * rs2_create_threshold(rs2_error **error)
bool supports(rs2_option option) const
Definition: rs_options.hpp:163
Definition: rs_processing.hpp:651
size_t size() const
Definition: rs_processing.hpp:216
rs2_processing_block * rs2_create_m420_decoder(rs2_error **error)
std::shared_ptr< rs2_processing_block > _block
Definition: rs_processing.hpp:354
y411_decoder()
Definition: rs_processing.hpp:569
rs2_frame * rs2_allocate_composite_frame(rs2_source *source, rs2_frame **frames, int count, rs2_error **error)
hole_filling_filter(filter f)
Definition: rs_processing.hpp:1144
Definition: rs_processing.hpp:1337
bool supports(rs2_camera_info info) const
Definition: rs_processing.hpp:327
Definition: rs_types.h:168
Definition: rs_processing.hpp:997
Definition: rs_processing.hpp:1122
Definition: rs_option.h:61
threshold_filter(filter f)
Definition: rs_processing.hpp:601
hdr_merge(filter f)
Definition: rs_processing.hpp:1205
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:26
Definition: rs_types.h:166
std::enable_if< std::is_base_of< rs2::frame, T >::value, bool >::type poll_for_frame(T *output) const
Definition: rs_processing.hpp:182
rs2_embedded_filter_type get_type() const
Definition: rs_processing.hpp:1284
Definition: rs_types.h:167
depth_huffman_decoder()
Definition: rs_processing.hpp:1094
rs2_frame * rs2_allocate_points(rs2_source *source, const rs2_stream_profile *new_stream, rs2_frame *original, rs2_error **error)
rs2_processing_block * rs2_create_units_transform(rs2_error **error)
bool keep_frames() const
Definition: rs_processing.hpp:233
void rs2_start_processing(rs2_processing_block *block, rs2_frame_callback *on_frame, rs2_error **error)
rs2_format format() const
Definition: rs_frame.hpp:44
Definition: rs_types.h:169
Definition: rs_types.h:148
Definition: rs_option.h:59
Definition: rs_processing.hpp:1320
Definition: rs_processing.hpp:499
Definition: rs_frame.hpp:748
int rs2_poll_for_frame(rs2_frame_queue *queue, rs2_frame **output_frame, rs2_error **error)
size_t capacity() const
Definition: rs_processing.hpp:228
Definition: rs_option.h:128
hdr_merge()
Definition: rs_processing.hpp:1203
Definition: rs_option.h:108
align(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:767
void on_frame(rs2_frame *f, rs2_source *source) override
Definition: rs_processing.hpp:123
rs2_processing_block * rs2_create_hole_filling_filter_block(rs2_error **error)
rs2_processing_block * rs2_create_sync_processing_block(rs2_error **error)
void operator()(frame f) const
Definition: rs_processing.hpp:727
void register_simple_option(rs2_option option_id, option_range range)
Definition: rs_processing.hpp:348
pointcloud(rs2_stream stream, int index=0)
Definition: rs_processing.hpp:437
rs2_processing_block * rs2_create_y411_decoder(rs2_error **error)
rs2_processing_block * rs2_create_processing_block(rs2_frame_processor_callback *proc, rs2_error **error)
float min
Definition: rs_types.hpp:201
units_transform(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:636
bool poll_for_frames(frameset *fs) const
Definition: rs_processing.hpp:699
Definition: rs_frame.hpp:1066
T as() const
Definition: rs_processing.hpp:415
void rs2_delete_frame_queue(rs2_frame_queue *queue)
Definition: rs_processing.hpp:1195
void map_to(frame mapped)
Definition: rs_processing.hpp:469
Definition: rs_context.hpp:11
Definition: rs_processing.hpp:528
rs2_frame_queue * rs2_create_frame_queue(int capacity, rs2_error **error)
rs2_frame * rs2_wait_for_frame(rs2_frame_queue *queue, unsigned int timeout_ms, rs2_error **error)
void rs2_process_frame(rs2_processing_block *block, rs2_frame *frame, rs2_error **error)
Definition: rs_processing.hpp:250
frame_queue _queue
Definition: rs_processing.hpp:423
colorizer(float color_scheme)
Definition: rs_processing.hpp:806
rs2_processing_block * rs2_create_huffman_depth_decompress_block(rs2_error **error)
Definition: rs_context.hpp:96
int rs2_frame_queue_size(rs2_frame_queue *queue, rs2_error **error)
void frame_ready(frame result) const
Definition: rs_processing.hpp:98
m420_decoder()
Definition: rs_processing.hpp:542
int rs2_processing_block_register_simple_option(rs2_processing_block *block, rs2_option option_id, float min, float max, float step, float def, rs2_error **error)
processing_block(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:298
threshold_filter(float min_dist=0.15f, float max_dist=4.f)
Definition: rs_processing.hpp:594
frame allocate_video_frame(const stream_profile &profile, const frame &original, int new_bpp=0, int new_width=0, int new_height=0, int new_stride=0, rs2_extension frame_type=RS2_EXTENSION_VIDEO_FRAME) const
Definition: rs_processing.hpp:32
float max
Definition: rs_types.hpp:202
float step
Definition: rs_types.hpp:204
rs2_processing_block * rs2_create_rates_printer_block(rs2_error **error)
void invoke(frame f) const
Definition: rs_processing.hpp:284
align(rs2_stream align_to)
Definition: rs_processing.hpp:751
Definition: rs_frame.hpp:1308
rs2_frame * rs2_allocate_synthetic_video_frame(rs2_source *source, const rs2_stream_profile *new_stream, rs2_frame *original, int new_bpp, int new_width, int new_height, int new_stride, rs2_extension frame_type, rs2_error **error)
rs2_processing_block * rs2_create_align(rs2_stream align_to, rs2_error **error)
rs2::frame process(rs2::frame frame) const override
Definition: rs_processing.hpp:369
depth_huffman_decoder(filter f)
Definition: rs_processing.hpp:1097
Definition: rs_option.h:64
frame_queue()
Definition: rs_processing.hpp:151
rotation_filter()
Definition: rs_processing.hpp:892
yuy_decoder()
Definition: rs_processing.hpp:510
Definition: rs_processing.hpp:17
rs2_processing_block * rs2_create_pointcloud(rs2_error **error)
bool is() const
Definition: rs_processing.hpp:408
hole_filling_filter()
Definition: rs_processing.hpp:1129
temporal_filter(float smooth_alpha, float smooth_delta, int persistence_control)
Definition: rs_processing.hpp:963
void rs2_enqueue_frame(rs2_frame *frame, void *queue)
frameset process(frameset frames)
Definition: rs_processing.hpp:761
bool is() const
Definition: rs_processing.hpp:1303
frame_queue get_queue()
Definition: rs_processing.hpp:404
Definition: rs_processing.hpp:627
Definition: rs_types.hpp:39
Definition: rs_processing.hpp:1230
processing_block(S processing_function)
Definition: rs_processing.hpp:309
Definition: rs_processing.hpp:936
Definition: rs_types.hpp:199
video_frame colorize(frame depth) const
Definition: rs_processing.hpp:815
int rs2_supports_processing_block_info(const rs2_processing_block *block, rs2_camera_info info, rs2_error **error)
rs2_processing_block * rs2_create_rotation_filter_block(rs2_streams_list streams_to_rotate, rs2_error **error)
decimation_filter(float magnitude)
Definition: rs_processing.hpp:852
void rs2_synthetic_frame_ready(rs2_source *source, rs2_frame *frame, rs2_error **error)
Definition: rs_types.h:191
rs2_processing_block * get() const
Definition: rs_processing.hpp:320
embedded_filter(std::shared_ptr< rs2_embedded_filter > filter)
Definition: rs_processing.hpp:1278
spatial_filter()
Definition: rs_processing.hpp:1007
sequence_id_filter(filter f)
Definition: rs_processing.hpp:1249
decimation_filter(filter f)
Definition: rs_processing.hpp:857
Definition: rs_types.hpp:34
S & operator>>(S &on_frame)
Definition: rs_processing.hpp:274
pointcloud()
Definition: rs_processing.hpp:435
Definition: rs_options.hpp:155
sequence_id_filter()
Definition: rs_processing.hpp:1237
std::vector< rs2_stream > list
Definition: rs_types.hpp:36
spatial_filter(filter f)
Definition: rs_processing.hpp:1026
void rs2_delete_processing_block(rs2_processing_block *block)
filter(S processing_function, int queue_size=1)
Definition: rs_processing.hpp:396
Definition: rs_types.h:184
Definition: rs_processing.hpp:429
rs2_processing_block * rs2_create_temporal_filter_block(rs2_error **error)
void enqueue(frame f) const
Definition: rs_processing.hpp:157
Definition: rs_processing.hpp:586
Definition: rs_option.h:66
void keep()
Definition: rs_frame.hpp:448
void start(S on_frame)
Definition: rs_processing.hpp:261
struct rs2_options rs2_options
Definition: rs_types.h:303
void operator()(frame f) const
Definition: rs_processing.hpp:207
Definition: rs_option.h:67
int stream_index() const
Definition: rs_frame.hpp:34
syncer(int queue_size=1)
Definition: rs_processing.hpp:678
static void handle(rs2_error *e)
Definition: rs_types.hpp:167
Definition: rs_sensor.h:49
struct rs2_source rs2_source
Definition: rs_types.h:292
rs2_processing_block * rs2_create_disparity_transform_block(unsigned char transform_to_disparity, rs2_error **error)
rs2_processing_block * rs2_create_colorizer(rs2_error **error)
m420_decoder(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:545
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:46
rs2_embedded_filter_type
Definition: rs_types.h:265
Definition: rs_processing.hpp:360
points calculate(frame depth) const
Definition: rs_processing.hpp:448
Definition: rs_types.h:164
bool try_wait_for_frames(frameset *fs, unsigned int timeout_ms=5000) const
Definition: rs_processing.hpp:716
Definition: rs_processing.hpp:1088
Definition: rs_option.h:73
const rs2_stream_profile * get() const
Definition: rs_frame.hpp:146
rs2_processing_block * rs2_create_sequence_id_filter(rs2_error **error)
Definition: rs_processing.hpp:783
frame wait_for_frame(unsigned int timeout_ms=5000) const
Definition: rs_processing.hpp:168
rotation_filter(std::vector< rs2_stream > streams_to_rotate, float value)
Definition: rs_processing.hpp:902
Definition: rs_types.h:147
Definition: rs_processing.hpp:1275
void release() override
Definition: rs_processing.hpp:130
yuy_decoder(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:513
filter(std::shared_ptr< rs2_processing_block > block, int queue_size=1)
Definition: rs_processing.hpp:383
rs2_frame * rs2_allocate_synthetic_motion_frame(rs2_source *source, const rs2_stream_profile *new_stream, rs2_frame *original, rs2_extension frame_type, rs2_error **error)
frame allocate_points(const stream_profile &profile, const frame &original) const
Definition: rs_processing.hpp:66
Definition: rs_option.h:62
Definition: rs_processing.hpp:739
struct rs2_processing_block rs2_processing_block
Definition: rs_types.h:293
rs2_processing_block * rs2_create_yuy_decoder(rs2_error **error)
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:137
asynchronous_syncer()
Definition: rs_processing.hpp:657
Definition: rs_frame.hpp:347
int rs2_is_embedded_filter_extendable_to(const rs2_embedded_filter *embedded_filter, rs2_extension extension_type, rs2_error **error)
rotation_filter(std::vector< rs2_stream > streams_to_rotate)
Definition: rs_processing.hpp:897
void set_option(rs2_option option, float value) const
Definition: rs_options.hpp:256
rs2_embedded_filter_type rs2_get_embedded_filter_type(const rs2_embedded_filter *embedded_filter, rs2_error **error)
sequence_id_filter(float sequence_id)
Definition: rs_processing.hpp:1244
const char * get_info(rs2_camera_info info) const
Definition: rs_processing.hpp:340
float def
Definition: rs_types.hpp:203
Definition: rs_processing.hpp:885
spatial_filter(float smooth_alpha, float smooth_delta, float magnitude, float hole_fill)
Definition: rs_processing.hpp:1018
frame allocate_motion_frame(const stream_profile &profile, const frame &original, rs2_extension frame_type=RS2_EXTENSION_MOTION_FRAME) const
Definition: rs_processing.hpp:55
rs2_processing_block * rs2_create_spatial_filter_block(rs2_error **error)
frame_processor_callback(T on_frame)
Definition: rs_processing.hpp:121
rs2_source * _source
Definition: rs_processing.hpp:106
options & operator=(const options &other)
Definition: rs_options.hpp:323
Definition: rs_processing.hpp:672
frame_queue(unsigned int capacity, bool keep_frames=false)
Definition: rs_processing.hpp:142
rs2_processing_block * get() const
Definition: rs_processing.hpp:405
Definition: rs_processing.hpp:133
rotation_filter(filter f)
Definition: rs_processing.hpp:908
Definition: rs_processing.hpp:117
frameset wait_for_frames(unsigned int timeout_ms=5000) const
Definition: rs_processing.hpp:689
Definition: rs_option.h:72
Definition: rs_processing.hpp:560
int rs2_try_wait_for_frame(rs2_frame_queue *queue, unsigned int timeout_ms, rs2_frame **output_frame, rs2_error **error)
Definition: rs_types.h:165
Definition: rs_processing.hpp:839
int rs2_is_processing_block_extendable_to(const rs2_processing_block *block, rs2_extension extension_type, rs2_error **error)
embedded_decimation_filter(embedded_filter filter)
Definition: rs_processing.hpp:1323
hole_filling_filter(int mode)
Definition: rs_processing.hpp:1139
temporal_filter()
Definition: rs_processing.hpp:945
struct rs2_error rs2_error
Definition: rs_types.h:276
rs2_stream stream_type() const
Definition: rs_frame.hpp:39
const char * rs2_get_processing_block_info(const rs2_processing_block *block, rs2_camera_info info, rs2_error **error)
Definition: rs_option.h:65
std::shared_ptr< rs2_embedded_filter > _embedded_filter
Definition: rs_processing.hpp:1317
rs2_frame * get() const
Definition: rs_frame.hpp:601
rates_printer()
Definition: rs_processing.hpp:1178
std::enable_if< std::is_base_of< rs2::frame, T >::value, bool >::type try_wait_for_frame(T *output, unsigned int timeout_ms=5000) const
Definition: rs_processing.hpp:194
colorizer(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:821
colorizer()
Definition: rs_processing.hpp:790
pointcloud(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:478
rs2_processing_block * rs2_create_hdr_merge_processing_block(rs2_error **error)
embedded_temporal_filter(embedded_filter filter)
Definition: rs_processing.hpp:1340
struct rs2_frame rs2_frame
Definition: rs_types.h:279
T as() const
Definition: rs_processing.hpp:1310
Definition: rs_processing.hpp:1053
Definition: rs_types.h:202
disparity_transform(filter f)
Definition: rs_processing.hpp:1062
Definition: rs_option.h:71
Definition: rs_processing.hpp:1171
const std::shared_ptr< rs2_embedded_filter > & get() const
Definition: rs_processing.hpp:1297
stream_profile get_profile() const
Definition: rs_frame.hpp:568
y411_decoder(std::shared_ptr< rs2_processing_block > block)
Definition: rs_processing.hpp:572
frame allocate_composite_frame(std::vector< frame > frames) const
Definition: rs_processing.hpp:81
disparity_transform(bool transform_to_disparity=true)
Definition: rs_processing.hpp:1060
Definition: rs_types.h:190
temporal_filter(filter f)
Definition: rs_processing.hpp:970
units_transform()
Definition: rs_processing.hpp:633