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

Table read error fallback #13512

Merged
merged 3 commits into from
Nov 14, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ds/d500/d500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,18 @@ namespace librealsense
float d500_device::get_stereo_baseline_mm() const // to be d500 adapted
{
using namespace ds;
auto table = check_calib<d500_coefficients_table>(*_coefficients_table_raw);
return fabs(table->baseline);
float baseline = 100.0f; // so we will have a non zero value if cannot read from table
try
{
auto table = check_calib<d500_coefficients_table>(*_coefficients_table_raw);
baseline = fabs(table->baseline);
}
catch( const std::exception &e )
{
LOG_ERROR("Failed reading stereo baseline, using default value --> " << e.what() );
}

return baseline;
}

std::vector<uint8_t> d500_device::get_d500_raw_calibration_table(ds::d500_calibration_table_id table_id) const // to be d500 adapted
Expand Down
18 changes: 16 additions & 2 deletions src/ds/d500/d500-private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,29 @@ namespace librealsense
{
case d500_calibration_table_id::depth_calibration_id:
{
return get_d500_depth_intrinsic_by_resolution(raw_data, width, height, is_symmetrization_enabled);
if ( !raw_data.empty() )
return get_d500_depth_intrinsic_by_resolution(raw_data, width, height, is_symmetrization_enabled);
else
LOG_ERROR("Cannot read depth table intrinsic values, using default values");
}
case d500_calibration_table_id::rgb_calibration_id:
{
return get_d500_color_intrinsic_by_resolution(raw_data, width, height);
if ( !raw_data.empty() )
return get_d500_color_intrinsic_by_resolution(raw_data, width, height);
else
LOG_ERROR("Cannot read color table intrinsic values, using default values");
}
default:
throw invalid_value_exception(rsutils::string::from() << "Parsing Calibration table type " << static_cast<int>(table_id) << " is not supported");
}

// If we got here, the table is empty so continue with default values
rs2_intrinsics intrinsics = {0};
intrinsics.height = height;
intrinsics.width = width;
intrinsics.ppx = intrinsics.fx = width / 2.f;
intrinsics.ppy = intrinsics.fy = height / 2.f;
return intrinsics;
}

// Algorithm prepared by Oscar Pelc in matlab:
Expand Down
Loading