Skip to content

Allow loading json for auto-hdr - #14046

Merged
Nir-Az merged 5 commits into
realsenseai:developmentfrom
AviaAv:auto-hdr-_
Jun 15, 2025
Merged

Nir-Az merged 5 commits into
realsenseai:developmentfrom
AviaAv:auto-hdr-_

Conversation

@AviaAv

@AviaAv AviaAv commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

Tracked on: [LRS-1270]

@AviaAv
AviaAv requested a review from Nir-Az June 3, 2025 13:01
@Nir-Az

Nir-Az commented Jun 3, 2025

Copy link
Copy Markdown
Collaborator

I see the windows GHA runner has a depracation error
Please update the image on all jobs to windows-2022
See: https://github.com/actions/runner-images/issues/12045

Workflows using the windows-2019 image label should be updated to windows-2022 or windows-2025.

Comment thread src/ds/advanced_mode/json_loader.hpp Outdated
return map;
}

std::string controlNameFromId( ControlId id )

@Nir-Az Nir-Az Jun 3, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we change the naming convention?
CamelCase instead of using _ like above?
Same comment for all functions added here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw it was used like that on a commented code on another file (bottom of hdr-config.cpp), thought it was intentional
I will change it to the regular naming convention

Comment thread src/ds/advanced_mode/json_loader.hpp Outdated
{
return it->second;
}
throw std::invalid_argument("Error: Incorrect buffer! controlName NOT found! (" + std::to_string(id) + ")");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets an id not name, right?

Comment thread src/ds/advanced_mode/json_loader.hpp Outdated
// Build reverse map on first use
static const std::unordered_map< std::string, ControlId > string_control_id_map = []()
{
std::unordered_map< std::string, ControlId > result;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

control_id?

@Nir-Az

Nir-Az commented Jun 3, 2025

Copy link
Copy Markdown
Collaborator

General comment please add a unit test for this feature

Comment thread common/option-model.cpp Outdated
"algorithm\nClick the button, then draw a rect on the frame" );
}

//if (opt == RS2_OPTION_HDR_ENABLED && false) // TODO: enable this when the auto-hdr feature is fully implemented, currently works via the load/save preset buttons at the top of the viewer - make sure to disable HDR before loading!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a comment lets add the code and wrap with a compilation flag
#if defined(AUTO_HDR)
#endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan on creating a compilation flag for this feature alone? or this is temporary until we add the feature?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary only

@Nir-Az
Nir-Az requested a review from OhadMeir June 3, 2025 13:24
@Nir-Az

Nir-Az commented Jun 3, 2025

Copy link
Copy Markdown
Collaborator

@OhadMeir please continue the review as I will be OOO

Comment thread src/ds/advanced_mode/presets.h Outdated
static constexpr uint8_t size() { return sizeof(item_header); }
};

struct Control {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to capitalize

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think librealsense::control is to common name for this. Maybe put under hdr namespace (will also remove need to comment hdr structs region).

Comment thread src/ds/advanced_mode/presets.h Outdated
static constexpr uint8_t size() { return sizeof(Control); }
};

struct sub_preset

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sub_preset the best name? It does not convey any meaning
I know it's the FW name but it doesn't have to be ours too...
hdr_setting/hdr_control or similar will be better

Comment thread src/ds/advanced_mode/presets.h Outdated
white_balance_control color_white_balance;
auto_white_balance_control color_auto_white_balance;
power_line_frequency_control color_power_line_frequency;
sub_preset sub_preset;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does hdr setting need to change if changing visual preset?

Comment thread common/option-model.cpp Outdated
error_message = safe_call([&]() {
dev->dev.as<serializable_device>().load_json(str);

LOG_INFO("HDR config loaded from JSON file: " << ret);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use notification_model::add_log. Remove easylogging include

Comment thread src/core/advanced_mode.h Outdated
void get_color_white_balance(white_balance_control* ptr) const;
void get_color_auto_white_balance(auto_white_balance_control* ptr) const;
void get_color_power_line_frequency(power_line_frequency_control* ptr) const;
void get_sub_preset(hdr::hdr_control* ptr) const;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned elsewhere, don't use the term "sub_preset". You can "get_hdr_preset" or "get_hdr_control", etc...

Comment thread src/ds/advanced_mode/json_loader.hpp Outdated
}

// Given a sub_preset_header and items, build the byte buffer
std::vector<uint8_t> serialize_sub_preset(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, don't use "sub_preset". Try "serialize_hdr_data/control/preset"

Comment thread src/ds/advanced_mode/json_loader.hpp Outdated

sub_preset["items"].push_back(std::move(item));
}
preset_writer.write_root_param("SubPreset", sub_preset);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also rename SubPreset and sub_preset here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is used to write to JSON, we will have to keep SubPreset here, but I will rename sub_preset to something else

Comment thread src/ds/advanced_mode/presets.h Outdated
static const std::unordered_map< control_id, std::string > control_id_string_map = {
{ DEPTH_LASER_MODE, "DepthLaserMode" },
{ DEPTH_MAN_EXP, "DepthManExp" },
{ DEPTH_GAIN, "DepthGain" },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OhadMeir If we change the JSON keys, we can also change those, right? call those depth-laser-mode, depth-exposure and depth-gain

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right

Comment thread src/ds/advanced_mode/json_loader.hpp Outdated
// build 'controls' array for the item
for (int c = 0; c < ih.num_of_controls; ++c) {
const hdr_preset::sub_control& ctrl = auto_hdr.items[i].second[c];
const std::string controlName = control_name_from_id( hdr_preset::control_id( ctrl.control_id ) );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename "control_name"

@OhadMeir OhadMeir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Will merge after minor fix (rename)

@Nir-Az
Nir-Az merged commit 8aee4e0 into realsenseai:development Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants