sequence-id-filter.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #include "sequence-id-filter.h"
5 
6 namespace librealsense
7 {
9  : generic_processing_block("Filter By Sequence id"),
10  _selected_stream_id(1.f)
11  {
12  auto selected_stream_id = std::make_shared<ptr_option<float>>(0.f, 2.f, 1.f, 1.f,
13  &_selected_stream_id, "Selected stream id for display",
14  std::map<float, std::string>{ {0.f, "all"}, { 1.f, "1" }, { 2.f, "2" }});
15  register_option(RS2_OPTION_SEQUENCE_ID, selected_stream_id);
16  }
17 
18  // processing only simple frames (not framesets)
19  // only depth frames
20  // only index 0
22  {
23  if (!frame)
24  return false;
25 
26  if (frame.is<rs2::frameset>())
27  return false;
28 
30  return false;
32  return false;
33  int seq_size = (int)frame.get_frame_metadata( RS2_FRAME_METADATA_SEQUENCE_SIZE );
34  if (seq_size == 0)
35  return false;
36  return true;
37  }
38 
40  {
41  // steps:
42  // check hdr seq id in metadata -
43  // if not as the option selected id, return last frame with the selected id
44  // else return current frame
45 
47  auto unique_id = f.get_profile().unique_id();
48  auto current_key = std::make_pair(seq_id, unique_id);
49 
50  if (is_selected_id(seq_id + 1))
51  {
52  _last_frames[current_key] = f;
53  return f;
54  }
55  else
56  {
57  int seq_id_selected = (seq_id == 0) ? 1 : 0;
58  auto key_with_selected_id = std::make_pair(seq_id_selected, unique_id);
59  if (_last_frames[key_with_selected_id])
60  return _last_frames[key_with_selected_id];
61  return f;
62  }
63  }
64 
65  bool sequence_id_filter::is_selected_id(int stream_index) const
66  {
67  if (static_cast<int>(_selected_stream_id) != 0 &&
68  stream_index != static_cast<int>(_selected_stream_id))
69  return false;
70  return true;
71  }
72 }
rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f) override
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:497
stream_profile get_profile() const
Definition: rs_frame.hpp:557
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:509
std::map< std::pair< int, int >, rs2::frame > _last_frames
void register_option(rs2_option id, std::shared_ptr< option > option)
Definition: options.h:86
GLdouble f
bool is() const
Definition: rs_frame.hpp:570
GLsizei GLsizei GLchar * source
bool is_selected_id(int stream_index) const
bool should_process(const rs2::frame &frame) override
int unique_id() const
Definition: rs_frame.hpp:54


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41