diff --git a/src/ds/ds-options.cpp b/src/ds/ds-options.cpp index 73fa4467ef..26f0b1b7ef 100644 --- a/src/ds/ds-options.cpp +++ b/src/ds/ds-options.cpp @@ -690,7 +690,22 @@ namespace librealsense void hdr_conditional_option::set(float value) { if (_hdr_cfg->is_config_in_process()) - _hdr_option->set(value); + { + if( _hdr_cfg->is_enabled() ) + { + // Changing exposure while HDR is enabled was requested by customers.It is currently disabled by D400 + // FW, so we workaround it by disabling HDR,changing exposure and enabling again.Disabling/Enabling + // resets the sequence index so we need to keep and restore it. + auto _current_hdr_sequence_index = _hdr_cfg->get( RS2_OPTION_SEQUENCE_ID ); + _hdr_cfg->set( RS2_OPTION_HDR_ENABLED, 0, { 0, 1, 1, 0 } ); + _hdr_cfg->set( RS2_OPTION_SEQUENCE_ID, _current_hdr_sequence_index, { 0, 2, 1, 0 } ); + _hdr_option->set( value ); + _hdr_cfg->set( RS2_OPTION_HDR_ENABLED, 1, { 0, 1, 1, 0 } ); + _hdr_cfg->set( RS2_OPTION_SEQUENCE_ID, _current_hdr_sequence_index, { 0, 2, 1, 0 } ); + } + else + _hdr_option->set( value ); + } else { if (_hdr_cfg->is_enabled()) diff --git a/unit-tests/live/d400/test-hdr-long.py b/unit-tests/live/d400/test-hdr-long.py index f90582b332..fa8a9424f3 100644 --- a/unit-tests/live/d400/test-hdr-long.py +++ b/unit-tests/live/d400/test-hdr-long.py @@ -502,5 +502,48 @@ def check_sequence_id(pipe): pipe.stop() depth_sensor.set_option(rs.option.hdr_enabled, 0) # disable hdr before next tests +with test.closure("HDR Streaming - enable runtime exposure update in HDR mode"): + device = test.find_first_device_or_exit() + depth_sensor = device.first_depth_sensor() + + if test.check(depth_sensor and depth_sensor.supports(rs.option.hdr_enabled)): + exposure_range = depth_sensor.get_option_range(rs.option.exposure) + gain_range = depth_sensor.get_option_range(rs.option.gain) + + depth_sensor.set_option(rs.option.hdr_enabled, 1) + test.check(depth_sensor.get_option(rs.option.hdr_enabled) == 1) + + cfg = rs.config() + cfg.enable_stream(rs.stream.depth) + cfg.enable_stream(rs.stream.infrared, 1) + pipe = rs.pipeline() + pipe.start(cfg) + + #change exposure and gain for seq id 1 + depth_sensor.set_option(rs.option.sequence_id, 1) # seq id 1 is expected to be the default value + test.check(depth_sensor.get_option(rs.option.sequence_id) == 1) + exp = depth_sensor.get_option(rs.option.exposure) + test.check(depth_sensor.get_option(rs.option.exposure) == exposure_range.default - 1000) # w/a + depth_sensor.set_option(rs.option.exposure, exposure_range.default - 2000) + test.check(depth_sensor.get_option(rs.option.exposure) == exposure_range.default - 2000) + + test.check(depth_sensor.get_option(rs.option.gain) == gain_range.default) + depth_sensor.set_option(rs.option.gain, gain_range.default + 2) + test.check(depth_sensor.get_option(rs.option.gain) == gain_range.default + 2) + + # change exposure and gain for seq id 2 + depth_sensor.set_option(rs.option.sequence_id, 2)# seq id 2 is expected to be the min value + test.check(depth_sensor.get_option(rs.option.sequence_id) == 2) + exp = depth_sensor.get_option(rs.option.exposure) + test.check(depth_sensor.get_option(rs.option.exposure) == exposure_range.min) # w/a + depth_sensor.set_option(rs.option.exposure, exposure_range.default) + test.check(depth_sensor.get_option(rs.option.exposure) == exposure_range.default) + + test.check(depth_sensor.get_option(rs.option.gain) == gain_range.min) + depth_sensor.set_option(rs.option.gain, gain_range.default + 10) + test.check(depth_sensor.get_option(rs.option.gain) == gain_range.default + 10) + + pipe.stop() + depth_sensor.set_option(rs.option.hdr_enabled, 0) # disable hdr before next tests test.print_results_and_exit()