sr300.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2016 Intel Corporation. All Rights Reserved.
3 
4 #include "sr300.h"
5 #include "metadata.h"
6 #include "hw-monitor.h"
8 #include "proc/threshold.h"
9 #include "proc/spatial-filter.h"
10 #include "proc/temporal-filter.h"
13 #include "ds5/ds5-device.h"
14 #include "../../include/librealsense2/h/rs_sensor.h"
15 #include "../common/fw/firmware-version.h"
16 
17 namespace librealsense
18 {
19  std::map<uint32_t, rs2_format> sr300_color_fourcc_to_rs2_format = {
20  {rs_fourcc('Y','U','Y','2'), RS2_FORMAT_YUYV},
21  {rs_fourcc('Y','U','Y','V'), RS2_FORMAT_YUYV},
22  {rs_fourcc('U','Y','V','Y'), RS2_FORMAT_UYVY}
23  };
24  std::map<uint32_t, rs2_stream> sr300_color_fourcc_to_rs2_stream = {
25  {rs_fourcc('Y','U','Y','2'), RS2_STREAM_COLOR},
26  {rs_fourcc('Y','U','Y','V'), RS2_STREAM_COLOR},
27  {rs_fourcc('U','Y','V','Y'), RS2_STREAM_COLOR}
28  };
29 
30  std::map<uint32_t, rs2_format> sr300_depth_fourcc_to_rs2_format = {
31  {rs_fourcc('G','R','E','Y'), RS2_FORMAT_Y8},
32  {rs_fourcc('Z','1','6',' '), RS2_FORMAT_Z16},
33  {rs_fourcc('I','N','V','I'), RS2_FORMAT_INVI},
34  {rs_fourcc('I','N','Z','I'), RS2_FORMAT_INZI}
35  };
36  std::map<uint32_t, rs2_stream> sr300_depth_fourcc_to_rs2_stream = {
37  {rs_fourcc('G','R','E','Y'), RS2_STREAM_INFRARED},
38  {rs_fourcc('Z','1','6',' '), RS2_STREAM_DEPTH},
39  {rs_fourcc('I','N','V','I'), RS2_STREAM_INFRARED},
40  {rs_fourcc('I','N','Z','I'), RS2_STREAM_DEPTH}
41  };
42 
43  std::shared_ptr<device_interface> sr300_info::create(std::shared_ptr<context> ctx,
44  bool register_device_notifications) const
45  {
46  auto pid = _depth.pid;
47  switch (pid)
48  {
49  case SR300_PID:
50  return std::make_shared<sr300_camera>(ctx, _color, _depth, _hwm,
51  this->get_device_data(),
52  register_device_notifications);
53  case SR300v2_PID:
54  return std::make_shared<sr305_camera>(ctx, _color, _depth, _hwm,
55  this->get_device_data(),
56  register_device_notifications);
57  case SR306_PID:
58  return std::make_shared<sr306_camera>(ctx, _depth, _hwm,
59  this->get_device_data(),
60  register_device_notifications);
61  default:
62  throw std::runtime_error(to_string() << "Unsupported SR300 model! 0x"
63  << std::hex << std::setw(4) << std::setfill('0') << (int)pid);
64  }
65 
66  }
67 
68  std::vector<std::shared_ptr<device_info>> sr300_info::pick_sr300_devices(
69  std::shared_ptr<context> ctx,
70  std::vector<platform::uvc_device_info>& uvc,
71  std::vector<platform::usb_device_info>& usb)
72  {
73  std::vector<platform::uvc_device_info> chosen;
74  std::vector<std::shared_ptr<device_info>> results;
75 
76  auto correct_pid = filter_by_product(uvc, { SR300_PID, SR300v2_PID, SR306_PID });
77  auto group_devices = group_devices_by_unique_id(correct_pid);
78  for (auto& group : group_devices)
79  {
83 
84  if (mi_present(group, 0))
85  {
86  color = get_mi(group, 0);
87  chosen.push_back(color);
88  if (!ivcam::try_fetch_usb_device(usb, color, hwm))
89  {
90  LOG_WARNING("try_fetch_usb_device(...) failed.");
91  return results;
92  }
93  }
94 
95  if (mi_present(group, 2))
96  {
97  depth = get_mi(group, 2);
98  chosen.push_back(depth);
99  }
100 
101  if (!color.pid && !depth.pid)
102  LOG_WARNING("SR300 group_devices is empty.");
103  else
104  {
105  if (!depth.pid) // SR306 : only mi=0 is defined
106  std::swap(color, depth);
107  auto info = std::make_shared<sr300_info>(ctx, color, depth, hwm);
108  results.push_back(info);
109  }
110  }
111 
112  trim_device_list(uvc, chosen);
113 
114  return results;
115  }
116 
117  std::shared_ptr<synthetic_sensor> sr300_camera::create_color_device(std::shared_ptr<context> ctx,
119  {
120  auto raw_color_ep = std::make_shared<uvc_sensor>("Raw RGB Camera", ctx->get_backend().create_uvc_device(color),
121  std::unique_ptr<frame_timestamp_reader>(new sr300_timestamp_reader_from_metadata()),
122  this);
123  auto color_ep = std::make_shared<sr300_color_sensor>(this,
124  raw_color_ep,
127 
128  color_ep->register_info(RS2_CAMERA_INFO_PHYSICAL_PORT, color.device_path);
129 
130  // register processing blocks
131  color_ep->register_processing_block(processing_block_factory::create_pbf_vector<uyvy_converter>(RS2_FORMAT_UYVY, map_supported_color_formats(RS2_FORMAT_UYVY), RS2_STREAM_COLOR));
132  color_ep->register_processing_block(processing_block_factory::create_pbf_vector<yuy2_converter>(RS2_FORMAT_YUYV, map_supported_color_formats(RS2_FORMAT_YUYV), RS2_STREAM_COLOR));
133 
134  // register options
135  color_ep->register_pu(RS2_OPTION_BACKLIGHT_COMPENSATION);
136  color_ep->register_pu(RS2_OPTION_BRIGHTNESS);
137  color_ep->register_pu(RS2_OPTION_CONTRAST);
138  color_ep->register_pu(RS2_OPTION_GAIN);
139  color_ep->register_pu(RS2_OPTION_GAMMA);
140  color_ep->register_pu(RS2_OPTION_HUE);
141  color_ep->register_pu(RS2_OPTION_SATURATION);
142  color_ep->register_pu(RS2_OPTION_SHARPNESS);
143 
144  auto white_balance_option = std::make_shared<uvc_pu_option>(*raw_color_ep, RS2_OPTION_WHITE_BALANCE);
145  auto auto_white_balance_option = std::make_shared<uvc_pu_option>(*raw_color_ep, RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE);
146  color_ep->register_option(RS2_OPTION_WHITE_BALANCE, white_balance_option);
147  color_ep->register_option(RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE, auto_white_balance_option);
148  color_ep->register_option(RS2_OPTION_WHITE_BALANCE,
149  std::make_shared<auto_disabling_control>(
150  white_balance_option,
151  auto_white_balance_option));
152 
153  auto exposure_option = std::make_shared<uvc_pu_option>(*raw_color_ep, RS2_OPTION_EXPOSURE);
154  auto auto_exposure_option = std::make_shared<uvc_pu_option>(*raw_color_ep, RS2_OPTION_ENABLE_AUTO_EXPOSURE);
155  color_ep->register_option(RS2_OPTION_EXPOSURE, exposure_option);
156  color_ep->register_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, auto_exposure_option);
157  color_ep->register_option(RS2_OPTION_EXPOSURE,
158  std::make_shared<auto_disabling_control>(
160  auto_exposure_option));
161 
162  // register metadata
163  auto md_offset = offsetof(metadata_raw, mode);
165  [](rs2_metadata_type param) { return static_cast<rs2_metadata_type>(param * TIMESTAMP_10NSEC_TO_MSEC); }));
169  color_ep->register_metadata(RS2_FRAME_METADATA_ACTUAL_EXPOSURE, make_sr300_attribute_parser(&md_sr300_rgb::actual_exposure, md_offset, [](rs2_metadata_type param) { return param * 100; }));
170  color_ep->register_metadata(RS2_FRAME_METADATA_AUTO_EXPOSURE, make_sr300_attribute_parser(&md_sr300_rgb::auto_exp_mode, md_offset, [](rs2_metadata_type param) { return (param != 1); }));
171  color_ep->register_metadata(RS2_FRAME_METADATA_GAIN_LEVEL, make_sr300_attribute_parser(&md_sr300_rgb::gain, md_offset));
173 
174  return color_ep;
175  }
176 
177  std::shared_ptr<synthetic_sensor> sr3xx_camera::create_depth_device(std::shared_ptr<context> ctx,
179  {
180  using namespace ivcam;
181 
182  auto&& backend = ctx->get_backend();
183 
184  // create uvc-endpoint from backend uvc-device
185  auto raw_depth_ep = std::make_shared<uvc_sensor>("Raw Depth Sensor", backend.create_uvc_device(depth),
186  std::unique_ptr<frame_timestamp_reader>(new sr300_timestamp_reader_from_metadata()),
187  this);
188  auto depth_ep = std::make_shared<sr300_depth_sensor>(this,
189  raw_depth_ep,
192  raw_depth_ep->register_xu(depth_xu); // make sure the XU is initialized everytime we power the camera
193 
194  depth_ep->register_info(RS2_CAMERA_INFO_PHYSICAL_PORT, depth.device_path);
195 
196  // register processing blocks factories
197  depth_ep->register_processing_block(
198  { { RS2_FORMAT_INVI } },
200  []() {return std::make_shared<invi_converter>(RS2_FORMAT_Y8); });
201  depth_ep->register_processing_block(
202  { { RS2_FORMAT_INVI } },
204  []() {return std::make_shared<invi_converter>(RS2_FORMAT_Y16); });
205  depth_ep->register_processing_block(
206  { { RS2_FORMAT_INZI } },
208  []() {return std::make_shared<inzi_converter>(RS2_FORMAT_Y8); });
209  depth_ep->register_processing_block(
210  { { RS2_FORMAT_INZI } },
212  []() {return std::make_shared<inzi_converter>(RS2_FORMAT_Y16); });
213  depth_ep->register_processing_block(processing_block_factory::create_id_pbf(RS2_FORMAT_Y8, RS2_STREAM_INFRARED, 1));
214  depth_ep->register_processing_block(processing_block_factory::create_id_pbf(RS2_FORMAT_Z16, RS2_STREAM_DEPTH));
215 
216  register_depth_xu<uint8_t>(*depth_ep, RS2_OPTION_LASER_POWER, IVCAM_DEPTH_LASER_POWER,
217  "Power of the SR300 projector, with 0 meaning projector off");
218  register_depth_xu<uint8_t>(*depth_ep, RS2_OPTION_ACCURACY, IVCAM_DEPTH_ACCURACY,
219  "Set the number of patterns projected per frame.\nThe higher the accuracy value the more patterns projected.\nIncreasing the number of patterns help to achieve better accuracy.\nNote that this control is affecting the Depth FPS");
220  register_depth_xu<uint8_t>(*depth_ep, RS2_OPTION_MOTION_RANGE, IVCAM_DEPTH_MOTION_RANGE,
221  "Motion vs. Range trade-off, with lower values allowing for better motion\nsensitivity and higher values allowing for better depth range");
222  register_depth_xu<uint8_t>(*depth_ep, RS2_OPTION_CONFIDENCE_THRESHOLD, IVCAM_DEPTH_CONFIDENCE_THRESH,
223  "The confidence level threshold used by the Depth algorithm pipe to set whether\na pixel will get a valid range or will be marked with invalid range");
224  register_depth_xu<uint8_t>(*depth_ep, RS2_OPTION_FILTER_OPTION, IVCAM_DEPTH_FILTER_OPTION,
225  "Set the filter to apply to each depth frame.\nEach one of the filter is optimized per the application requirements");
226 
227  depth_ep->register_option(RS2_OPTION_VISUAL_PRESET, std::make_shared<preset_option>(*this,
229 
230  auto md_offset = offsetof(metadata_raw, mode);
231 
233  [](rs2_metadata_type param) { return static_cast<rs2_metadata_type>(param * TIMESTAMP_10NSEC_TO_MSEC); }));
236  [](rs2_metadata_type param) { return param * 100; }));
238 
239  return depth_ep;
240  }
241 
243  {
244  return{ dims.x, dims.y, (c.Kc[0][2] * 0.5f + 0.5f) * dims.x,
245  (c.Kc[1][2] * 0.5f + 0.5f) * dims.y,
246  c.Kc[0][0] * 0.5f * dims.x,
247  c.Kc[1][1] * 0.5f * dims.y,
249  { c.Invdistc[0], c.Invdistc[1], c.Invdistc[2],
250  c.Invdistc[3], c.Invdistc[4] } };
251  }
252 
254  {
255  rs2_intrinsics intrin = { dims.x, dims.y, c.Kt[0][2] * 0.5f + 0.5f,
256  c.Kt[1][2] * 0.5f + 0.5f, c.Kt[0][0] * 0.5f,
257  c.Kt[1][1] * 0.5f, RS2_DISTORTION_NONE,{} };
258 
259  if (dims.x * 3 == dims.y * 4) // If using a 4:3 aspect ratio, adjust intrinsics (defaults to 16:9)
260  {
261  intrin.fx *= 4.0f / 3;
262  intrin.ppx *= 4.0f / 3;
263  intrin.ppx -= 1.0f / 6;
264  }
265 
266  intrin.fx *= dims.x;
267  intrin.fy *= dims.y;
268  intrin.ppx *= dims.x;
269  intrin.ppy *= dims.y;
270 
271  return intrin;
272  }
273 
275  {
277  auto data = _hw_monitor->send(command);
278  auto t = *reinterpret_cast<int32_t *>(data.data());
279  return static_cast<float>(t) / 100;
280  }
281 
283  {
285  auto data = _hw_monitor->send(command);
286  return static_cast<int8_t>(data[0]);
287  }
288 
290  {
292  cmd.require_response = false;
293  _hw_monitor->send(cmd);
294  }
295 
296  void sr3xx_camera::enable_timestamp(bool colorEnable, bool depthEnable) const
297  {
299  cmd.param1 = depthEnable ? 1 : 0;
300  cmd.param2 = colorEnable ? 1 : 0;
301  _hw_monitor->send(cmd);
302  }
303 
305  {
307  cmd.param1 = c.enableMvR;
308  cmd.param2 = c.enableLaser;
309 
310  std::vector<uint16_t> data;
311  data.resize(6);
312  data[0] = c.minMvR;
313  data[1] = c.maxMvR;
314  data[2] = c.startMvR;
315  data[3] = c.minLaser;
316  data[4] = c.maxLaser;
317  data[5] = c.startLaser;
318 
319  if (c.ARUpperTh != -1)
320  {
321  data.push_back(c.ARUpperTh);
322  }
323 
324  if (c.ARLowerTh != -1)
325  {
326  data.push_back(c.ARLowerTh);
327  }
328 
329  cmd.data.resize(sizeof(uint16_t) * data.size());
330  librealsense::copy(cmd.data.data(), data.data(), cmd.data.size());
331 
332  _hw_monitor->send(cmd);
333  }
334 
336  {
337  // Stop all data streaming/exchange pipes with HW
338  stop_activity();
339  using namespace std;
340  using namespace std::chrono;
341 
342  try {
344  cmd.param1 = 1;
345  _hw_monitor->send(cmd);
346  std::vector<uint8_t> gvd_buff(HW_MONITOR_BUFFER_SIZE);
347  for (auto i = 0; i < 50; i++)
348  {
349  _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD);
350  this_thread::sleep_for(milliseconds(50));
351  }
352  throw std::runtime_error("Device still connected!");
353  }
354  catch (std::exception& e)
355  {
356  LOG_WARNING(e.what());
357  }
358  catch (...) {
359  // The set command returns a failure because switching to DFU resets the device while the command is running.
360  }
361  }
362 
364  {
365  // TODO: Refactor, unify with DS version
366  int flash_size = 1024 * 2048;
367  int max_bulk_size = 1016;
368  int max_iterations = int(flash_size / max_bulk_size + 1);
369 
370  std::vector<uint8_t> flash;
371  flash.reserve(flash_size);
372 
373  for (int i = 0; i < max_iterations; i++)
374  {
375  int offset = max_bulk_size * i;
376  int size = max_bulk_size;
377  if (i == max_iterations - 1)
378  {
379  size = flash_size - offset;
380  }
381 
382  bool appended = false;
383 
384  const int retries = 3;
385  for (int j = 0; j < retries && !appended; j++)
386  {
387  try
388  {
390  cmd.param1 = offset;
391  cmd.param2 = size;
392  auto res = _hw_monitor->send(cmd);
393 
394  flash.insert(flash.end(), res.begin(), res.end());
395  appended = true;
396  }
397  catch (...)
398  {
399  if (i < retries - 1) std::this_thread::sleep_for(std::chrono::milliseconds(100));
400  else throw;
401  }
402  }
403 
404  if (callback) callback->on_update_progress((float)i / max_iterations);
405  }
406 
407  return flash;
408  }
409 
410  void sr3xx_camera::update_flash(const std::vector<uint8_t>&, update_progress_callback_ptr, int)
411  {
412  throw std::runtime_error("update_flash is not supported by SR300");
413  }
414 
416  {
421  int crc;
424  uint8_t reserved21[148];
425  };
426 
428  {
429  TakeFromRO = 0,
430  TakeFromRW = 1,
431  TakeFromRAM = 2
432  };
433 
435  {
437  command.param1 = static_cast<uint32_t>(cam_data_source::TakeFromRAM);
438  auto data = _hw_monitor->send(command);
439 
440  sr300_raw_calibration rawCalib;
441  librealsense::copy(&rawCalib, data.data(), std::min(sizeof(rawCalib), data.size()));
442  return rawCalib.CalibrationParameters;
443  }
444 
445  sr3xx_camera::sr3xx_camera(std::shared_ptr<context> ctx,
447  const platform::usb_device_info &hwm_device,
449  bool register_device_notifications)
450  : device(ctx, group, register_device_notifications),
451  firmware_logger_device(ctx, group, nullptr, get_firmware_logs_command(), get_flash_logs_command()),
452  _depth_device_idx(add_sensor(create_depth_device(ctx, depth))),
453  _depth_stream(new stream(RS2_STREAM_DEPTH)),
454  _ir_stream(new stream(RS2_STREAM_INFRARED)),
455  _hw_monitor(std::make_shared<hw_monitor>(std::make_shared<locked_transfer>(ctx->get_backend().create_usb_device(hwm_device), get_raw_depth_sensor())))
456  {
457  using namespace ivcam;
458  static auto device_name = "Intel RealSense SR3xx";
459 
460  // Temporal solution for HW Monitor injection - to be refactored
462  std::vector<uint8_t> gvd_buff(HW_MONITOR_BUFFER_SIZE);
463  _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), GVD);
464  // fooling tests recordings - don't remove
465  _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), GVD);
466 
467  auto fw_version = _hw_monitor->get_firmware_version_string(gvd_buff, fw_version_offset);
468  auto serial = _hw_monitor->get_module_serial_string(gvd_buff, module_serial_offset);
469  auto pid_hex_str = hexify(depth.pid);
470 
471  _camer_calib_params = [this]() { return get_calibration(); };
472  enable_timestamp(true, true);
473 
474  register_info(RS2_CAMERA_INFO_NAME, device_name);
484 
486 
487  _depth_to_color_extrinsics = std::make_shared<lazy<rs2_extrinsics>>([this]()
488  {
489  auto c = *_camer_calib_params;
490  pose depth_to_color = {
491  transpose(reinterpret_cast<const float3x3 &>(c.Rt)),
492  reinterpret_cast<const float3 &>(c.Tt) * 0.001f
493  };
494 
495  return from_pose(depth_to_color);
496  });
497 
499 
502 
504  std::make_shared<const_value_option>("Number of meters represented by a single depth unit",
505  lazy<float>([this]() {
506  auto c = *_camer_calib_params;
507  return (c.Rmax / 1000 / 0xFFFF);
508  })));
509 
510  }
511 
514  const platform::usb_device_info& hwm_device,
516  bool register_device_notifications)
517  : sr3xx_camera(ctx, depth, hwm_device, group, register_device_notifications),
518  device(ctx, group, register_device_notifications),
519  _color_stream(new stream(RS2_STREAM_COLOR)),
520  _color_device_idx(add_sensor(create_color_device(ctx, color)))
521  {
522  static auto device_name = "Intel RealSense SR300";
523  update_info(RS2_CAMERA_INFO_NAME, device_name);
526  }
527 
530  const platform::usb_device_info &hwm_device,
532  bool register_device_notifications)
533  : sr300_camera(ctx, color, depth, hwm_device, group, register_device_notifications),
534  device(ctx, group, register_device_notifications) {
535 
536  static auto device_name = "Intel RealSense SR305";
537  //auto recommended_fw_version = firmware_version(SR3XX_RECOMMENDED_FIRMWARE_VERSION);
538  update_info(RS2_CAMERA_INFO_NAME, device_name);
539  //register_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION, recommended_fw_version);
540 
541  roi_sensor_interface* roi_sensor;
542  if ((roi_sensor = dynamic_cast<roi_sensor_interface*>(&get_sensor(_color_device_idx))))
543  roi_sensor->set_roi_method(std::make_shared<ds5_auto_exposure_roi_method>(*_hw_monitor,
545 
546  }
547 
548  sr306_camera::sr306_camera(std::shared_ptr<context> ctx,
550  const platform::usb_device_info& hwm_device,
552  bool register_device_notifications)
553  : sr3xx_camera(ctx, depth, hwm_device, group, register_device_notifications),
554  device(ctx, group, register_device_notifications) {
555 
556  static auto device_name = "Intel RealSense SR306";
557  //auto recommended_fw_version = firmware_version(SR306_RECOMMENDED_FIRMWARE_VERSION);
558  update_info(RS2_CAMERA_INFO_NAME, device_name);
559  //register_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION, recommended_fw_version);
560  }
561 
563  {
564  return command{ ivcam::GLD, 0x1f4 };
565  }
566 
568  {
569  return command{ ivcam::FlashRead, 0x000B6000, 0x3f8 };
570  }
571 
572  void sr3xx_camera::create_snapshot(std::shared_ptr<debug_interface>& snapshot) const
573  {
574  //TODO: implement
575  }
576  void sr3xx_camera::enable_recording(std::function<void(const debug_interface&)> record_action)
577  {
578  //TODO: implement
579  }
580 
581 
583  {
584  std::lock_guard<std::recursive_mutex> lock(_mtx);
585 
586  if (has_metadata_ts(frame))
587  {
588  auto f = std::dynamic_pointer_cast<librealsense::frame>(frame);
589  if (!f)
590  {
591  LOG_ERROR("Frame is not valid. Failed to downcast to librealsense::frame.");
592  return 0;
593  }
594  auto md = (librealsense::metadata_raw*)(f->additional_data.metadata_blob.data());
595  return (double)(ts_wrap.calc(md->header.timestamp))*TIMESTAMP_10NSEC_TO_MSEC;
596  }
597  else
598  {
599  if (!one_time_note)
600  {
601  uint32_t fcc;
602  auto sp = frame->get_stream();
603  auto bp = As<stream_profile_base, stream_profile_interface>(sp);
604  if (bp)
605  fcc = bp->get_backend_profile().format;
606 
607  LOG_WARNING("UVC metadata payloads are not available for stream "
608  << std::hex << fcc << std::dec << sp->get_format()
609  << ". Please refer to installation chapter for details.");
610  one_time_note = true;
611  }
612  return _backup_timestamp_reader->get_frame_timestamp(frame);
613  }
614  }
615 
616  unsigned long long sr300_timestamp_reader_from_metadata::get_frame_counter(const std::shared_ptr<frame_interface>& frame) const
617  {
618  std::lock_guard<std::recursive_mutex> lock(_mtx);
619 
620  if (has_metadata_fc(frame))
621  {
622  auto f = std::dynamic_pointer_cast<librealsense::frame>(frame);
623  if (!f)
624  {
625  LOG_ERROR("Frame is not valid. Failed to downcast to librealsense::frame.");
626  return 0;
627  }
628  auto md = (librealsense::metadata_raw*)(f->additional_data.metadata_blob.data());
629  return md->mode.sr300_rgb_mode.frame_counter; // The attribute offset is identical for all sr300-supported streams
630  }
631 
632  return _backup_timestamp_reader->get_frame_counter(frame);
633  }
634 
636  {
637  std::lock_guard<std::recursive_mutex> lock(_mtx);
638  one_time_note = false;
639  _backup_timestamp_reader->reset();
640  ts_wrap.reset();
641  }
642 
644  {
645  std::lock_guard<std::recursive_mutex> lock(_mtx);
646 
647  return (has_metadata_ts(frame)) ? RS2_TIMESTAMP_DOMAIN_HARDWARE_CLOCK : _backup_timestamp_reader->get_frame_timestamp_domain(frame);
648  }
649 
650  std::shared_ptr<matcher> sr3xx_camera::create_matcher(const frame_holder& frame) const
651  {
652  std::vector<std::shared_ptr<matcher>> depth_matchers;
653 
654  std::vector<stream_interface*> streams = { _depth_stream.get(), _ir_stream.get() };
655 
656  for (auto& s : streams)
657  {
658  depth_matchers.push_back(std::make_shared<identity_matcher>(s->get_unique_id(), s->get_stream_type()));
659  }
660  std::vector<std::shared_ptr<matcher>> matchers;
662  {
663  matchers.push_back(std::make_shared<timestamp_composite_matcher>(depth_matchers));
664  }
665  else
666  {
667  matchers.push_back(std::make_shared<frame_number_composite_matcher>(depth_matchers));
668  }
669 
670  return std::make_shared<timestamp_composite_matcher>(matchers);
671  }
672 
673  std::shared_ptr<matcher> sr300_camera::create_matcher(const frame_holder& frame) const
674  {
675  std::vector<std::shared_ptr<matcher>> depth_matchers;
676 
677  std::vector<stream_interface*> streams = { _depth_stream.get(), _ir_stream.get() };
678 
679  for (auto& s : streams)
680  {
681  depth_matchers.push_back(std::make_shared<identity_matcher>(s->get_unique_id(), s->get_stream_type()));
682  }
683  std::vector<std::shared_ptr<matcher>> matchers;
685  {
686  matchers.push_back(std::make_shared<timestamp_composite_matcher>(depth_matchers));
687  }
688  else
689  {
690  matchers.push_back(std::make_shared<frame_number_composite_matcher>(depth_matchers));
691  }
692 
693  auto color_matcher = std::make_shared<identity_matcher>(_color_stream->get_unique_id(), _color_stream->get_stream_type());
694  matchers.push_back(color_matcher);
695 
696  return std::make_shared<timestamp_composite_matcher>(matchers);
697  }
698 
700  {
702  res.push_back(std::make_shared<threshold>());
703  res.push_back(std::make_shared<spatial_filter>());
704  res.push_back(std::make_shared<temporal_filter>());
705  res.push_back(std::make_shared<hole_filling_filter>());
706  return res;
707  }
708 }
static const textual_icon lock
Definition: model-views.h:218
virtual void register_option(rs2_option id, std::shared_ptr< option > option)
Definition: sensor.cpp:1070
static processing_blocks get_sr300_depth_recommended_proccesing_blocks()
Definition: sr300.cpp:699
static rs2_intrinsics make_color_intrinsics(const ivcam::camera_calib_params &c, const int2 &dims)
Definition: sr300.cpp:253
std::shared_ptr< synthetic_sensor > create_color_device(std::shared_ptr< context > ctx, const platform::uvc_device_info &color)
Definition: sr300.cpp:117
std::shared_ptr< synthetic_sensor > create_depth_device(std::shared_ptr< context > ctx, const platform::uvc_device_info &depth)
Definition: sr300.cpp:177
std::vector< platform::uvc_device_info > filter_by_product(const std::vector< platform::uvc_device_info > &devices, const std::set< uint16_t > &pid_list)
Definition: context.cpp:478
ivcam::camera_calib_params get_calibration() const
Definition: sr300.cpp:434
rs2_extrinsics from_pose(pose a)
Definition: src/types.h:602
void assign_hw_monitor(std::shared_ptr< hw_monitor > hardware_monitor)
metadata_raw - metadata structure layout as transmitted and received by backend
Definition: src/metadata.h:678
GLdouble s
std::map< uint32_t, rs2_stream > sr300_color_fourcc_to_rs2_stream
Definition: sr300.cpp:24
void trim_device_list(std::vector< platform::usb_device_info > &devices, const std::vector< platform::usb_device_info > &chosen)
Definition: context.cpp:600
#define LOG_WARNING(...)
Definition: src/types.h:241
GLuint color
std::vector< uint8_t > backup_flash(update_progress_callback_ptr callback) override
Definition: sr300.cpp:363
sr305_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &color, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
Definition: sr300.cpp:528
rs2_intrinsics intrin
const uint16_t SR300v2_PID
GLint GLint GLsizei GLsizei GLsizei depth
void register_same_extrinsics(const stream_interface &from, const stream_interface &to)
Definition: environment.cpp:23
unsigned short uint16_t
Definition: stdint.h:79
bool try_fetch_usb_device(std::vector< platform::usb_device_info > &devices, const platform::uvc_device_info &info, platform::usb_device_info &result)
std::shared_ptr< device_interface > create(std::shared_ptr< context > ctx, bool register_device_notifications) const override
Definition: sr300.cpp:43
std::shared_ptr< hw_monitor > _hw_monitor
unsigned char uint8_t
Definition: stdint.h:78
command get_flash_logs_command() const
Definition: sr300.cpp:567
e
Definition: rmse.py:177
sr306_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
Definition: sr300.cpp:548
rs2_time_t get_frame_timestamp(const std::shared_ptr< frame_interface > &frame) override
Definition: sr300.cpp:582
float read_mems_temp() const
Definition: sr300.cpp:274
std::shared_ptr< rs2_update_progress_callback > update_progress_callback_ptr
Definition: src/types.h:1077
GLdouble t
void update_flash(const std::vector< uint8_t > &image, update_progress_callback_ptr callback, int update_mode) override
Definition: sr300.cpp:410
command get_firmware_logs_command() const
Definition: sr300.cpp:562
float3x3 transpose(const float3x3 &a)
Definition: src/types.h:588
def info(name, value, persistent=False)
Definition: test.py:301
std::map< uint32_t, rs2_format > sr300_color_fourcc_to_rs2_format
Definition: sr300.cpp:19
GLdouble f
void register_extrinsics(const stream_interface &from, const stream_interface &to, std::weak_ptr< lazy< rs2_extrinsics >> extr)
Definition: environment.cpp:28
GLenum mode
std::string hexify(const T &val)
Definition: src/types.h:185
void register_info(rs2_camera_info info, const std::string &val)
Definition: sensor.cpp:602
unsigned long long get_frame_counter(const std::shared_ptr< frame_interface > &frame) const override
Definition: sr300.cpp:616
dictionary streams
Definition: t265_stereo.py:140
GLsizeiptr size
std::vector< std::vector< platform::uvc_device_info > > group_devices_by_unique_id(const std::vector< platform::uvc_device_info > &devices)
Definition: context.cpp:583
processing_blocks get_depth_recommended_proccesing_blocks()
Definition: sensor.cpp:228
std::shared_ptr< lazy< rs2_extrinsics > > _depth_to_color_extrinsics
const GLubyte * c
Definition: glext.h:12690
platform::usb_device_info _hwm
const double TIMESTAMP_10NSEC_TO_MSEC
unsigned int uint32_t
Definition: stdint.h:80
ivcam::camera_calib_params CalibrationParameters
Definition: sr300.cpp:422
GLboolean GLuint group
Definition: glext.h:5688
std::map< uint32_t, rs2_format > sr300_depth_fourcc_to_rs2_format
Definition: sr300.cpp:30
platform::uvc_device_info _depth
const uint8_t IVCAM_DEPTH_FILTER_OPTION
Definition: ivcam-private.h:15
uint32_t rs_fourcc(const T a, const T b, const T c, const T d)
Definition: src/types.h:1846
platform::uvc_device_info get_mi(const std::vector< platform::uvc_device_info > &devices, uint32_t mi)
Definition: context.cpp:634
static processing_block_factory create_id_pbf(rs2_format format, rs2_stream stream, int idx=0)
void enter_update_state() const override
Definition: sr300.cpp:335
std::vector< uint8_t > data
Definition: hw-monitor.h:240
const uint8_t IVCAM_DEPTH_MOTION_RANGE
Definition: ivcam-private.h:13
def callback(frame)
Definition: t265_stereo.py:91
std::map< uint32_t, rs2_stream > sr300_depth_fourcc_to_rs2_stream
Definition: sr300.cpp:36
GLint j
std::shared_ptr< md_attribute_parser_base > make_uvc_header_parser(Attribute St::*attribute, attrib_modifyer mod=nullptr)
A utility function to create UVC metadata header parser.
lazy< ivcam::camera_calib_params > _camer_calib_params
signed char int8_t
Definition: stdint.h:75
#define LOG_ERROR(...)
Definition: src/types.h:242
platform::backend_device_group get_device_data() const override
void update_info(rs2_camera_info info, const std::string &val)
Definition: sensor.cpp:614
const platform::extension_unit depth_xu
Definition: ds5-private.h:159
rs2_timestamp_domain get_frame_timestamp_domain(const std::shared_ptr< frame_interface > &frame) const override
Definition: sr300.cpp:643
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
Definition: json.hpp:12141
const uint8_t IVCAM_DEPTH_CONFIDENCE_THRESH
Definition: ivcam-private.h:16
static environment & get_instance()
int add_sensor(const std::shared_ptr< sensor_interface > &sensor_base)
Definition: device.cpp:163
extrinsics_graph & get_extrinsics_graph()
void set_auto_range(const ivcam::cam_auto_range_request &c) const
Definition: sr300.cpp:304
sensor_interface & get_sensor(size_t subdevice) override
Definition: device.cpp:187
std::shared_ptr< stream_interface > _ir_stream
void enable_timestamp(bool colorEnable, bool depthEnable) const
Definition: sr300.cpp:296
sr300_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &color, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
Definition: sr300.cpp:512
void create_snapshot(std::shared_ptr< debug_interface > &snapshot) const override
Definition: sr300.cpp:572
frame_interface * frame
Definition: streaming.h:126
std::shared_ptr< stream_interface > _depth_stream
const uint8_t IVCAM_DEPTH_LASER_POWER
Definition: ivcam-private.h:11
long long rs2_metadata_type
Definition: rs_types.h:301
int min(int a, int b)
Definition: lz4s.c:73
GLenum GLfloat param
const uint16_t SR306_PID
const uint8_t IVCAM_DEPTH_ACCURACY
Definition: ivcam-private.h:12
void enable_recording(std::function< void(const debug_interface &)> record_action) override
Definition: sr300.cpp:576
Video stream intrinsics.
Definition: rs_types.h:58
void register_stream_to_extrinsic_group(const stream_interface &stream, uint32_t groupd_index)
Definition: device.cpp:246
static rs2_intrinsics make_depth_intrinsics(const ivcam::camera_calib_params &c, const int2 &dims)
Definition: sr300.cpp:242
int i
#define offsetof(STRUCTURE, FIELD)
Definition: sqlite3.c:11372
GLuint res
Definition: glext.h:8856
std::array< float, 3 > color
Definition: model-views.h:449
signed int int32_t
Definition: stdint.h:77
virtual std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
Definition: sr300.cpp:673
sr3xx_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
Definition: sr300.cpp:445
const uint16_t SR300_PID
platform::uvc_device_info _color
static std::vector< std::shared_ptr< device_info > > pick_sr300_devices(std::shared_ptr< context > ctx, std::vector< platform::uvc_device_info > &platform, std::vector< platform::usb_device_info > &usb)
Definition: sr300.cpp:68
double rs2_time_t
Definition: rs_types.h:300
GLboolean * data
const uint16_t HW_MONITOR_BUFFER_SIZE
Definition: hw-monitor.h:41
std::shared_ptr< stream_interface > _color_stream
int read_ir_temp() const
Definition: sr300.cpp:282
std::shared_ptr< md_attribute_parser_base > make_sr300_attribute_parser(Attribute S::*attribute, unsigned long long offset, attrib_modifyer mod=nullptr)
A helper function to create a specialized attribute parser. Return it as a pointer to a base-class...
Definition: parser.hpp:150
virtual std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
Definition: sr300.cpp:650
void copy(void *dst, void const *src, size_t size)
Definition: types.cpp:836
GLintptr offset
synthetic_sensor & get_depth_sensor()
virtual bool supports_frame_metadata(const rs2_frame_metadata_value &frame_metadata) const =0
virtual void set_roi_method(std::shared_ptr< region_of_interest_method > roi_method)=0
bool mi_present(const std::vector< platform::uvc_device_info > &devices, uint32_t mi)
Definition: context.cpp:624
std::string to_string(T value)
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
Definition: rs_frame.h:19
void force_hardware_reset() const
Definition: sr300.cpp:289


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