Skip to content

Commit

Permalink
PR #13524 from OhadMeir: Reread calibration tables after applying OCC…
Browse files Browse the repository at this point in the history
… calibration
  • Loading branch information
Nir-Az authored Nov 21, 2024
2 parents 090ccbb + d1b71f6 commit a75366f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/auto-calibrated-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
17 changes: 17 additions & 0 deletions src/ds/d400/d400-auto-calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>& calibration)
Expand Down Expand Up @@ -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<uint8_t> auto_calibrated::run_focal_length_calibration(rs2_frame_queue* left, rs2_frame_queue* right, float target_w, float target_h,
Expand Down
4 changes: 3 additions & 1 deletion src/ds/d400/d400-color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions src/ds/d400/d400-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions src/ds/d500/d500-auto-calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>& calibration)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/ds/d500/d500-color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions src/ds/d500/d500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a75366f

Please sign in to comment.