CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix hdr bug where no depth sensor exists #14179
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
Conversation
7a6b577
to
d9d1443
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an HDR bug that occurs when no depth sensor is available on the device. The main issue was that the HDR model constructor was attempting to access depth sensor options without proper error handling, causing crashes when a depth sensor doesn't exist.
Key changes:
- Added validation for HDR preset iterations to prevent invalid configurations
- Wrapped depth sensor initialization in try-catch to handle missing depth sensors gracefully
- Made option ranges non-const to allow initialization in the constructor body
- Fixed format string vulnerabilities in ImGui text rendering
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/ds/advanced_mode/json_loader.hpp | Added validation for HDR preset iterations to ensure valid range |
common/hdr-model.h | Changed option ranges from const to non-const to support deferred initialization |
common/hdr-model.cpp | Added error handling for missing depth sensors and fixed format string issues |
|
||
item_header.header_size = hdr_preset::item_header::size(); | ||
item_header.iterations = static_cast<uint16_t>(std::stoi(item.at("iterations").get<std::string>())); | ||
if( item_header.iterations <= 0 || item_header.iterations > 0xFFFF ) // not allowing 0 iterations |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition item_header.iterations > 0xFFFF
is redundant since item_header.iterations
is of type uint16_t
, which can only hold values from 0 to 0xFFFF. This check will never be true.
if( item_header.iterations <= 0 || item_header.iterations > 0xFFFF ) // not allowing 0 iterations | |
if( item_header.iterations == 0 ) // not allowing 0 iterations |
Copilot uses AI. Check for mistakes.
|
||
auto text_gain = _is_auto ? "Gain Delta" : "Gain Value:"; | ||
ImGui::Text( text_gain ); | ||
auto text_gain = _is_auto ? "Gain Delta:" : "Gain Value:"; |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after 'Delta' - should be 'Gain Delta: ' to match the pattern used for 'Gain Value:'
auto text_gain = _is_auto ? "Gain Delta:" : "Gain Value:"; | |
auto text_gain = _is_auto ? "Gain Delta: " : "Gain Value:"; |
Copilot uses AI. Check for mistakes.
common/hdr-model.cpp
Outdated
else | ||
control.depth_gain = (int)clamp((float)g, _gain_range.min, _gain_range.max); | ||
|
||
auto text_exp = _is_auto ? "Exposure Delta" : "Exposure Value:"; |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing colon after 'Delta' - should be 'Exposure Delta:' to match the pattern used for 'Exposure Value:'
auto text_exp = _is_auto ? "Exposure Delta" : "Exposure Value:"; | |
auto text_exp = _is_auto ? "Exposure Delta:" : "Exposure Value:"; |
Copilot uses AI. Check for mistakes.
common/hdr-model.cpp
Outdated
catch( const rs2::error & e ) | ||
{ | ||
_hdr_supported = false; | ||
LOG_ERROR( "Failed to initialize HDR model: " << e.what() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_DEBUG
Tracked on: [RSDSO-19396]