Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reread calibration tables after applying OCC calibration #13524

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ); }
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
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 )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The write does it inside no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not understand. _calib_engine->write_calibration() uses a HWMC to write the data to the camera.
The callbacks are to notify users - in this case the device object

cb();
// Currently only depth calibrations are supported, call correct callbacks based on table type otherwise
//for( auto & cb : _color_write_callbacks )
// cb();
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
}

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently D500 calibration logic does not implement (no need) resetting to factory calibration. I just wanted that, if and whenever it might be implemented, we won't forget notifying the callbacks

//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
Loading