18 #define MAX_DS_DEFAULT_X 639 19 #define MAX_DS_DEFAULT_Y 439 24 :
rs_device_base(device, info, validator), start_stop_pad(
std::chrono::milliseconds(500))
59 std::vector<supported_option> so_vec;
61 for (
auto& opt : ae_vector)
63 double min, max, step, def;
65 so_vec.push_back({ opt, min, max, step, def });
79 auto intrinsics =
stream.get_intrinsics();
80 max_x = intrinsics.width - 1;
81 max_y = intrinsics.height - 1;
112 std::vector<rs_option> base_opt;
113 std::vector<double> base_opt_val;
118 auto ae_writer = make_struct_interface<ds::ae_params>(
131 for (
size_t i = 0; i<
count; ++i)
185 base_opt.push_back(options[i]); base_opt_val.push_back(values[i]);
break;
189 minmax_writer.commit();
190 disp_writer.commit();
202 std::vector<rs_option> base_opt;
203 std::vector<size_t> base_opt_index;
204 std::vector<double> base_opt_val;
209 auto ae_reader = make_struct_interface<ds::ae_params>(
222 for (
size_t i = 0; i<
count; ++i)
278 base_opt.push_back(options[i]); base_opt_index.push_back(i);
break;
283 base_opt_val.resize(base_opt.size());
288 for (
auto i : base_opt_index)
289 values[i] = base_opt_val[i];
319 uint8_t streamIntent = 0;
320 for(
const auto &
m : selected_modes)
322 switch(
m.mode.subdevice)
331 default:
throw std::logic_error(
"unsupported R200 depth format");
333 dm.is_disparity_enabled = 0;
338 dm.is_disparity_enabled = 1;
363 for(
const auto &
m : selected_modes)
365 for(
const auto & output :
m.get_outputs())
367 fps[output.first] =
m.mode.fps;
368 max_fps = std::max(max_fps,
m.mode.fps);
375 if(fps[
s] == max_fps)
return s;
385 if(
stream.is_enabled())
return static_cast<uint32_t>(
stream.get_framerate());
405 for(
auto fps : {30, 60, 90})
410 info.
subdevice_modes.push_back({0, {640, 481}, pf, fps,
c.modesLR[0], {}, {0, -6}});
411 info.
subdevice_modes.push_back({0, {640, 373}, pf, fps,
c.modesLR[1], {}, {0, -6}});
412 info.
subdevice_modes.push_back({0, {640, 254}, pf, fps,
c.modesLR[2], {}, {0, -6}});
422 info.
subdevice_modes.push_back({ 2, { 640, 480 },
pf_yuy2, 60,
c.intrinsicsThird[1], {
c.modesThird[1][0] }, { 0 } });
423 info.
subdevice_modes.push_back({ 2, { 640, 480 },
pf_yuy2, 30,
c.intrinsicsThird[1], {
c.modesThird[1][0] }, { 0 } });
427 info.
subdevice_modes.push_back({ 2,{ 1920, 1080 },
pf_yuy2, 15,
c.intrinsicsThird[0],{
c.modesThird[0][0] },{ 0 } });
428 info.
subdevice_modes.push_back({ 2,{ 1920, 1080 },
pf_yuy2, 30,
c.intrinsicsThird[0],{
c.modesThird[0][0] },{ 0 } });
437 info.
subdevice_modes.push_back({ 2, { 640, 480 },
pf_yuy2, 15,
c.intrinsicsThird[1], {
c.modesThird[1][0] }, { 0 } });
438 info.
subdevice_modes.push_back({ 2, { 640, 480 },
pf_rw16, 15,
c.intrinsicsThird[1], {
c.modesThird[1][0] }, { 0 } });
476 info.
options.push_back({ RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED, 0, 1, 1, 0 });
502 info.
stream_poses[
RS_STREAM_DEPTH] = {{{1,0,0},{0,1,0},{0,0,1}},{0,0,0}};
503 info.
stream_poses[
RS_STREAM_INFRARED] = {{{1,0,0},{0,1,0},{0,0,1}},{0,0,0}};
506 info.
stream_poses[
RS_STREAM_INFRARED2] = {{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {
c.B * 0.001f, 0, 0}};
509 for(
int i=0; i<3; ++i)
for(
int j=0; j<3; ++j)
511 for(
int i=0; i<3; ++i)
517 info.
serial = std::to_string(
c.serial_number);
540 if (std::isnormal(
h.calibration_date))
542 if (std::isnormal(
h.first_program_date))
544 if (std::isnormal(
h.focus_alignment_date))
546 if (std::isnormal(
h.build_date))
557 std::vector<rs_option> auto_exposure_options = {
569 if (std::find(auto_exposure_options.begin(), auto_exposure_options.end(),
option) != auto_exposure_options.end())
574 std::vector<rs_option> only_when_not_streaming = {
582 if (std::find(only_when_not_streaming.begin(), only_when_not_streaming.end(),
option) != only_when_not_streaming.end())
601 def = disc.default_value;
613 def = disc.default_value;
626 std::vector<rs_option> auto_exposure_options = {
632 if (std::find(auto_exposure_options.begin(), auto_exposure_options.end(),
option) != auto_exposure_options.end())
638 if (
stream.is_enabled()) max_x =
stream.get_intrinsics().width - 1;
639 min = 1; max = max_x; step = 1; def = max_x;
645 if (
stream.is_enabled()) max_x =
stream.get_intrinsics().width - 1;
646 min = 1; max = max_x - 1; step = 1; def = 0;
652 if (
stream.is_enabled()) max_y =
stream.get_intrinsics().height - 1;
653 min = 1; max = max_y; step = 1; def = max_y;
659 if (
stream.is_enabled()) max_y =
stream.get_intrinsics().height - 1;
660 min = 0; max = max_y - 1; step = 1; def = 0;
683 dinghy_timestamp_reader(
int fps) : fps(fps), last_timestamp(0), timestamp_wraparound(1,
std::numeric_limits<uint32_t>::max()), frame_counter_wraparound(1,
std::numeric_limits<uint32_t>::max()) {}
689 const uint32_t magic_numbers[] = {0x08070605, 0x04030201, 0x8A8B8C8D};
721 auto new_ts = timestamp_wraparound.
fix(last_timestamp + 1000. / fps);
722 last_timestamp = new_ts;
728 auto frame_number = 0;
731 return frame_counter_wraparound.
fix(frame_number);
739 int embedded_frame_counter = 0;
743 auto data =
static_cast<const char*
>(frame);
745 for (
int i = 0, j = 0; i < 4; ++i, ++j)
746 embedded_frame_counter |= ((
data[i] & 0x01) << j);
750 embedded_frame_counter =
reinterpret_cast<byte_wrapping&
>(*((
unsigned char*)frame)).lsb;
753 return embedded_frame_counter;
766 fisheye_timestamp_reader(
int in_configured_fps,
const char* fw_ver) : configured_fps(in_configured_fps), last_fisheye_timestamp(0), last_fisheye_counter(0), timestamp_wraparound(1,
std::numeric_limits<uint32_t>::max()), frame_counter_wraparound(0,
std::numeric_limits<uint32_t>::max()), validate(true), fw_version(fw_ver){}
774 auto pixel_lsb = get_embedded_frame_counter(frame);
775 if ((sts = (pixel_lsb != 0)))
782 unsigned char lsb : 4;
783 unsigned char msb : 4;
788 std::lock_guard<std::mutex> guard(mutex);
790 auto last_counter_lsb =
reinterpret_cast<byte_wrapping&
>(last_fisheye_counter).lsb;
791 auto pixel_lsb = get_embedded_frame_counter(frame);
792 if (last_counter_lsb == pixel_lsb)
793 return last_fisheye_counter;
795 auto last_counter_msb = (last_fisheye_counter >> 4);
796 auto wrap_around =
reinterpret_cast<byte_wrapping&
>(last_fisheye_counter).lsb;
797 if (wrap_around == 15 || pixel_lsb < last_counter_lsb)
802 auto fixed_counter = (last_counter_msb << 4) | (pixel_lsb & 0xff);
804 last_fisheye_counter = fixed_counter;
805 return frame_counter_wraparound.
fix(fixed_counter);
810 auto new_ts = timestamp_wraparound.
fix(last_fisheye_timestamp + 1000. / actual_fps);
811 last_fisheye_timestamp = new_ts;
821 bool first_frames =
true;
824 color_timestamp_reader(
int fps,
int scale) : fps(fps), scale(scale), last_timestamp(0), timestamp_wraparound(0,
std::numeric_limits<uint32_t>::max()), frame_counter_wraparound(0,
std::numeric_limits<uint32_t>::max()) {}
828 auto counter = get_frame_counter(mode, frame);
830 if (
counter == 0 && first_frames)
return false;
831 first_frames =
false;
837 auto frame_number = 0;
841 for (
auto i = 0; i < 32; ++i)
843 frame_number |= ((*
data & 1) << (i & 1 ? 32 - i : 30 - i));
847 frame_number /=
scale;
849 return frame_counter_wraparound.
fix(frame_number);
854 auto new_ts = timestamp_wraparound.
fix(last_timestamp + 1000. / fps);
855 last_timestamp = new_ts;
869 serial_timestamp_generator(
int fps) : fps(fps), serial_frame_number(), last_timestamp(0), timestamp_wraparound(0,
std::numeric_limits<uint32_t>::max()), frame_counter_wraparound(0,
std::numeric_limits<uint32_t>::max())
872 ts_step = 1000. / fps;
878 auto new_ts = timestamp_wraparound.
fix(last_timestamp + ts_step);
879 last_timestamp = new_ts;
884 return frame_counter_wraparound.
fix(++serial_frame_number);
900 if (stream_depth.is_enabled())
901 return std::make_shared<dinghy_timestamp_reader>(stream_depth.get_framerate());
904 if (stream_infrared.is_enabled())
905 return std::make_shared<dinghy_timestamp_reader>(stream_infrared.get_framerate());
907 if (stream_infrared2.is_enabled())
908 return std::make_shared<dinghy_timestamp_reader>(stream_infrared2.get_framerate());
911 if (stream_fisheye.is_enabled())
915 if (stream_color.is_enabled())
920 bool depth_streams_active = stream_depth.is_enabled() | stream_infrared.is_enabled() | stream_infrared2.is_enabled();
924 auto master_fps = stream_depth.is_enabled() ? stream_depth.get_framerate() : 0;
925 master_fps = stream_infrared.is_enabled() ? stream_infrared.get_framerate() : master_fps;
926 master_fps = stream_infrared2.is_enabled() ? stream_infrared2.get_framerate() : master_fps;
927 auto scale = master_fps / stream_color.get_framerate();
929 return std::make_shared<color_timestamp_reader>(stream_color.get_framerate(),
scale);
933 return std::make_shared<serial_timestamp_generator>(stream_color.get_framerate());
uint32_t score_max_thresh
uint32_t texture_count_thresh
int num_libuvc_transfer_buffers
rsimpl::device_config config
uint32_t texture_diff_thresh
static void update_device_info(rsimpl::static_device_info &info)
virtual void get_option_range(rs_option option, double &min, double &max, double &step, double &def) override
color_timestamp_reader(int fps, int scale)
const std::shared_ptr< rsimpl::uvc::device > device
double get_frame_timestamp(const subdevice_mode &mode, const void *frame, double) override
virtual rs_extrinsics get_extrinsics_to(const rs_stream_interface &other) const override
const ds::dinghy & get_dinghy(const subdevice_mode &mode, const void *frame)
virtual void get_options(const rs_option options[], size_t count, double values[]) override
const rsimpl::uvc::device & get_device() const
uint32_t robbins_munroe_plus_inc
bool validate_frame(const subdevice_mode &mode, const void *frame) override
void set_disparity_mode(uvc::device &device, disp_mode mode)
wraparound_mechanism< unsigned long long > frame_counter_wraparound
pose stream_poses[RS_STREAM_NATIVE_COUNT]
uint32_t get_lr_framerate() const
GLenum GLenum GLenum GLenum GLenum scale
virtual void stop(rs_source source) override
unsigned last_fisheye_counter
const native_pixel_format pf_y8i
bool validate_frame(const subdevice_mode &mode, const void *frame) override
const native_pixel_format pf_y12i
uint32_t get_depth_units(const uvc::device &device)
bool get_emitter_state(const uvc::device &device, bool is_streaming, bool is_depth_enabled)
GLsizei const GLchar *const * string
int get_embedded_frame_counter(const void *frame) const
const int STATUS_BIT_WEB_STREAMING
virtual void stop_fw_logger() override
GLint GLint GLsizei GLsizei GLsizei depth
double disparity_multiplier
rs_intrinsics pad_crop_intrinsics(const rs_intrinsics &i, int pad_crop)
const int STATUS_BIT_Z_STREAMING
virtual void stop(rs_source source) override
rs_option
Defines general configuration controls.
static void set_common_ds_config(std::shared_ptr< uvc::device > device, static_device_info &info, const ds::ds_info &cam_info)
disp_mode get_disparity_mode(const uvc::device &device)
unsigned long long get_frame_counter(const subdevice_mode &, const void *) override
GLfloat GLfloat GLfloat GLfloat h
void set_lr_exposure_discovery(uvc::device &device, discovery disc)
uint32_t get_disparity_shift(const uvc::device &device)
rate_value get_lr_gain(const uvc::device &device)
virtual void start(rs_source source) override
const native_pixel_format pf_y16
wraparound_mechanism< double > timestamp_wraparound
std::vector< subdevice_mode > subdevice_modes
void correct_lr_auto_exposure_params(rs_device_base *device, ae_params ¶ms)
uint8_t get_lr_exposure_mode(const uvc::device &device)
stream_request presets[RS_STREAM_NATIVE_COUNT][RS_PRESET_COUNT]
wraparound_mechanism< unsigned long long > frame_counter_wraparound
void set_lr_auto_exposure_params(uvc::device &device, ae_params params)
uint16_t exposure_bottom_edge
ae_params get_lr_auto_exposure_params(const uvc::device &device, std::vector< supported_option > ae_vec)
ds_calibration calibration
uint16_t exposure_left_edge
const uint8_t RS_STREAM_NATIVE_COUNT
std::vector< supported_capability > capabilities_vector
ds_head_content head_content
float nominal_depth_scale
int stream_subdevices[RS_STREAM_NATIVE_COUNT]
double last_fisheye_timestamp
std::string firmware_version
const native_pixel_format pf_y8
void set_emitter_state(uvc::device &device, bool state)
wraparound_mechanism< double > timestamp_wraparound
GLuint GLuint GLsizei count
bool validate_frame(const subdevice_mode &, const void *frame) override
void on_update_disparity_multiplier(double multiplier)
const int STATUS_BIT_LR_STREAMING
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
uint32_t robbins_munroe_minus_inc
wraparound_mechanism< unsigned long long > frame_counter_wraparound
uint32_t score_min_thresh
void set_options(const rs_option options[], size_t count, const double values[]) override
void set_stream_intent(uvc::device &device, uint8_t &intent)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * data
const char * get_camera_info(rs_camera_info info) const override
discovery get_lr_gain_discovery(const uvc::device &device)
std::map< rs_camera_info, std::string > camera_info
bool supports_option(rs_option option) const override
uint32_t second_peak_thresh
void set_depth_units(uvc::device &device, uint32_t units)
void get_options(const rs_option options[], size_t count, double values[]) override
std::shared_ptr< frame_timestamp_reader > create_frame_timestamp_reader(int subdevice) const
std::vector< supported_option > options
virtual void disable_auto_option(int subdevice, rs_option auto_opt)
unsigned long long get_frame_counter(const subdevice_mode &mode, const void *frame) override
unsigned long long get_frame_counter(const subdevice_mode &, const void *frame) override
uint16_t exposure_right_edge
dinghy_timestamp_reader(int fps)
float mean_intensity_set_point
wraparound_mechanism< double > timestamp_wraparound
uint16_t exposure_top_edge
discovery get_lr_exposure_discovery(const uvc::device &device)
rate_value get_lr_exposure(const uvc::device &device)
rs_source
Source: allows you to choose between available hardware subdevices.
virtual bool supports_option(rs_option option) const override
const native_pixel_format pf_z16
ds_device(std::shared_ptr< uvc::device > device, const static_device_info &info, calibration_validator validator)
wraparound_mechanism< unsigned long long > frame_counter_wraparound
int get_pu_control(const device &device, int subdevice, rs_option option)
const native_pixel_format pf_rw16
void set_lr_gain_discovery(uvc::device &device, discovery disc)
std::vector< std::shared_ptr< frame_timestamp_reader > > create_frame_timestamp_readers() const override
void set_lr_gain(uvc::device &device, rate_value gain)
void set_depth_params(uvc::device &device, dc_params params)
void set_disparity_shift(uvc::device &device, uint32_t shift)
bool validate_frame(const subdevice_mode &, const void *) override
void set_pu_control_with_retry(device &device, int subdevice, rs_option option, int value)
GLenum GLsizei GLsizei GLint * values
fisheye_timestamp_reader(int in_configured_fps, const char *fw_ver)
rs_stream select_key_stream(const std::vector< rsimpl::subdevice_mode_selection > &selected_modes) override
rs_stream
Streams are different types of data provided by RealSense devices.
GLsizei GLsizei GLchar * source
double get_frame_timestamp(const subdevice_mode &mode, const void *frame, double actual_fps) override
serial_timestamp_generator(int fps)
std::vector< interstream_rule > interstream_rules
void set_lr_exposure(uvc::device &device, rate_value exposure)
std::vector< supported_option > get_ae_range_vec()
unsigned long long get_frame_counter(const subdevice_mode &mode, const void *frame) override
const native_pixel_format pf_yuy2
bool is_pu_control(rs_option option)
virtual void start(rs_source source) override
void get_option_range(rs_option option, double &min, double &max, double &step, double &def) override
std::string read_isp_firmware_version(uvc::device &device)
rs_intrinsics scale_intrinsics(const rs_intrinsics &i, int width, int height)
virtual void set_options(const rs_option options[], size_t count, const double values[]) override
wraparound_mechanism< double > timestamp_wraparound
virtual void stop_fw_logger() override
void on_update_depth_units(uint32_t units)
virtual void start_fw_logger(char fw_log_op_code, int grab_rate_in_ms, std::timed_mutex &mutex) override
GLdouble GLdouble GLdouble GLdouble top
std::string read_firmware_version(uvc::device &device)
bool is_disparity_mode_enabled() const
void on_before_start(const std::vector< subdevice_mode_selection > &selected_modes) override
dc_params get_depth_params(const uvc::device &device)
range get_min_max_depth(const uvc::device &device)
double get_frame_timestamp(const subdevice_mode &mode, const void *frame, double) override
void set_min_max_depth(uvc::device &device, range min_max)
std::string time_to_string(double val)
const rsimpl::stream_interface & get_stream_interface(rs_stream stream) const override
virtual void start_fw_logger(char fw_log_op_code, int grab_rate_in_ms, std::timed_mutex &mutex) override
void set_lr_exposure_mode(uvc::device &device, uint8_t mode)
bool is_capturing() const override
double get_frame_timestamp(const subdevice_mode &, const void *, double) override
float bright_ratio_set_point