diff --git a/src/auto-calibrated-device.h b/src/auto-calibrated-device.h index a8835bbe0d..ad01b3f89e 100644 --- a/src/auto-calibrated-device.h +++ b/src/auto-calibrated-device.h @@ -28,6 +28,14 @@ namespace librealsense float target_w, float target_h, rs2_update_progress_callback_sptr progress_callback) = 0; virtual std::string get_calibration_config() const = 0; virtual void set_calibration_config(const std::string& calibration_config_json_str) const = 0; + + void add_depth_write_observer( std::function< void() > callback ) { _depth_write_callbacks.push_back( callback ); } + void add_color_write_observer( std::function< void() > callback ) { _color_write_callbacks.push_back( callback ); } + + protected: + std::vector< std::function< void() > > _depth_write_callbacks; // Notify observers when depth tables are written + std::vector< std::function< void() > > _color_write_callbacks; // Notify observers when color table is written + }; MAP_EXTENSION(RS2_EXTENSION_AUTO_CALIBRATED_DEVICE, auto_calibrated_interface); } diff --git a/src/ds/d400/d400-auto-calibration.cpp b/src/ds/d400/d400-auto-calibration.cpp index b0bfd74e8e..66fa23fd5d 100644 --- a/src/ds/d400/d400-auto-calibration.cpp +++ b/src/ds/d400/d400-auto-calibration.cpp @@ -1599,6 +1599,18 @@ namespace librealsense LOG_DEBUG("Flashing " << ((tbl_id == d400_calibration_table_id::coefficients_table_id) ? "Depth" : "RGB") << " calibration table"); + switch( tbl_id ) + { + case d400_calibration_table_id::coefficients_table_id: + for( auto & cb : _depth_write_callbacks ) + cb(); + break; + case d400_calibration_table_id::rgb_calibration_id: + for( auto & cb : _color_write_callbacks ) + cb(); + break; + // default: Will not arrive here, was thrown in previous switch + } } void auto_calibrated::set_calibration_table(const std::vector& calibration) @@ -1638,6 +1650,11 @@ namespace librealsense { command cmd(ds::fw_cmd::CAL_RESTORE_DFLT); _hw_monitor->send(cmd); + + for( auto & cb : _depth_write_callbacks ) + cb(); + for( auto & cb : _color_write_callbacks ) + cb(); } std::vector auto_calibrated::run_focal_length_calibration(rs2_frame_queue* left, rs2_frame_queue* right, float target_w, float target_h, diff --git a/src/ds/d400/d400-color.cpp b/src/ds/d400/d400-color.cpp index 88a0290073..74d6c74f69 100644 --- a/src/ds/d400/d400-color.cpp +++ b/src/ds/d400/d400-color.cpp @@ -156,7 +156,9 @@ namespace librealsense { register_metadata_mipi(color_ep); } - register_processing_blocks(); + register_processing_blocks(); + + auto_calibrated::add_color_write_observer( [this]() { _color_calib_table_raw.reset(); } ); } void d400_color::register_options() diff --git a/src/ds/d400/d400-device.cpp b/src/ds/d400/d400-device.cpp index d63f190bf4..fe61a97678 100644 --- a/src/ds/d400/d400-device.cpp +++ b/src/ds/d400/d400-device.cpp @@ -969,6 +969,12 @@ namespace librealsense std::string curr_version= _fw_version; register_features(); + + auto_calibrated::add_depth_write_observer( [this]() + { + _coefficients_table_raw.reset(); + _new_calib_table_raw.reset(); + } ); } void d400_device::register_features() diff --git a/src/ds/d500/d500-auto-calibration.cpp b/src/ds/d500/d500-auto-calibration.cpp index d53d303752..b6d0ac2a9d 100644 --- a/src/ds/d500/d500-auto-calibration.cpp +++ b/src/ds/d500/d500-auto-calibration.cpp @@ -432,6 +432,12 @@ namespace librealsense void d500_auto_calibrated::write_calibration() const { _calib_engine->write_calibration(_curr_calibration); + + for( auto & cb : _depth_write_callbacks ) + cb(); + // Currently only depth calibrations are supported, call correct callbacks based on table type otherwise + //for( auto & cb : _color_write_callbacks ) + // cb(); } void d500_auto_calibrated::set_calibration_table(const std::vector& calibration) @@ -463,6 +469,12 @@ namespace librealsense void d500_auto_calibrated::reset_to_factory_calibration() const { throw not_implemented_exception(rsutils::string::from() << "Reset to factory Calibration not applicable for this device"); + + // Uncomment if function implemented + //for( auto & cb : _depth_write_callbacks ) + // cb(); + //for( auto & cb : _color_write_callbacks ) + // cb(); } std::vector< uint8_t > d500_auto_calibrated::run_focal_length_calibration( rs2_frame_queue * left, diff --git a/src/ds/d500/d500-color.cpp b/src/ds/d500/d500-color.cpp index 5ae9d96512..db220350c2 100644 --- a/src/ds/d500/d500-color.cpp +++ b/src/ds/d500/d500-color.cpp @@ -111,6 +111,8 @@ namespace librealsense register_options(); register_metadata(); register_color_processing_blocks(); + + d500_auto_calibrated::add_color_write_observer( [this]() { _color_calib_table_raw.reset(); } ); } void d500_color::register_color_processing_blocks() diff --git a/src/ds/d500/d500-device.cpp b/src/ds/d500/d500-device.cpp index 843585f891..6118e7e6ea 100644 --- a/src/ds/d500/d500-device.cpp +++ b/src/ds/d500/d500-device.cpp @@ -602,6 +602,7 @@ namespace librealsense depth_sensor.register_option( RS2_OPTION_ERROR_POLLING_ENABLED, std::make_shared< polling_errors_disable >( _polling_error_handler ) ); + }); //group_multiple_fw_calls // attributes of md_capture_timing @@ -702,6 +703,12 @@ namespace librealsense register_info(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR, usb_type_str); register_features(); + + d500_auto_calibrated::add_depth_write_observer( [this]() + { + _coefficients_table_raw.reset(); + _new_calib_table_raw.reset(); + } ); } void d500_device::register_features()