Skip to content

Commit

Permalink
PR #13512 from Nir-Az: Table read error fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az authored Nov 14, 2024
2 parents 31f3252 + c25e183 commit 2fea862
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
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

0 comments on commit 2fea862

Please sign in to comment.