l500-depth.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2018 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include <vector>
7 #include <mutex>
8 #include <string>
9 #include <map>
10 
11 #include "l500-device.h"
12 #include "context.h"
13 #include "backend.h"
14 #include "hw-monitor.h"
15 #include "image.h"
16 #include "stream.h"
17 #include "l500-private.h"
18 #include "error-handling.h"
19 #include "l500-options.h"
20 #include "calibrated-sensor.h"
22 #include "debug-stream-sensor.h"
23 
24 namespace librealsense
25 {
26  class l500_depth : public virtual l500_device
27  {
28  public:
29 
31 
32  l500_depth(std::shared_ptr<context> ctx,
34 
36 
37  std::vector<tagged_profile> get_profiles_tags() const override;
38 
39  std::shared_ptr<matcher> create_matcher(const frame_holder& frame) const override;
40  };
41 
42  class l500_depth_sensor_interface: public recordable<l500_depth_sensor_interface>
43  {
44  public:
45  virtual ivcam2::intrinsic_depth get_intrinsic() const = 0;
46  virtual float read_baseline() const = 0;
47  virtual ~l500_depth_sensor_interface() = default;
48  };
50 
52  {
53  public:
55  _intrinsic(intrinsic), _baseline(baseline)
56  {}
57 
59  {
60  return _intrinsic;
61  }
62  float read_baseline() const override
63  {
64  return _baseline;
65 
66  }
67  void update(std::shared_ptr<extension_snapshot> ext) override
68  {
69  if (auto api = As<l500_depth_sensor_interface>(ext))
70  {
71  _intrinsic = api->get_intrinsic();
72  }
73  }
74 
75  void create_snapshot(std::shared_ptr<l500_depth_sensor_interface>& snapshot) const override
76  {
77  snapshot = std::make_shared<l500_depth_sensor_snapshot>(get_intrinsic(), read_baseline());
78  }
79 
80  void enable_recording(std::function<void(const l500_depth_sensor_interface&)> recording_function) override
81  {}
82 
84 
85  protected:
87  float _baseline;
88  };
89 
91  : public synthetic_sensor
92  , public video_sensor_interface
93  , public virtual depth_sensor
94  , public virtual l500_depth_sensor_interface
95  , public calibrated_sensor
97  , public debug_stream_sensor
98  {
99  public:
100  explicit l500_depth_sensor(
101  l500_device * owner,
102  std::shared_ptr< uvc_sensor > uvc_sensor,
103  std::map< uint32_t, rs2_format > l500_depth_sourcc_to_rs2_format_map,
104  std::map< uint32_t, rs2_stream > l500_depth_sourcc_to_rs2_stream_map
105  );
106 
108 
109  std::vector<rs2_option> get_supported_options() const override
110  {
111  std::vector<rs2_option> options;
112  for (auto opt : _options)
113  {
114  if (std::find_if(_owner->_advanced_options.begin(), _owner->_advanced_options.end(), [opt](rs2_option o) { return o == opt.first;}) != _owner->_advanced_options.end())
115  continue;
116 
117  options.push_back(opt.first);
118  }
119 
120  for (auto option : _owner->_advanced_options)
121  options.push_back(option);
122 
123  return options;
124  }
125 
127  {
128  auto num_of_res = intrinsic.resolution.num_of_resolutions;
129 
130  for (auto i = 0; i < num_of_res; i++)
131  {
132  auto model_world = intrinsic.resolution.intrinsic_resolution[i].world;
133  auto model_raw = intrinsic.resolution.intrinsic_resolution[i].raw;
134 
135  if (model_world.pinhole_cam_model.height == height && model_world.pinhole_cam_model.width == width)
136  return model_world;
137  else if (model_raw.pinhole_cam_model.height == height && model_raw.pinhole_cam_model.width == width)
138  return model_raw;
139  }
140  throw std::runtime_error(to_string() << "intrinsics for resolution " << width << "," << height << " doesn't exist");
141  }
142 
144  {
145  using namespace ivcam2;
146 
147  auto intrinsic_params = get_intrinsic_params(profile.width, profile.height, get_intrinsic());
148 
149  rs2_intrinsics intrinsics = { 0 };
156 
162 
163  intrinsics.model = RS2_DISTORTION_NONE;
164  return intrinsics;
165  }
166 
167  // calibrated_sensor
168  void override_intrinsics( rs2_intrinsics const & intr ) override;
169  void override_extrinsics( rs2_extrinsics const & extr ) override;
170  rs2_dsm_params get_dsm_params() const override;
171  void override_dsm_params( rs2_dsm_params const & dsm_params ) override;
172  void reset_calibration() override;
173 
175  {
177 
178  auto&& results = synthetic_sensor::init_stream_profiles();
179  for (auto&& p : results)
180  {
181  // Register stream types
182  if (p->get_stream_type() == RS2_STREAM_DEPTH)
183  {
184  assign_stream(_owner->_depth_stream, p);
185  }
186  else if (p->get_stream_type() == RS2_STREAM_INFRARED)
187  {
188  assign_stream(_owner->_ir_stream, p);
189  }
190  else if (p->get_stream_type() == RS2_STREAM_CONFIDENCE)
191  {
192  assign_stream(_owner->_confidence_stream, p);
193  }
194 
195  // Register intrinsics
196  auto&& video = dynamic_cast<video_stream_profile_interface*>(p.get());
197 
198  const auto&& profile = to_profile(p.get());
199  std::weak_ptr<l500_depth_sensor> wp =
200  std::dynamic_pointer_cast<l500_depth_sensor>(this->shared_from_this());
201 
202  video->set_intrinsics([profile, wp]()
203  {
204  auto sp = wp.lock();
205  if (sp)
206  return sp->get_intrinsics(profile);
207  else
208  return rs2_intrinsics{};
209  });
210  }
211 
212  return results;
213  }
214 
215 
216  float get_depth_scale() const override { return get_option(RS2_OPTION_DEPTH_UNITS).query(); }
217 
219  {
220  using namespace ivcam2;
221  return *_owner->_calib_table;
222  }
223 
224  float get_max_usable_depth_range() const override;
225 
226  stream_profiles get_debug_stream_profiles() const override;
227 
228  void create_snapshot(std::shared_ptr<depth_sensor>& snapshot) const override
229  {
230  snapshot = std::make_shared<depth_sensor_snapshot>(get_depth_scale());
231  }
232  void enable_recording(std::function<void(const depth_sensor&)> recording_function) override
233  {
234  get_option(RS2_OPTION_DEPTH_UNITS).enable_recording([this, recording_function](const option& o) {
235  recording_function(*this);
236  });
237  }
238 
239  void create_snapshot(std::shared_ptr<l500_depth_sensor_interface>& snapshot) const override
240  {
241  snapshot = std::make_shared<l500_depth_sensor_snapshot>(get_intrinsic(), read_baseline());
242  }
243 
244  void enable_recording(std::function<void(const l500_depth_sensor_interface&)> recording_function) override
245  {}
246 
247  static processing_blocks get_l500_recommended_proccesing_blocks();
248 
250  {
251  return get_l500_recommended_proccesing_blocks();
252  };
253 
254  std::shared_ptr< stream_profile_interface > is_color_sensor_needed() const;
255 
256  int read_algo_version();
257  float read_baseline() const override;
258  float read_znorm();
259 
260  void start(frame_callback_ptr callback) override;
261  void open(const stream_profiles& requests) override;
262  void stop() override;
263  float get_depth_offset() const;
264  bool is_max_range_preset() const;
265 
266  private:
272  };
273 }
void enable_recording(std::function< void(const depth_sensor &)> recording_function) override
Definition: l500-depth.h:232
static const textual_icon lock
Definition: model-views.h:218
void create_snapshot(std::shared_ptr< depth_sensor > &snapshot) const override
Definition: l500-depth.h:228
l500_depth_sensor_snapshot(ivcam2::intrinsic_depth intrinsic, float baseline)
Definition: l500-depth.h:54
intrinsic_per_resolution intrinsic_resolution[MAX_NUM_OF_DEPTH_RESOLUTIONS]
Definition: l500-private.h:361
float get_depth_scale() const override
Definition: l500-depth.h:216
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
processing_blocks get_recommended_processing_blocks() const override
Definition: l500-depth.h:249
std::shared_ptr< rs2_frame_callback > frame_callback_ptr
Definition: src/types.h:1071
l500_depth(std::shared_ptr< context > ctx, const platform::backend_device_group &group)
Definition: l500-depth.cpp:70
GLfloat GLfloat p
Definition: glext.h:12687
void update(std::shared_ptr< extension_snapshot > ext) override
Definition: l500-depth.h:67
static ivcam2::intrinsic_params get_intrinsic_params(const uint32_t width, const uint32_t height, ivcam2::intrinsic_depth intrinsic)
Definition: l500-depth.h:126
Video DSM (Digital Sync Module) parameters for calibration (same layout as in FW ac_depth_params) Thi...
Definition: rs_types.h:74
virtual stream_profiles init_stream_profiles() override
Definition: sensor.cpp:1225
float coeffs[5]
Definition: rs_types.h:67
stream_profiles init_stream_profiles() override
Definition: l500-depth.h:174
ivcam2::intrinsic_depth get_intrinsic() const override
Definition: l500-depth.h:218
static const textual_icon stop
Definition: model-views.h:225
std::vector< tagged_profile > get_profiles_tags() const override
Definition: l500-depth.cpp:165
void enable_recording(std::function< void(const l500_depth_sensor_interface &)> recording_function) override
Definition: l500-depth.h:80
ivcam2::intrinsic_depth get_intrinsic() const override
Definition: l500-depth.h:58
stream_profiles _user_requests
Definition: l500-depth.h:270
unsigned int uint32_t
Definition: stdint.h:80
GLboolean GLuint group
Definition: glext.h:5688
GLint GLsizei GLsizei height
def callback(frame)
Definition: t265_stereo.py:91
float read_baseline() const override
Definition: l500-depth.h:62
GLuint start
void enable_recording(std::function< void(const l500_depth_sensor_interface &)> recording_function) override
Definition: l500-depth.h:244
float get_depth_scale(rs2::device dev)
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
Definition: streaming.h:165
dictionary intrinsics
Definition: t265_stereo.py:142
static environment & get_instance()
extrinsics_graph & get_extrinsics_graph()
ivcam2::intrinsic_depth read_intrinsics_table() const
Definition: l500-depth.cpp:33
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:96
rs2_distortion model
Definition: rs_types.h:66
stream_profile to_profile(const stream_profile_interface *sp)
Definition: src/stream.h:185
rs2_extrinsics extr
Definition: test-pose.cpp:258
Video stream intrinsics.
Definition: rs_types.h:58
friend class l500_depth_sensor
Definition: l500-device.h:89
int i
l500_device *const _owner
Definition: l500-depth.h:268
rs2_intrinsics get_intrinsics(const stream_profile &profile) const override
Definition: l500-depth.h:143
ivcam2::intrinsic_depth _intrinsic
Definition: l500-depth.h:86
pinhole_camera_model pinhole_cam_model
Definition: l500-private.h:345
stream_profiles _validator_requests
Definition: l500-depth.h:271
void create_snapshot(std::shared_ptr< l500_depth_sensor_interface > &snapshot) const override
Definition: l500-depth.h:75
std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
Definition: l500-depth.cpp:181
MAP_EXTENSION(RS2_EXTENSION_POINTS, librealsense::points)
GLint GLsizei width
void create_snapshot(std::shared_ptr< l500_depth_sensor_interface > &snapshot) const override
Definition: l500-depth.h:239
std::string to_string(T value)
std::vector< rs2_option > get_supported_options() const override
Definition: l500-depth.h:109


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