pub trait ProblemType: Sized + 'static {
type Config: Clone + Default + Serialize + DeserializeOwned + Debug;
type Input: Clone + Serialize + DeserializeOwned + Debug;
type State: Clone + Default + Serialize + DeserializeOwned + Debug;
type Output: Clone + Serialize + DeserializeOwned + Debug;
type Export: Clone + Serialize + DeserializeOwned + Debug;
// Required methods
fn name() -> &'static str;
fn export(
output: &Self::Output,
config: &Self::Config,
) -> Result<Self::Export, Error>;
// Provided methods
fn schema_version() -> u32 { ... }
fn validate_input(_input: &Self::Input) -> Result<(), Error> { ... }
fn validate_config(_config: &Self::Config) -> Result<(), Error> { ... }
fn validate_input_config(
_input: &Self::Input,
_config: &Self::Config,
) -> Result<(), Error> { ... }
fn on_input_change() -> InvalidationPolicy { ... }
fn on_config_change() -> InvalidationPolicy { ... }
}Expand description
Trait defining the interface for a calibration problem.
Each problem type (e.g., planar intrinsics, hand-eye, laserline) implements this trait to specify its configuration, input data, internal state, output, and export formats.
§Design Philosophy
The trait is minimal by design. Problem-specific behavior is implemented
via step functions that operate on &mut CalibrationSession<Self> rather
than as trait methods. This allows:
- Arbitrary step signatures with step-specific options
- Easy composition of custom pipelines
- Direct access to intermediate state
§Associated Types
- Config: Calibration parameters (solver options, fix masks, thresholds)
- Input: Observation data (image points, correspondences)
- State: Problem-specific intermediate results (homographies, initial poses)
- Output: Final calibration result (camera parameters, errors)
- Export: User-facing export format (may be same as Output)
§Example
pub struct MyProblem;
impl ProblemType for MyProblem {
type Config = MyConfig;
type Input = MyDataset;
type State = MyState;
type Output = MyResult;
type Export = MyExport;
fn name() -> &'static str { "my_problem" }
fn export(output: &Self::Output, _config: &Self::Config) -> Result<Self::Export, crate::Error> {
Ok(output.into())
}
}Required Associated Types§
Sourcetype Config: Clone + Default + Serialize + DeserializeOwned + Debug
type Config: Clone + Default + Serialize + DeserializeOwned + Debug
Configuration parameters that control calibration behavior.
Examples: solver options, fix masks, convergence thresholds.
Must have a sensible Default implementation.
Sourcetype Input: Clone + Serialize + DeserializeOwned + Debug
type Input: Clone + Serialize + DeserializeOwned + Debug
Input observations (embedded in session).
Examples: PlanarDataset, HandEyeDataset, LaserlineDataset.
Sourcetype State: Clone + Default + Serialize + DeserializeOwned + Debug
type State: Clone + Default + Serialize + DeserializeOwned + Debug
Problem-specific workspace for intermediate results.
Examples: computed homographies, initial poses, per-view residuals.
Use () if no intermediate state is needed.
Required Methods§
Provided Methods§
Sourcefn schema_version() -> u32
fn schema_version() -> u32
Schema version for forward compatibility.
Bump when the serialization format of any associated type changes in a way that breaks backward compatibility.
The session loader validates this value strictly and rejects sessions whose metadata schema version differs from the current implementation.
Sourcefn validate_input(_input: &Self::Input) -> Result<(), Error>
fn validate_input(_input: &Self::Input) -> Result<(), Error>
Validate input data after setting.
Called by CalibrationSession::set_input.
Return an error to reject the input.
Default implementation: always valid.
Sourcefn validate_config(_config: &Self::Config) -> Result<(), Error>
fn validate_config(_config: &Self::Config) -> Result<(), Error>
Validate configuration.
Called by CalibrationSession::set_config.
Return an error to reject the config.
Default implementation: always valid.
Sourcefn validate_input_config(
_input: &Self::Input,
_config: &Self::Config,
) -> Result<(), Error>
fn validate_input_config( _input: &Self::Input, _config: &Self::Config, ) -> Result<(), Error>
Cross-validate input and config together.
Called by CalibrationSession::validate
after individual validation passes.
Default implementation: always valid.
Sourcefn on_input_change() -> InvalidationPolicy
fn on_input_change() -> InvalidationPolicy
Policy for what to clear when input changes.
Default: clear state and output, keep exports.
Sourcefn on_config_change() -> InvalidationPolicy
fn on_config_change() -> InvalidationPolicy
Policy for what to clear when config changes.
Default: keep everything (config changes don’t auto-invalidate).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.