Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable runtime exposure update in HDR mode #12908

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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() )
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
{
// 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 } );
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
}
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
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved

test.print_results_and_exit()