Skip to content

Commit

Permalink
PR #12908 from noacoohen: Enable runtime exposure update in HDR mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az committed May 12, 2024
2 parents 6702e3d + cbe521b commit 998aaa1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/ds/ds-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
43 changes: 43 additions & 0 deletions unit-tests/live/d400/test-hdr-long.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 998aaa1

Please sign in to comment.