From 40a90a83bd836e7c654f122c3a80a7572f12fbdd Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Wed, 13 Nov 2024 15:06:02 +0200 Subject: [PATCH 1/3] 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; } } From 524f519d548565362b9f6d6aaa3a1e15d16d38d7 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Wed, 13 Nov 2024 18:40:06 +0200 Subject: [PATCH 2/3] commets improvements --- src/ds/d500/d500-device.cpp | 2 +- src/ds/d500/d500-private.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ds/d500/d500-device.cpp b/src/ds/d500/d500-device.cpp index 85379bdb41..843585f891 100644 --- a/src/ds/d500/d500-device.cpp +++ b/src/ds/d500/d500-device.cpp @@ -294,7 +294,7 @@ namespace librealsense } catch( const std::exception &e ) { - LOG_ERROR("Failed reading stereo baseline, using a default value --> " << e.what() ); + LOG_ERROR("Failed reading stereo baseline, using default value --> " << e.what() ); } return baseline; diff --git a/src/ds/d500/d500-private.cpp b/src/ds/d500/d500-private.cpp index dadaf447e4..bd23e70c4f 100644 --- a/src/ds/d500/d500-private.cpp +++ b/src/ds/d500/d500-private.cpp @@ -62,7 +62,7 @@ namespace librealsense } else // In case we got an empty table we will run with default values { - LOG_ERROR("cannot read intrinsic values, setting defaults"); + LOG_ERROR("cannot read intrinsic values, using default values"); rs2_intrinsics intrinsics = {0}; intrinsics.height = height; intrinsics.width = width; From c25e183f37554eaf4c38f0fa24445ce34616be2c Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Thu, 14 Nov 2024 11:22:26 +0200 Subject: [PATCH 3/3] add depth table related sensor to the comments --- src/ds/d500/d500-private.cpp | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ds/d500/d500-private.cpp b/src/ds/d500/d500-private.cpp index bd23e70c4f..0dfb39977d 100644 --- a/src/ds/d500/d500-private.cpp +++ b/src/ds/d500/d500-private.cpp @@ -43,33 +43,33 @@ 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) { - - if (!raw_data.empty()) + switch (table_id) { - switch (table_id) - { - case d500_calibration_table_id::depth_calibration_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); - } - 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"); - } + else + LOG_ERROR("Cannot read depth table intrinsic values, using default values"); } - else // In case we got an empty table we will run with default values + case d500_calibration_table_id::rgb_calibration_id: { - LOG_ERROR("cannot read intrinsic values, using 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; + 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(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: