Skip to main content

ProblemType

Trait ProblemType 

Source
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§

Source

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.

Source

type Input: Clone + Serialize + DeserializeOwned + Debug

Input observations (embedded in session).

Examples: PlanarDataset, HandEyeDataset, LaserlineDataset.

Source

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.

Source

type Output: Clone + Serialize + DeserializeOwned + Debug

Final calibration output (single result).

Examples: PlanarIntrinsicsEstimate, HandEyeEstimate.

Source

type Export: Clone + Serialize + DeserializeOwned + Debug

Export format for external consumption.

May be the same as Output, or a simplified/transformed version suitable for downstream use.

Required Methods§

Source

fn name() -> &'static str

Unique identifier for this problem type.

Used for serialization, logging, and identifying session files. Should be a stable, lowercase, snake_case string.

Examples: "planar_intrinsics", "hand_eye", "laserline_bundle".

Source

fn export( output: &Self::Output, config: &Self::Config, ) -> Result<Self::Export, Error>

Convert output to export format.

Called by CalibrationSession::export. The config is provided for cases where export format depends on settings.

Provided Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn on_input_change() -> InvalidationPolicy

Policy for what to clear when input changes.

Default: clear state and output, keep exports.

Source

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.

Implementors§

Source§

impl ProblemType for LaserlineDeviceProblem

Source§

impl ProblemType for PlanarIntrinsicsProblem

Source§

impl ProblemType for RigExtrinsicsProblem

Source§

impl ProblemType for RigHandeyeProblem

Source§

impl ProblemType for ScheimpflugIntrinsicsProblem

Source§

impl ProblemType for SingleCamHandeyeProblem