From 40a90a83bd836e7c654f122c3a80a7572f12fbdd Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Wed, 13 Nov 2024 15:06:02 +0200 Subject: [PATCH] support empty flash enumeration --- src/ds/d500/d500-device.cpp | 14 ++++++++++++-- src/ds/d500/d500-private.cpp | 32 +++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/ds/d500/d500-device.cpp b/src/ds/d500/d500-device.cpp index d456ab0123..85379bdb41 100644 --- a/src/ds/d500/d500-device.cpp +++ b/src/ds/d500/d500-device.cpp @@ -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(*_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(*_coefficients_table_raw); + baseline = fabs(table->baseline); + } + catch( const std::exception &e ) + { + LOG_ERROR("Failed reading stereo baseline, using a default value --> " << e.what() ); + } + + return baseline; } std::vector d500_device::get_d500_raw_calibration_table(ds::d500_calibration_table_id table_id) const // to be d500 adapted diff --git a/src/ds/d500/d500-private.cpp b/src/ds/d500/d500-private.cpp index fb597f8d0e..dadaf447e4 100644 --- a/src/ds/d500/d500-private.cpp +++ b/src/ds/d500/d500-private.cpp @@ -43,18 +43,32 @@ namespace librealsense rs2_intrinsics get_d500_intrinsic_by_resolution(const vector& raw_data, d500_calibration_table_id table_id, uint32_t width, uint32_t height, bool is_symmetrization_enabled) { - switch (table_id) - { - case d500_calibration_table_id::depth_calibration_id: + + if (!raw_data.empty()) { - return get_d500_depth_intrinsic_by_resolution(raw_data, width, height, is_symmetrization_enabled); + switch (table_id) + { + case d500_calibration_table_id::depth_calibration_id: + { + return get_d500_depth_intrinsic_by_resolution(raw_data, width, height, is_symmetrization_enabled); + } + case d500_calibration_table_id::rgb_calibration_id: + { + return get_d500_color_intrinsic_by_resolution(raw_data, width, height); + } + default: + throw invalid_value_exception(rsutils::string::from() << "Parsing Calibration table type " << static_cast(table_id) << " is not supported"); + } } - case d500_calibration_table_id::rgb_calibration_id: + else // In case we got an empty table we will run with default values { - return get_d500_color_intrinsic_by_resolution(raw_data, width, height); - } - default: - throw invalid_value_exception(rsutils::string::from() << "Parsing Calibration table type " << static_cast(table_id) << " is not supported"); + LOG_ERROR("cannot read intrinsic values, setting defaults"); + 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; } }