zr300.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #include <climits>
5 #include <algorithm>
6 
7 #include "image.h"
8 #include "ds-private.h"
9 #include "zr300.h"
10 #include "ivcam-private.h"
11 #include "hw-monitor.h"
12 
13 using namespace rsimpl;
14 using namespace rsimpl::ds;
15 using namespace rsimpl::motion_module;
16 using namespace rsimpl::hw_monitor;
17 
18 namespace rsimpl
19 {
20  zr300_camera::zr300_camera(std::shared_ptr<uvc::device> device, const static_device_info & info, motion_module_calibration in_fe_intrinsic, calibration_validator validator)
21  : ds_device(device, info, validator),
22  motion_module_ctrl(device.get(), usbMutex),
23  auto_exposure(nullptr),
24  to_add_frames((auto_exposure_state.get_auto_exposure_state(RS_OPTION_FISHEYE_ENABLE_AUTO_EXPOSURE) == 1)),
25  fe_intrinsic(in_fe_intrinsic)
26  {}
27 
29  {
30 
31  }
32 
34  {
35  return (option == RS_OPTION_FISHEYE_GAIN);
36  }
37 
39  {
40  return (option == RS_OPTION_FISHEYE_STROBE) ||
42  (option == RS_OPTION_FISHEYE_EXPOSURE);
43  }
44 
45  void zr300_camera::set_options(const rs_option options[], size_t count, const double values[])
46  {
47  std::vector<rs_option> base_opt;
48  std::vector<double> base_opt_val;
49 
50  auto& dev = get_device();
51 
52  // Handle ZR300 specific options first
53  for (size_t i = 0; i < count; ++i)
54  {
55  if (is_fisheye_uvc_control(options[i]))
56  {
57  uvc::set_pu_control_with_retry(dev, 3, options[i], static_cast<int>(values[i]));
58  continue;
59  }
60 
61  switch (options[i])
62  {
63  case RS_OPTION_FISHEYE_STROBE: zr300::set_fisheye_strobe(dev, static_cast<uint8_t>(values[i])); break;
64  case RS_OPTION_FISHEYE_EXTERNAL_TRIGGER: zr300::set_fisheye_external_trigger(dev, static_cast<uint8_t>(values[i])); break;
65  case RS_OPTION_FISHEYE_EXPOSURE: zr300::set_fisheye_exposure(dev, static_cast<uint16_t>(values[i])); break;
72 
73  // Default will be handled by parent implementation
74  default: base_opt.push_back(options[i]); base_opt_val.push_back(values[i]); break;
75  }
76  }
77 
78  //Then handle the common options
79  if (base_opt.size())
80  ds_device::set_options(base_opt.data(), base_opt.size(), base_opt_val.data());
81  }
82 
83  void zr300_camera::get_options(const rs_option options[], size_t count, double values[])
84  {
85  std::vector<rs_option> base_opt;
86  std::vector<size_t> base_opt_index;
87  std::vector<double> base_opt_val;
88 
89  auto & dev = get_device();
90 
91  // Acquire ZR300-specific options first
92  for (size_t i = 0; i<count; ++i)
93  {
94  if (is_fisheye_uvc_control(options[i]))
95  {
96  values[i] = uvc::get_pu_control(dev, 3, options[i]);
97  continue;
98  }
99 
100  switch(options[i])
101  {
102 
103  case RS_OPTION_FISHEYE_STROBE: values[i] = zr300::get_fisheye_strobe (dev); break;
111  case RS_OPTION_HARDWARE_LOGGER_ENABLED: values[i] = get_fw_logger_option(); break;
112 
113  // Default will be handled by parent implementation
114  default: base_opt.push_back(options[i]); base_opt_index.push_back(i); break;
115  }
116  }
117 
118  //Then retrieve the common options
119  if (base_opt.size())
120  {
121  base_opt_val.resize(base_opt.size());
122  ds_device::get_options(base_opt.data(), base_opt.size(), base_opt_val.data());
123  }
124 
125  // Merge the local data with values obtained by base class
126  for (auto i : base_opt_index)
127  values[i] = base_opt_val[i];
128  }
129 
131  {
132  switch(type)
133  {
136  break;
137  default: rs_device_base::send_blob_to_device(type, data, size);
138  }
139  }
140 
142  {
144  }
145 
146  void zr300_camera::on_before_callback(rs_stream stream, rs_frame_ref * frame, std::shared_ptr<rsimpl::frame_archive> archive)
147  {
148  if (!to_add_frames || stream != RS_STREAM_FISHEYE)
149  return;
150 
151  auto_exposure->add_frame(clone_frame(frame), archive);
152  }
153 
155  {
156  if (value >= 1)
157  {
159  start_fw_logger(char(adaptor_board_command::GLD), 100, usbMutex);
160  }
161  else
162  {
164  stop_fw_logger();
165  }
166  }
167 
169  {
171  }
172 
174  {
177 
179  {
180  if (auto_exposure_prev_state) // auto_exposure previous value
181  {
182  if (auto_exposure)
183  auto_exposure->update_auto_exposure_state(auto_exposure_state); // auto_exposure mode not changed
184  }
185  else
186  {
187  to_add_frames = true; // auto_exposure moved from disable to enable
188  }
189  }
190  else
191  {
192  if (auto_exposure_prev_state)
193  {
194  to_add_frames = false; // auto_exposure moved from enable to disable
195  }
196  }
197  }
198 
200  {
202  }
203 
205  {
207  motion_module_ready = on;
208  }
209 
210  // Power on Fisheye camera (dspwr)
212  {
215 
217  auto_exposure = std::make_shared<auto_exposure_mechanism>(this, auto_exposure_state);
218 
219  ds_device::start(source);
220  }
221 
222  // Power off Fisheye camera
224  {
227 
228  ds_device::stop(source);
230  auto_exposure.reset();
231  }
232 
233  // Power on motion module (mmpwr)
235  {
239  }
240 
241  // Power down Motion Module
243  {
247  }
248 
249  rs_stream zr300_camera::select_key_stream(const std::vector<rsimpl::subdevice_mode_selection> & selected_modes)
250  {
251  // When all streams are enabled at an identical framerate, R200 images are delivered in the order: Z -> Third -> L/R
252  // To maximize the chance of being able to deliver coherent framesets, we want to wait on the latest image coming from
253  // a stream running at the fastest framerate.
254  int fps[RS_STREAM_NATIVE_COUNT] = {}, max_fps = 0;
255  for(const auto & m : selected_modes)
256  {
257  for(const auto & output : m.get_outputs())
258  {
259  fps[output.first] = m.mode.fps;
260  max_fps = std::max(max_fps, m.mode.fps);
261  }
262  }
263 
264  // Select the "latest arriving" stream which is running at the fastest framerate
266  {
267  if(fps[s] == max_fps) return s;
268  }
269  return RS_STREAM_DEPTH;
270  }
271 
273  {
275  {
276  throw std::runtime_error("Motion intrinsic is not valid");
277  }
279  }
280 
282  {
283  // The following 4 parameters are removed from DS4.1 FW:
284  std::vector<rs_option> auto_exposure_options = {
289  };
290 
291  if (std::find(auto_exposure_options.begin(), auto_exposure_options.end(), option) != auto_exposure_options.end())
292  {
293  return false;
294  }
295 
296  return ds_device::supports_option(option);
297  }
298 
300  {
301  if (!validate_motion_extrinsics(from))
302  {
303  throw std::runtime_error("Motion intrinsic is not valid");
304  }
305  switch (from)
306  {
307  case RS_STREAM_DEPTH:
309  case RS_STREAM_COLOR:
311  case RS_STREAM_FISHEYE:
313  default:
314  throw std::runtime_error(to_string() << "No motion extrinsics from "<<from );
315  }
316  }
317 
318  void zr300_camera::get_option_range(rs_option option, double & min, double & max, double & step, double & def)
319  {
320  if (is_fisheye_uvc_control(option))
321  {
322  int mn, mx, stp, df;
323  uvc::get_pu_control_range(get_device(), 3, option, &mn, &mx, &stp, &df);
324  min = mn;
325  max = mx;
326  step = stp;
327  def = df;
328  }
329  else
330  {
331  // Default to parent implementation
332  ds_device::get_option_range(option, min, max, step, def);
333  }
334  }
335 
337  {
338  hwmon_cmd cmd((int)adaptor_board_command::FRCNT);
340  unsigned long long frame_counter = 0;
341  memcpy(&frame_counter, cmd.receivedCommandData, cmd.receivedCommandDataLength);
342  return frame_counter;
343  }
344 
346  {
348  {
349  LOG_WARNING("Motion exntrinsics validation from "<< from_stream <<" failed, ver.size = " << fe_intrinsic.calib.mm_extrinsic.ver.size << " real size = " << fe_intrinsic.calib.mm_extrinsic.get_data_size());
350  return false;
351  }
352 
353  auto res = true;
354  switch (from_stream)
355  {
356  case RS_STREAM_DEPTH:
358  res = false;
359 
360  break;
361  case RS_STREAM_COLOR:
363  res = false;
364 
365  break;
366  case RS_STREAM_FISHEYE:
368  res = false;
369 
370  break;
371  default:
372  res = false;
373  }
374 
375  if (res == false) LOG_WARNING("Motion exntrinsics validation from " << from_stream << " failed, because the data is invalid");
376  return res;
377  }
378 
380  {
382  {
383  LOG_ERROR("Motion intrinsics validation of failed, ver.size = " << fe_intrinsic.calib.imu_intrinsic.ver.size << " real size = " << fe_intrinsic.calib.imu_intrinsic.get_data_size());
384  return false;
385  }
387  {
388  LOG_ERROR("Motion intrinsics validation of failed, because the data is invalid");
389  return false;
390  }
391 
392  return true;
393  }
394 
395  serial_number read_serial_number(uvc::device & device, std::timed_mutex & mutex)
396  {
397  uint8_t serial_number_raw[HW_MONITOR_BUFFER_SIZE];
398  size_t bufferLength = HW_MONITOR_BUFFER_SIZE;
399  get_raw_data(static_cast<uint8_t>(adaptor_board_command::MM_SNB), device, mutex, serial_number_raw, bufferLength);
400 
401  serial_number sn;
402  memcpy(&sn, serial_number_raw, std::min(sizeof(serial_number), bufferLength)); // Is this longer or shorter than the rawCalib struct?
403  return sn;
404  }
405  calibration read_calibration(uvc::device & device, std::timed_mutex & mutex)
406  {
407  uint8_t scalibration_raw[HW_MONITOR_BUFFER_SIZE];
408  size_t bufferLength = HW_MONITOR_BUFFER_SIZE;
409  get_raw_data(static_cast<uint8_t>(adaptor_board_command::MM_TRB), device, mutex, scalibration_raw, bufferLength);
410 
412  memcpy(&calibration, scalibration_raw, std::min(sizeof(calibration), bufferLength)); // Is this longer or shorter than the rawCalib struct?
413  return calibration;
414  }
415  motion_module_calibration read_fisheye_intrinsic(uvc::device & device, std::timed_mutex & mutex)
416  {
417  motion_module_calibration intrinsic;
418  intrinsic.calib = read_calibration(device, mutex);
419  intrinsic.sn = read_serial_number(device, mutex);
420 
421  return intrinsic;
422  }
423 
424 
425  std::shared_ptr<rs_device> make_zr300_device(std::shared_ptr<uvc::device> device)
426  {
427  LOG_INFO("Connecting to Intel RealSense ZR300");
428 
429  static_device_info info;
430  info.name = "Intel RealSense ZR300" ;
431  auto cam_info = ds::read_camera_info(*device);
432 
434  auto succeeded_to_read_fisheye_intrinsic = false;
435 
436 
437  // TODO - is Motion Module optional
439  {
440  // Acquire Device handle for Motion Module API
442  std::timed_mutex mtx;
443  try
444  {
445  std::string version_string;
446  ivcam::get_firmware_version_string(*device, mtx, version_string, (int)adaptor_board_command::GVD);
448  ivcam::get_firmware_version_string(*device, mtx, version_string, (int)adaptor_board_command::GVD, 4);
450  }
451  catch (...)
452  {
453  LOG_ERROR("Failed to get firmware version");
454  }
455 
456  try
457  {
458  std::timed_mutex mutex;
459  fisheye_intrinsic = read_fisheye_intrinsic(*device, mutex);
460  succeeded_to_read_fisheye_intrinsic = true;
461  }
462  catch (...)
463  {
464  LOG_ERROR("Couldn't query adapter board / motion module FW version!");
465  }
466  rs_intrinsics rs_intrinsics = fisheye_intrinsic.calib.fe_intrinsic;
467 
470 
474  info.presets[RS_STREAM_FISHEYE][RS_PRESET_HIGHEST_FRAMERATE] = { true, 640, 480, RS_FORMAT_RAW8, 60 };
475 
476  for (auto &fps : { 30, 60})
477  info.subdevice_modes.push_back({ 3, { 640, 480 }, pf_raw8, fps, rs_intrinsics, { /*TODO:ask if we need rect_modes*/ }, { 0 } });
478 
480  {
482  if (ver >= firmware_version("1.25.0.0") && ver < firmware_version("1.27.2.90"))
483  info.options.push_back({ RS_OPTION_FISHEYE_EXPOSURE, 40, 331, 1, 40 });
484  else if (ver >= firmware_version("1.27.2.90"))
485  {
487  info.options.push_back({ RS_OPTION_FISHEYE_EXPOSURE, 2, 320, 1, 4 });
488  }
489  }
490 
492 
493  info.options.push_back({ RS_OPTION_FISHEYE_GAIN, 0, 0, 0, 0 });
494  info.options.push_back({ RS_OPTION_FISHEYE_STROBE, 0, 1, 1, 0 });
495  info.options.push_back({ RS_OPTION_FISHEYE_EXTERNAL_TRIGGER, 0, 1, 1, 0 });
496  info.options.push_back({ RS_OPTION_FISHEYE_ENABLE_AUTO_EXPOSURE, 0, 1, 1, 1 });
497  info.options.push_back({ RS_OPTION_FISHEYE_AUTO_EXPOSURE_MODE, 0, 2, 1, 0 });
498  info.options.push_back({ RS_OPTION_FISHEYE_AUTO_EXPOSURE_ANTIFLICKER_RATE, 50, 60, 10, 60 });
499  info.options.push_back({ RS_OPTION_FISHEYE_AUTO_EXPOSURE_PIXEL_SAMPLE_RATE, 1, 3, 1, 1 });
500  info.options.push_back({ RS_OPTION_FISHEYE_AUTO_EXPOSURE_SKIP_FRAMES, 2, 3, 1, 2 });
501  info.options.push_back({ RS_OPTION_HARDWARE_LOGGER_ENABLED, 0, 1, 1, 0 });
502  }
503 
504  ds_device::set_common_ds_config(device, info, cam_info);
505  info.subdevice_modes.push_back({ 2, { 1920, 1080 }, pf_rw16, 30, cam_info.calibration.intrinsicsThird[0], { cam_info.calibration.modesThird[0][0] }, { 0 } });
506 
507  if (succeeded_to_read_fisheye_intrinsic)
508  {
509  auto fe_extrinsic = fisheye_intrinsic.calib.mm_extrinsic;
510  pose fisheye_to_depth = { reinterpret_cast<float3x3 &>(fe_extrinsic.fe_to_depth.rotation), reinterpret_cast<float3&>(fe_extrinsic.fe_to_depth.translation) };
511  auto depth_to_fisheye = inverse(fisheye_to_depth);
512  info.stream_poses[RS_STREAM_FISHEYE] = depth_to_fisheye;
513 
514  info.capabilities_vector.push_back({ RS_CAPABILITIES_FISH_EYE, { 1, 15, 5, 0 }, firmware_version::any(), RS_CAMERA_INFO_MOTION_MODULE_FIRMWARE_VERSION });
515  info.capabilities_vector.push_back({ RS_CAPABILITIES_MOTION_EVENTS, { 1, 15, 5, 0 }, firmware_version::any(), RS_CAMERA_INFO_MOTION_MODULE_FIRMWARE_VERSION });
516  }
517  else
518  {
519  LOG_WARNING("Motion module capabilities were disabled due to failure to acquire intrinsic");
520  }
521 
522  auto fisheye_intrinsics_validator = [fisheye_intrinsic, succeeded_to_read_fisheye_intrinsic](rs_stream stream)
523  {
524  if (stream != RS_STREAM_FISHEYE)
525  {
526  return true;
527  }
528  if (!succeeded_to_read_fisheye_intrinsic)
529  {
530  LOG_WARNING("Intrinsics validation of "<<stream<<" failed, because the reading of calibration table failed");
531  return false;
532  }
533  if (fisheye_intrinsic.calib.fe_intrinsic.ver.size != fisheye_intrinsic.calib.fe_intrinsic.get_data_size())
534  {
535  LOG_WARNING("Intrinsics validation of " << stream << " failed, ver.size param. = " << (int)fisheye_intrinsic.calib.fe_intrinsic.ver.size << "; actual size = " << fisheye_intrinsic.calib.fe_intrinsic.get_data_size());
536  return false;
537  }
538  if (!fisheye_intrinsic.calib.fe_intrinsic.has_data())
539  {
540  LOG_WARNING("Intrinsics validation of " << stream <<" failed, because the data is invalid");
541  return false;
542  }
543  return true;
544  };
545 
546  auto fisheye_extrinsics_validator = [fisheye_intrinsic, succeeded_to_read_fisheye_intrinsic](rs_stream from_stream, rs_stream to_stream)
547  {
548  if (from_stream != RS_STREAM_FISHEYE && to_stream != RS_STREAM_FISHEYE)
549  {
550  return true;
551  }
552  if (!succeeded_to_read_fisheye_intrinsic)
553  {
554  LOG_WARNING("Exstrinsics validation of" << from_stream <<" to "<< to_stream << " failed, because the reading of calibration table failed");
555  return false;
556  }
557  if (fisheye_intrinsic.calib.mm_extrinsic.ver.size != fisheye_intrinsic.calib.mm_extrinsic.get_data_size())
558  {
559  LOG_WARNING("Extrinsics validation of" << from_stream <<" to "<<to_stream<< " failed, ver.size = " << fisheye_intrinsic.calib.fe_intrinsic.ver.size << " real size = " << fisheye_intrinsic.calib.fe_intrinsic.get_data_size());
560  return false;
561  }
562  if(!fisheye_intrinsic.calib.mm_extrinsic.fe_to_depth.has_data())
563  {
564  LOG_WARNING("Extrinsics validation of" << from_stream <<" to "<<to_stream<< " failed, because the data is invalid");
565  return false;
566  }
567 
568  return true;
569  };
570 
571  return std::make_shared<zr300_camera>(device, info, fisheye_intrinsic, calibration_validator(fisheye_extrinsics_validator, fisheye_intrinsics_validator));
572  }
573 
575  {
576  switch (option)
577  {
579  return (static_cast<unsigned>(is_auto_exposure));
580  break;
582  return (static_cast<unsigned>(mode));
583  break;
585  return (static_cast<unsigned>(rate));
586  break;
588  return (static_cast<unsigned>(sample_rate));
589  break;
591  return (static_cast<unsigned>(skip_frames));
592  break;
593  default:
594  throw std::logic_error("Option unsupported");
595  break;
596  }
597  }
598 
600  {
601  switch (option)
602  {
604  is_auto_exposure = (value >= 1);
605  break;
607  mode = static_cast<auto_exposure_modes>((int)value);
608  break;
610  rate = static_cast<unsigned>(value);
611  break;
613  sample_rate = static_cast<unsigned>(value);
614  break;
616  skip_frames = static_cast<unsigned>(value);
617  break;
618  default:
619  throw std::logic_error("Option unsupported");
620  break;
621  }
622  }
623 
624  auto_exposure_mechanism::auto_exposure_mechanism(zr300_camera* dev, fisheye_auto_exposure_state auto_exposure_state) : device(dev), auto_exposure_algo(auto_exposure_state), sync_archive(nullptr), keep_alive(true), frames_counter(0), skip_frames(get_skip_frames(auto_exposure_state))
625  {
626  exposure_thread = std::make_shared<std::thread>([this]() {
627  while (keep_alive)
628  {
629  std::unique_lock<std::mutex> lk(queue_mtx);
630  cv.wait(lk, [&] {return (get_queue_size() || !keep_alive); });
631  if (!keep_alive)
632  return;
633 
634 
635  rs_frame_ref* frame_ref = nullptr;
636  auto frame_sts = try_pop_front_data(&frame_ref);
637  lk.unlock();
638 
639  double values[2] = {};
640  unsigned long long frame_counter;
641  try {
643  {
644  double gain[1] = {};
645  rs_option options[] = { RS_OPTION_FISHEYE_GAIN };
646  device->get_options(options, 1, gain);
648  values[1] = gain[0];
649  }
650  else
651  {
653  device->get_options(options, 2, values);
654  }
655 
656  values[0] /= 10.; // Fisheye exposure value by extension control is in units of 10 mSec
657  frame_counter = device->get_frame_counter_by_usb_cmd();
658  push_back_exp_and_cnt(exposure_and_frame_counter(values[0], frame_counter));
659  }
660  catch (...) {};
661 
662  if (frame_sts)
663  {
664  unsigned long long frame_counter = frame_ref->get_frame_number();
665  double exp_by_frame_cnt;
666  auto exp_and_cnt_sts = try_get_exp_by_frame_cnt(exp_by_frame_cnt, frame_counter);
667 
668  auto exposure_value = static_cast<float>((exp_and_cnt_sts)? exp_by_frame_cnt : values[0]);
669  auto gain_value = static_cast<float>(2 + (values[1]-15) / 8.);
670 
671  bool sts = auto_exposure_algo.analyze_image(frame_ref);
672  if (sts)
673  {
674  bool modify_exposure, modify_gain;
675  auto_exposure_algo.modify_exposure(exposure_value, modify_exposure, gain_value, modify_gain);
676 
677  if (modify_exposure)
678  {
680  double value[] = { exposure_value * 10. };
681  if (value[0] < 1)
682  value[0] = 1;
683 
684  device->set_options(option, 1, value);
685  }
686 
687  if (modify_gain)
688  {
690  double value[] = { (gain_value-2) * 8 +15. };
691  device->set_options(option, 1, value);
692  }
693  }
694  }
695  sync_archive->release_frame_ref((rsimpl::frame_archive::frame_ref *)frame_ref);
696  }
697  });
698  }
699 
701  {
702  {
703  std::lock_guard<std::mutex> lk(queue_mtx);
704  keep_alive = false;
705  clear_queue();
706  }
707  cv.notify_one();
708  exposure_thread->join();
709  }
710 
712  {
713  std::lock_guard<std::mutex> lk(queue_mtx);
715  auto_exposure_algo.update_options(auto_exposure_state);
716  }
717 
718  void auto_exposure_mechanism::add_frame(rs_frame_ref* frame, std::shared_ptr<rsimpl::frame_archive> archive)
719  {
720  if (!keep_alive || (skip_frames && (frames_counter++) != skip_frames))
721  {
722  archive->release_frame_ref((rsimpl::frame_archive::frame_ref *)frame);
723  return;
724  }
725 
726  frames_counter = 0;
727 
728  if (!sync_archive)
729  sync_archive = archive;
730 
731  {
732  std::lock_guard<std::mutex> lk(queue_mtx);
733  if (data_queue.size() > 1)
734  {
735  sync_archive->release_frame_ref((rsimpl::frame_archive::frame_ref *)data_queue.front());
736  data_queue.pop_front();
737  }
738 
739  push_back_data(frame);
740  }
741  cv.notify_one();
742  }
743 
745  {
746  std::lock_guard<std::mutex> lk(exp_and_cnt_queue_mtx);
747 
750 
751  exposure_and_frame_counter_queue.push_back(exp_and_cnt);
752  }
753 
754  bool auto_exposure_mechanism::try_get_exp_by_frame_cnt(double& exposure, const unsigned long long frame_counter)
755  {
756  std::lock_guard<std::mutex> lk(exp_and_cnt_queue_mtx);
757 
759  return false;
760 
761  unsigned long long min = std::numeric_limits<uint64_t>::max();
762  double exp;
763  auto it = std::find_if(exposure_and_frame_counter_queue.begin(), exposure_and_frame_counter_queue.end(),
764  [&](const exposure_and_frame_counter& element) {
765  unsigned int diff = std::abs(static_cast<int>(frame_counter - element.frame_counter));
766  if (diff < min)
767  {
768  min = diff;
769  exp = element.exposure;
770  return false;
771  }
772  return true;
773  });
774 
775  if (it != exposure_and_frame_counter_queue.end())
776  {
777  exposure = it->exposure;
779  return true;
780  }
781 
782  return false;
783  }
784 
786  {
787  data_queue.push_back(data);
788  }
789 
791  {
792  if (!data_queue.size())
793  return false;
794 
795  *data = data_queue.front();
796  data_queue.pop_front();
797 
798  return true;
799  }
800 
802  {
803  return data_queue.size();
804  }
805 
807  {
808  rs_frame_ref* frame_ref = nullptr;
809  while (try_pop_front_data(&frame_ref))
810  {
811  sync_archive->release_frame_ref((rsimpl::frame_archive::frame_ref *)frame_ref);
812  }
813  }
814 
816  {
817  update_options(auto_exposure_state);
818  }
819 
820  void auto_exposure_algorithm::modify_exposure(float& exposure_value, bool& exp_modified, float& gain_value, bool& gain_modified)
821  {
822  float total_exposure = exposure * gain;
823  LOG_DEBUG("TotalExposure " << total_exposure << ", target_exposure " << target_exposure);
824  if (fabs(target_exposure - total_exposure) > eps)
825  {
826  rounding_mode_type RoundingMode;
827 
828  if (target_exposure > total_exposure)
829  {
830  float target_exposure0 = total_exposure * (1.0f + exposure_step);
831 
832  target_exposure0 = std::min(target_exposure0, target_exposure);
833  increase_exposure_gain(target_exposure0, target_exposure0, exposure, gain);
834  RoundingMode = rounding_mode_type::ceil;
835  LOG_DEBUG(" ModifyExposure: IncreaseExposureGain: ");
836  LOG_DEBUG(" target_exposure0 " << target_exposure0);
837  }
838  else
839  {
840  float target_exposure0 = total_exposure / (1.0f + exposure_step);
841 
842  target_exposure0 = std::max(target_exposure0, target_exposure);
843  decrease_exposure_gain(target_exposure0, target_exposure0, exposure, gain);
844  RoundingMode = rounding_mode_type::floor;
845  LOG_DEBUG(" ModifyExposure: DecreaseExposureGain: ");
846  LOG_DEBUG(" target_exposure0 " << target_exposure0);
847  }
848  LOG_DEBUG(" exposure " << exposure << ", gain " << gain);
849  if (exposure_value != exposure)
850  {
851  exp_modified = true;
852  exposure_value = exposure;
853  exposure_value = exposure_to_value(exposure_value, RoundingMode);
854  LOG_DEBUG("output exposure by algo = " << exposure_value);
855  }
856  if (gain_value != gain)
857  {
858  gain_modified = true;
859  gain_value = gain;
860  LOG_DEBUG("GainModified: gain = " << gain);
861  gain_value = gain_to_value(gain_value, RoundingMode);
862  LOG_DEBUG(" rounded to: " << gain);
863  }
864  }
865  }
866 
868  {
869  int cols = image->get_frame_width();
870  int rows = image->get_frame_height();
871 
872  const int number_of_pixels = cols * rows; //VGA
873  if (number_of_pixels == 0) return false; // empty image
874 
875  std::vector<int> H(256);
876  int total_weight = number_of_pixels;
877 
878  im_hist((uint8_t*)image->get_frame_data(), cols, rows, image->get_frame_bpp() / 8 * cols, &H[0]);
879 
880  histogram_metric score = {};
881  histogram_score(H, total_weight, score);
882  // int EffectiveDynamicRange = (score.highlight_limit - score.shadow_limit);
884  float s1 = (score.main_mean - 128.0f) / 255.0f;
885  float s2 = 0;
886 
887  s2 = (score.over_exposure_count - score.under_exposure_count) / (float)total_weight;
888 
889  float s = -0.3f * (s1 + 5.0f * s2);
890  LOG_DEBUG(" AnalyzeImage Score: " << s);
891 
892  if (s > 0)
893  {
894  direction = +1;
895  increase_exposure_target(s, target_exposure);
896  }
897  else
898  {
899  LOG_DEBUG(" AnalyzeImage: DecreaseExposure");
900  direction = -1;
901  decrease_exposure_target(s, target_exposure);
902  }
903 
904  if (fabs(1.0f - (exposure * gain) / target_exposure) < hysteresis)
905  {
906  LOG_DEBUG(" AnalyzeImage: Don't Modify (Hysteresis): " << target_exposure << " " << exposure * gain);
907  return false;
908  }
909 
910  prev_direction = direction;
911  LOG_DEBUG(" AnalyzeImage: Modify");
912  return true;
913  }
914 
916  {
917  std::lock_guard<std::recursive_mutex> lock(state_mutex);
918 
919  state = options;
920  flicker_cycle = 1000.0f / (state.get_auto_exposure_state(RS_OPTION_FISHEYE_AUTO_EXPOSURE_ANTIFLICKER_RATE) * 2.0f);
921  }
922 
923  void auto_exposure_algorithm::im_hist(const uint8_t* data, const int width, const int height, const int rowStep, int h[])
924  {
925  std::lock_guard<std::recursive_mutex> lock(state_mutex);
926 
927  for (int i = 0; i < 256; ++i) h[i] = 0;
928  const uint8_t* rowData = data;
929  for (int i = 0; i < height; ++i, rowData += rowStep) for (int j = 0; j < width; j+=state.get_auto_exposure_state(RS_OPTION_FISHEYE_AUTO_EXPOSURE_PIXEL_SAMPLE_RATE)) ++h[rowData[j]];
930  }
931 
932  void auto_exposure_algorithm::increase_exposure_target(float mult, float& target_exposure)
933  {
934  target_exposure = std::min((exposure * gain) * (1.0f + mult), maximal_exposure * gain_limit);
935  }
937  void auto_exposure_algorithm::decrease_exposure_target(float mult, float& target_exposure)
938  {
939  target_exposure = std::max((exposure * gain) * (1.0f + mult), minimal_exposure * base_gain);
940  }
941 
942  void auto_exposure_algorithm::increase_exposure_gain(const float& target_exposure, const float& target_exposure0, float& exposure, float& gain)
943  {
944  std::lock_guard<std::recursive_mutex> lock(state_mutex);
945 
946  switch (state.get_auto_exposure_state(RS_OPTION_FISHEYE_AUTO_EXPOSURE_MODE))
947  {
948  case int(auto_exposure_modes::static_auto_exposure): static_increase_exposure_gain(target_exposure, target_exposure0, exposure, gain); break;
949  case int(auto_exposure_modes::auto_exposure_anti_flicker): anti_flicker_increase_exposure_gain(target_exposure, target_exposure0, exposure, gain); break;
950  case int(auto_exposure_modes::auto_exposure_hybrid): hybrid_increase_exposure_gain(target_exposure, target_exposure0, exposure, gain); break;
951  }
952  }
953  void auto_exposure_algorithm::decrease_exposure_gain(const float& target_exposure, const float& target_exposure0, float& exposure, float& gain)
954  {
955  std::lock_guard<std::recursive_mutex> lock(state_mutex);
956 
957  switch (state.get_auto_exposure_state(RS_OPTION_FISHEYE_AUTO_EXPOSURE_MODE))
958  {
959  case int(auto_exposure_modes::static_auto_exposure): static_decrease_exposure_gain(target_exposure, target_exposure0, exposure, gain); break;
960  case int(auto_exposure_modes::auto_exposure_anti_flicker): anti_flicker_decrease_exposure_gain(target_exposure, target_exposure0, exposure, gain); break;
961  case int(auto_exposure_modes::auto_exposure_hybrid): hybrid_decrease_exposure_gain(target_exposure, target_exposure0, exposure, gain); break;
962  }
963  }
964  void auto_exposure_algorithm::static_increase_exposure_gain(const float& /*target_exposure*/, const float& target_exposure0, float& exposure, float& gain)
965  {
966  exposure = std::max(minimal_exposure, std::min(target_exposure0 / base_gain, maximal_exposure));
967  gain = std::min(gain_limit, std::max(target_exposure0 / exposure, base_gain));
968  }
969  void auto_exposure_algorithm::static_decrease_exposure_gain(const float& /*target_exposure*/, const float& target_exposure0, float& exposure, float& gain)
970  {
971  exposure = std::max(minimal_exposure, std::min(target_exposure0 / base_gain, maximal_exposure));
972  gain = std::min(gain_limit, std::max(target_exposure0 / exposure, base_gain));
973  }
974  void auto_exposure_algorithm::anti_flicker_increase_exposure_gain(const float& target_exposure, const float& /*target_exposure0*/, float& exposure, float& gain)
975  {
976  std::vector< std::tuple<float, float, float> > exposure_gain_score;
977 
978  for (int i = 1; i < 4; ++i)
979  {
980  if (i * flicker_cycle >= maximal_exposure)
981  {
982  continue;
983  }
984  float exposure1 = std::max(std::min(i * flicker_cycle, maximal_exposure), flicker_cycle);
985  float gain1 = base_gain;
986 
987  if ((exposure1 * gain1) != target_exposure)
988  {
989  gain1 = std::min(std::max(target_exposure / exposure1, base_gain), gain_limit);
990  }
991  float score1 = fabs(target_exposure - exposure1 * gain1);
992  exposure_gain_score.push_back(std::tuple<float, float, float>(score1, exposure1, gain1));
993  }
994 
995  std::sort(exposure_gain_score.begin(), exposure_gain_score.end());
996 
997  exposure = std::get<1>(exposure_gain_score.front());
998  gain = std::get<2>(exposure_gain_score.front());
999  }
1000  void auto_exposure_algorithm::anti_flicker_decrease_exposure_gain(const float& target_exposure, const float& /*target_exposure0*/, float& exposure, float& gain)
1001  {
1002  std::vector< std::tuple<float, float, float> > exposure_gain_score;
1003 
1004  for (int i = 1; i < 4; ++i)
1005  {
1006  if (i * flicker_cycle >= maximal_exposure)
1007  {
1008  continue;
1009  }
1010  float exposure1 = std::max(std::min(i * flicker_cycle, maximal_exposure), flicker_cycle);
1011  float gain1 = base_gain;
1012  if ((exposure1 * gain1) != target_exposure)
1013  {
1014  gain1 = std::min(std::max(target_exposure / exposure1, base_gain), gain_limit);
1015  }
1016  float score1 = fabs(target_exposure - exposure1 * gain1);
1017  exposure_gain_score.push_back(std::tuple<float, float, float>(score1, exposure1, gain1));
1018  }
1019 
1020  std::sort(exposure_gain_score.begin(), exposure_gain_score.end());
1021 
1022  exposure = std::get<1>(exposure_gain_score.front());
1023  gain = std::get<2>(exposure_gain_score.front());
1024  }
1025  void auto_exposure_algorithm::hybrid_increase_exposure_gain(const float& target_exposure, const float& target_exposure0, float& exposure, float& gain)
1026  {
1027  if (anti_flicker_mode)
1028  {
1029  anti_flicker_increase_exposure_gain(target_exposure, target_exposure0, exposure, gain);
1030  }
1031  else
1032  {
1033  static_increase_exposure_gain(target_exposure, target_exposure0, exposure, gain);
1034  LOG_DEBUG("HybridAutoExposure::IncreaseExposureGain: " << exposure * gain << " " << flicker_cycle * base_gain << " " << base_gain);
1035  if (target_exposure > 0.99 * flicker_cycle * base_gain)
1036  {
1037  anti_flicker_mode = true;
1038  anti_flicker_increase_exposure_gain(target_exposure, target_exposure0, exposure, gain);
1039  LOG_DEBUG("anti_flicker_mode = true");
1040  }
1041  }
1042  }
1043  void auto_exposure_algorithm::hybrid_decrease_exposure_gain(const float& target_exposure, const float& target_exposure0, float& exposure, float& gain)
1044  {
1045  if (anti_flicker_mode)
1046  {
1047  LOG_DEBUG("HybridAutoExposure::DecreaseExposureGain: " << exposure << " " << flicker_cycle << " " << gain << " " << base_gain);
1048  if ((target_exposure) <= 0.99 * (flicker_cycle * base_gain))
1049  {
1050  anti_flicker_mode = false;
1051  static_decrease_exposure_gain(target_exposure, target_exposure0, exposure, gain);
1052  LOG_DEBUG("anti_flicker_mode = false");
1053  }
1054  else
1055  {
1056  anti_flicker_decrease_exposure_gain(target_exposure, target_exposure0, exposure, gain);
1057  }
1058  }
1059  else
1060  {
1061  static_decrease_exposure_gain(target_exposure, target_exposure0, exposure, gain);
1062  }
1063  }
1064 
1066  {
1067  const float line_period_us = 19.33333333f;
1068 
1069  float ExposureTimeLine = (exp_ms * 1000.0f / line_period_us);
1070  if (rounding_mode == rounding_mode_type::ceil) ExposureTimeLine = std::ceil(ExposureTimeLine);
1071  else if (rounding_mode == rounding_mode_type::floor) ExposureTimeLine = std::floor(ExposureTimeLine);
1072  else ExposureTimeLine = round(ExposureTimeLine);
1073  return ((float)ExposureTimeLine * line_period_us) / 1000.0f;
1074  }
1075 
1077  {
1078 
1079  if (gain < base_gain) { return base_gain; }
1080  else if (gain > 16.0f) { return 16.0f; }
1081  else {
1082  if (rounding_mode == rounding_mode_type::ceil) return std::ceil(gain * 8.0f) / 8.0f;
1083  else if (rounding_mode == rounding_mode_type::floor) return std::floor(gain * 8.0f) / 8.0f;
1084  else return round(gain * 8.0f) / 8.0f;
1085  }
1086  }
1087 
1088  template <typename T> inline T sqr(const T& x) { return (x*x); }
1089  void auto_exposure_algorithm::histogram_score(std::vector<int>& h, const int total_weight, histogram_metric& score)
1090  {
1091  score.under_exposure_count = 0;
1092  score.over_exposure_count = 0;
1093 
1094  for (size_t i = 0; i <= under_exposure_limit; ++i)
1095  {
1096  score.under_exposure_count += h[i];
1097  }
1098  score.shadow_limit = 0;
1099  //if (Score.UnderExposureCount < UnderExposureNoiseLimit)
1100  {
1101  score.shadow_limit = under_exposure_limit;
1102  for (size_t i = under_exposure_limit + 1; i <= over_exposure_limit; ++i)
1103  {
1104  if (h[i] > under_exposure_noise_limit)
1105  {
1106  break;
1107  }
1108  score.shadow_limit++;
1109  }
1110  int lower_q = 0;
1111  score.lower_q = 0;
1112  for (size_t i = under_exposure_limit + 1; i <= over_exposure_limit; ++i)
1113  {
1114  lower_q += h[i];
1115  if (lower_q > total_weight / 4)
1116  {
1117  break;
1118  }
1119  score.lower_q++;
1120  }
1121  }
1122 
1123  for (size_t i = over_exposure_limit; i <= 255; ++i)
1124  {
1125  score.over_exposure_count += h[i];
1126  }
1127 
1128  score.highlight_limit = 255;
1129  //if (Score.OverExposureCount < OverExposureNoiseLimit)
1130  {
1131  score.highlight_limit = over_exposure_limit;
1132  for (size_t i = over_exposure_limit; i >= under_exposure_limit; --i)
1133  {
1134  if (h[i] > over_exposure_noise_limit)
1135  {
1136  break;
1137  }
1138  score.highlight_limit--;
1139  }
1140  int upper_q = 0;
1141  score.upper_q = over_exposure_limit;
1142  for (size_t i = over_exposure_limit; i >= under_exposure_limit; --i)
1143  {
1144  upper_q += h[i];
1145  if (upper_q > total_weight / 4)
1146  {
1147  break;
1148  }
1149  score.upper_q--;
1150  }
1151 
1152  }
1153  int32_t m1 = 0;
1154  int64_t m2 = 0;
1155 
1156  double nn = (double)total_weight - score.under_exposure_count - score.over_exposure_count;
1157  if (nn == 0)
1158  {
1159  nn = (double)total_weight;
1160  for (int i = 0; i <= 255; ++i)
1161  {
1162  m1 += h[i] * i;
1163  m2 += h[i] * sqr(i);
1164  }
1165  }
1166  else
1167  {
1168  for (int i = under_exposure_limit + 1; i < over_exposure_limit; ++i)
1169  {
1170  m1 += h[i] * i;
1171  m2 += h[i] * sqr(i);
1172  }
1173  }
1174  score.main_mean = (float)((double)m1 / nn);
1175  double Var = (double)m2 / nn - sqr((double)m1 / nn);
1176  if (Var > 0)
1177  {
1178  score.main_std = (float)sqrt(Var);
1179  }
1180  else
1181  {
1182  score.main_std = 0.0f;
1183  }
1184  }
1185 }
void set_fw_logger_option(double value)
Definition: zr300.cpp:154
void toggle_motion_module_power(bool bOn)
Definition: zr300.cpp:199
void decrease_exposure_target(float mult, float &target_exposure)
Definition: zr300.cpp:937
std::shared_ptr< rs_device > make_zr300_device(std::shared_ptr< uvc::device > device)
Definition: zr300.cpp:425
uint16_t get_fisheye_exposure(const uvc::device &device)
Definition: ds-private.cpp:444
rsimpl::device_config config
Definition: device.h:79
mm_extrinsic fe_to_imu
Definition: zr300.h:83
void anti_flicker_decrease_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:1000
virtual bool supports(rs_capabilities capability) const override
Definition: device.cpp:606
const std::shared_ptr< rsimpl::uvc::device > device
Definition: device.h:77
std::deque< rs_frame_ref * > data_queue
Definition: zr300.h:279
std::vector< rs_frame_metadata > supported_metadata_vector
Definition: types.h:283
void get_pu_control_range(const device &device, int subdevice, rs_option option, int *min, int *max, int *step, int *def)
virtual void stop_motion_tracking()
Definition: device.cpp:187
void modify_exposure(float &exposure_value, bool &exp_modified, float &gain_value, bool &gain_modified)
Definition: zr300.cpp:820
const rsimpl::uvc::device & get_device() const
Definition: device.h:102
float exposure_to_value(float exp_ms, rounding_mode_type rounding_mode)
Definition: zr300.cpp:1065
IMU_version ver
Definition: zr300.h:107
int get_data_size() const
Definition: zr300.h:41
virtual int get_frame_bpp() const =0
std::mutex exp_and_cnt_queue_mtx
Definition: zr300.h:284
void set_fisheye_external_trigger(uvc::device &device, uint8_t ext_trig)
Definition: ds-private.cpp:429
GLint GLint GLsizei GLsizei height
Definition: glext.h:112
void increase_exposure_target(float mult, float &target_exposure)
Definition: zr300.cpp:932
const GLfloat * m
Definition: glext.h:6461
rs_blob_type
Proprietary formats for direct communication with device firmware.
Definition: rs.h:228
void increase_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:942
auto_exposure_algorithm(fisheye_auto_exposure_state auto_exposure_state)
Definition: zr300.cpp:815
void stop_motion_tracking() override
Definition: zr300.cpp:242
IMU_version ver
Definition: zr300.h:36
bool has_data() const
Definition: zr300.h:75
std::mutex mtx
#define LOG_WARNING(...)
Definition: types.h:79
auto_exposure_mechanism(zr300_camera *dev, fisheye_auto_exposure_state auto_exposure_state)
Definition: zr300.cpp:624
bool is_device_connected(device &device, int vid, int pid)
bool analyze_image(const rs_frame_ref *image)
Definition: zr300.cpp:867
virtual const uint8_t * get_frame_data() const =0
unsigned long long get_frame_counter_by_usb_cmd()
Definition: zr300.cpp:336
void get_options(const rs_option options[], size_t count, double values[]) override
Definition: zr300.cpp:83
GLenum GLenum GLsizei void * image
Definition: glext.h:2716
const uint16_t VID_INTEL_CAMERA
Definition: uvc.h:14
GLsizei const GLchar *const * string
Definition: glext.h:683
void anti_flicker_increase_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:974
float gain_to_value(float gain, rounding_mode_type rounding_mode)
Definition: zr300.cpp:1076
virtual void stop_fw_logger() override
Definition: ds-device.cpp:309
Definition: archive.h:12
bool validate_motion_intrinsics() const
Definition: zr300.cpp:379
bool motion_module_ready
Definition: device.h:113
bool try_get_exp_by_frame_cnt(double &exposure, const unsigned long long frame_counter)
Definition: zr300.cpp:754
uint8_t receivedCommandData[HW_MONITOR_BUFFER_SIZE]
Definition: hw-monitor.h:75
rs_option
Defines general configuration controls.
Definition: rs.h:128
uint8_t get_fisheye_external_trigger(const uvc::device &device)
Definition: ds-private.cpp:424
GLuint GLuint stream
Definition: glext.h:1774
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:1944
std::condition_variable cv
Definition: zr300.h:277
void set_options(const rs_option options[], size_t count, const double values[]) override
Definition: zr300.cpp:45
std::vector< subdevice_mode > subdevice_modes
Definition: types.h:273
void claim_motion_module_interface(uvc::device &device)
Definition: ds-private.cpp:454
stream_request presets[RS_STREAM_NATIVE_COUNT][RS_PRESET_COUNT]
Definition: types.h:275
bool is_fisheye_uvc_control(rs_option option)
Definition: zr300.cpp:33
void perform_and_send_monitor_command(uvc::device &device, std::timed_mutex &mutex, hwmon_cmd &newCommand)
Definition: hw-monitor.cpp:95
mm_extrinsic rgb_to_imu
Definition: zr300.h:85
void set_fisheye_exposure(uvc::device &device, uint16_t exposure)
Definition: ds-private.cpp:449
std::shared_ptr< std::thread > exposure_thread
Definition: zr300.h:276
void update_options(const fisheye_auto_exposure_state &options)
Definition: zr300.cpp:915
void histogram_score(std::vector< int > &h, const int total_weight, histogram_metric &score)
Definition: zr300.cpp:1089
virtual double get_frame_metadata(rs_frame_metadata frame_metadata) const =0
const uint8_t RS_STREAM_NATIVE_COUNT
Definition: types.h:27
void set_auto_exposure_state(rs_option option, double value)
Definition: zr300.cpp:173
std::vector< supported_capability > capabilities_vector
Definition: types.h:282
GLuint GLenum option
Definition: glext.h:5581
virtual void send_blob_to_device(rs_blob_type, void *, int)
Definition: device.h:174
int stream_subdevices[RS_STREAM_NATIVE_COUNT]
Definition: types.h:271
calibration read_calibration(uvc::device &device, std::timed_mutex &mutex)
Definition: zr300.cpp:405
void update_auto_exposure_state(fisheye_auto_exposure_state &auto_exposure_state)
Definition: zr300.cpp:711
#define LOG_DEBUG(...)
Definition: types.h:77
IMU_intrinsic imu_intrinsic
Definition: zr300.h:166
void push_back_data(rs_frame_ref *data)
Definition: zr300.cpp:785
serial_number read_serial_number(uvc::device &device, std::timed_mutex &mutex)
Definition: zr300.cpp:395
GLuint GLuint GLsizei count
Definition: glext.h:111
std::shared_ptr< rsimpl::frame_archive > sync_archive
Definition: zr300.h:275
std::atomic< unsigned > frames_counter
Definition: zr300.h:281
stream_request requests[RS_STREAM_NATIVE_COUNT]
Definition: types.h:451
GLfloat f
Definition: glext.h:1868
Motion module intrinsics: includes accelerometer and gyroscope intrinsics structs of type rs_motion_d...
Definition: rs.h:325
uint8_t get_fisheye_strobe(const uvc::device &device)
Definition: ds-private.cpp:434
rs_stream select_key_stream(const std::vector< rsimpl::subdevice_mode_selection > &selected_modes) override
Definition: zr300.cpp:249
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
std::deque< exposure_and_frame_counter > exposure_and_frame_counter_queue
Definition: zr300.h:283
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * data
Definition: glext.h:223
virtual unsigned long long get_frame_number() const =0
std::atomic< bool > keep_fw_logger_alive
Definition: device.h:114
virtual int get_frame_width() const =0
unsigned get_fw_logger_option()
Definition: zr300.cpp:168
std::map< rs_camera_info, std::string > camera_info
Definition: types.h:284
auto_exposure_algorithm auto_exposure_algo
Definition: zr300.h:274
void on_before_callback(rs_stream, rs_frame_ref *, std::shared_ptr< rsimpl::frame_archive >) override
Definition: zr300.cpp:146
bool validate_motion_extrinsics(rs_stream) const
Definition: zr300.cpp:345
void toggle_motion_module_events(bool bOn)
Definition: zr300.cpp:204
const std::size_t max_size_of_exp_and_cnt_queue
Definition: zr300.h:272
std::vector< supported_option > options
Definition: types.h:276
unsigned get_auto_exposure_state(rs_option option) const
Definition: zr300.cpp:574
IMU_extrinsic mm_extrinsic
Definition: zr300.h:165
std::shared_ptr< rsimpl::syncronizing_archive > archive
Definition: device.h:94
GLsizei const GLfloat * value
Definition: glext.h:693
void send_blob_to_device(rs_blob_type type, void *data, int size) override
Definition: zr300.cpp:130
ds_info read_camera_info(uvc::device &device)
Definition: ds-private.cpp:332
void stop(rs_source source) override
Definition: zr300.cpp:223
void hybrid_increase_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:1025
GLenum mode
Definition: glext.h:1117
const uint16_t HW_MONITOR_BUFFER_SIZE
Definition: hw-monitor.h:41
rs_source
Source: allows you to choose between available hardware subdevices.
Definition: rs.h:90
Video stream intrinsics.
Definition: rs.h:300
#define LOG_INFO(...)
Definition: types.h:78
int get_pu_control(const device &device, int subdevice, rs_option option)
motion_module::motion_module_control motion_module_ctrl
Definition: zr300.h:289
Cross-stream extrinsics: encode the topology describing how the different devices are connected...
Definition: rs.h:332
const native_pixel_format pf_rw16
Definition: image.cpp:460
void get_firmware_version_string(uvc::device &device, std::timed_mutex &mutex, std::string &version, int gvd_cmd, int offset)
#define FISHEYE_PRODUCT_ID
Definition: ds-device.h:14
T sqr(const T &x)
Definition: zr300.cpp:1088
void set_pu_control_with_retry(device &device, int subdevice, rs_option option, int value)
Definition: uvc.h:71
GLenum GLsizei GLsizei GLint * values
Definition: glext.h:1484
bool is_fisheye_xu_control(rs_option option)
Definition: zr300.cpp:38
bool has_data() const
Definition: zr300.h:46
pose inverse(const pose &a)
Definition: types.h:123
GLdouble s
Definition: glext.h:231
void static_decrease_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:969
void start_motion_tracking() override
Definition: zr300.cpp:234
rs_stream
Streams are different types of data provided by RealSense devices.
Definition: rs.h:33
void get_option_range(rs_option option, double &min, double &max, double &step, double &def) override
Definition: zr300.cpp:318
void push_back_exp_and_cnt(exposure_and_frame_counter exp_and_cnt)
Definition: zr300.cpp:744
GLint GLint GLsizei width
Definition: glext.h:112
void set_auto_exposure_state(rs_option option, double value)
Definition: zr300.cpp:599
std::atomic< bool > keep_alive
Definition: zr300.h:278
zr300_camera(std::shared_ptr< uvc::device > device, const static_device_info &info, motion_module_calibration fe_intrinsic, calibration_validator validator)
Definition: zr300.cpp:20
GLsizei GLsizei GLchar * source
Definition: glext.h:672
static firmware_version any()
Definition: types.h:216
rs_device * dev
GLsizeiptr size
Definition: glext.h:532
bool has_data() const
Definition: zr300.h:122
std::atomic< unsigned > skip_frames
Definition: zr300.h:282
std::shared_ptr< auto_exposure_mechanism > auto_exposure
Definition: zr300.h:292
bool try_pop_front_data(rs_frame_ref **data)
Definition: zr300.cpp:790
auto_exposure_modes
Definition: zr300.h:177
IMU_version ver
Definition: zr300.h:82
GLuint res
Definition: glext.h:8310
void get_raw_data(uint8_t opcode, uvc::device &device, std::timed_mutex &mutex, uint8_t *data, size_t &bytesReturned)
Definition: hw-monitor.cpp:262
void im_hist(const uint8_t *data, const int width, const int height, const int rowStep, int h[])
Definition: zr300.cpp:923
fisheye_intrinsic fe_intrinsic
Definition: zr300.h:164
rs_motion_intrinsics get_motion_intrinsics() const override
Definition: zr300.cpp:272
std::atomic< bool > to_add_frames
Definition: zr300.h:293
void add_frame(rs_frame_ref *frame, std::shared_ptr< rsimpl::frame_archive > archive)
Definition: zr300.cpp:718
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: glext.h:8966
void static_increase_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:964
motion_module_calibration fe_intrinsic
Definition: zr300.h:334
virtual void start_motion_tracking()
Definition: device.cpp:140
int get_data_size() const
Definition: zr300.h:116
void decrease_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:953
rs_extrinsics get_motion_extrinsics_from(rs_stream from) const override
Definition: zr300.cpp:299
void set_fisheye_strobe(uvc::device &device, uint8_t strobe)
Definition: ds-private.cpp:439
int get_data_size() const
Definition: zr300.h:89
unsigned get_auto_exposure_state(rs_option option)
Definition: zr300.cpp:141
fisheye_auto_exposure_state auto_exposure_state
Definition: zr300.h:291
bool supports_option(rs_option option) const override
Definition: zr300.cpp:281
motion_module_calibration read_fisheye_intrinsic(uvc::device &device, std::timed_mutex &mutex)
Definition: zr300.cpp:415
GLint GLint GLint GLint GLint x
Definition: glext.h:114
virtual int get_frame_height() const =0
void start(rs_source source) override
Definition: zr300.cpp:211
const native_pixel_format pf_raw8
Definition: image.cpp:459
GLuint start
Definition: glext.h:111
#define LOG_ERROR(...)
Definition: types.h:80
void hybrid_decrease_exposure_gain(const float &target_exposure, const float &target_exposure0, float &exposure, float &gain)
Definition: zr300.cpp:1043
GLuint GLuint GLsizei GLenum type
Definition: glext.h:111
virtual void start_fw_logger(char fw_log_op_code, int grab_rate_in_ms, std::timed_mutex &mutex) override
Definition: ds-device.cpp:304
virtual bool supports_frame_metadata(rs_frame_metadata frame_metadata) const =0
rs_frame_ref * clone_frame(rs_frame_ref *frame) override
Definition: device.cpp:518
mm_extrinsic depth_to_imu
Definition: zr300.h:86
std::timed_mutex usbMutex
Definition: zr300.h:300


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Fri Mar 13 2020 03:16:18