Skip to main content

CalibrationSession

Struct CalibrationSession 

Source
pub struct CalibrationSession<P>
where P: ProblemType,
{ pub metadata: SessionMetadata, pub config: <P as ProblemType>::Config, pub state: <P as ProblemType>::State, pub exports: Vec<ExportRecord<<P as ProblemType>::Export>>, pub log: Vec<LogEntry>, /* private fields */ }
Expand description

A calibration session container with mutable state.

The session stores configuration, input data, intermediate state, and the final output. Step functions mutate the session in-place.

§Design Principles

  • Single output: Only one final result is stored.
  • Embedded input: Input data is stored directly in the session.
  • Config changes don’t auto-clear: Changing config doesn’t invalidate output.
  • Exports collection: Multiple exports can be generated and stored.

§Example

use vision_calibration_pipeline::session::CalibrationSession;
use vision_calibration_pipeline::planar_intrinsics::{PlanarIntrinsicsProblem, step_init, step_optimize};

let mut session = CalibrationSession::<PlanarIntrinsicsProblem>::new();
session.set_input(dataset)?;

step_init(&mut session, None)?;
step_optimize(&mut session, None)?;

let export = session.export()?;

Fields§

§metadata: SessionMetadata

Session metadata (problem type, schema version, timestamps, description).

§config: <P as ProblemType>::Config

Configuration parameters (always present, defaults if not explicitly set).

§state: <P as ProblemType>::State

Problem-specific intermediate state (default until computed).

§exports: Vec<ExportRecord<<P as ProblemType>::Export>>

Collection of generated exports.

§log: Vec<LogEntry>

Operation log (lightweight audit trail).

Implementations§

Source§

impl<P> CalibrationSession<P>
where P: ProblemType,

Source

pub fn new() -> CalibrationSession<P>

Create a new empty session with default configuration.

Source

pub fn with_description(description: impl Into<String>) -> CalibrationSession<P>

Create a new session with a description.

Source

pub fn with_input( input: <P as ProblemType>::Input, ) -> Result<CalibrationSession<P>, Error>

Create a new session with input data.

§Errors

Returns an error if input validation fails.

Source

pub fn set_input( &mut self, input: <P as ProblemType>::Input, ) -> Result<(), Error>

Set input data, applying validation and invalidation policy.

§Errors

Returns an error if ProblemType::validate_input fails.

Source

pub fn input(&self) -> Option<&<P as ProblemType>::Input>

Get a reference to the input, if set.

Source

pub fn input_mut(&mut self) -> Option<&mut <P as ProblemType>::Input>

Get a mutable reference to the input, if set.

Source

pub fn require_input(&self) -> Result<&<P as ProblemType>::Input, Error>

Get a reference to the input, or error if not set.

§Errors

Returns an error if input is not set.

Source

pub fn require_input_mut( &mut self, ) -> Result<&mut <P as ProblemType>::Input, Error>

Get a mutable reference to the input, or error if not set.

§Errors

Returns an error if input is not set.

Source

pub fn has_input(&self) -> bool

Check if input is set.

Source

pub fn clear_input(&mut self)

Clear input data, applying invalidation policy.

Source

pub fn set_config( &mut self, config: <P as ProblemType>::Config, ) -> Result<(), Error>

Set configuration, applying validation and invalidation policy.

§Errors

Returns an error if ProblemType::validate_config fails.

Source

pub fn update_config<F>(&mut self, f: F) -> Result<(), Error>
where F: FnOnce(&mut <P as ProblemType>::Config),

Update configuration with a closure.

The closure receives a mutable reference to the current config. After the closure returns, validation and invalidation policy are applied.

§Errors

Returns an error if validation fails after the update.

Source

pub fn output(&self) -> Option<&<P as ProblemType>::Output>

Get a reference to the output, if computed.

Source

pub fn output_mut(&mut self) -> Option<&mut <P as ProblemType>::Output>

Get a mutable reference to the output, if computed.

Source

pub fn require_output(&self) -> Result<&<P as ProblemType>::Output, Error>

Get a reference to the output, or error if not computed.

§Errors

Returns an error if output is not computed.

Source

pub fn set_output(&mut self, output: <P as ProblemType>::Output)

Set the output (typically called by step functions).

Source

pub fn has_output(&self) -> bool

Check if output is computed.

Source

pub fn clear_output(&mut self)

Clear output.

Source

pub fn export(&mut self) -> Result<<P as ProblemType>::Export, Error>

Export the current output and add to exports collection.

§Errors

Returns an error if output is not computed or if export conversion fails.

Source

pub fn export_with_notes( &mut self, notes: impl Into<String>, ) -> Result<<P as ProblemType>::Export, Error>

Export the current output with notes and add to exports collection.

§Errors

Returns an error if output is not computed or if export conversion fails.

Source

pub fn export_peek(&self) -> Result<<P as ProblemType>::Export, Error>

Export without adding to collection (peek).

Useful for inspecting the export without modifying the session.

§Errors

Returns an error if output is not computed or if export conversion fails.

Source

pub fn validate(&self) -> Result<(), Error>

Validate that the session is ready for processing.

Checks:

  1. Input is set and valid
  2. Config is valid
  3. Input and config are compatible (cross-validation)
§Errors

Returns an error if any validation check fails.

Source

pub fn log_success(&mut self, operation: impl Into<String>)

Log a successful operation.

Source

pub fn log_success_with_notes( &mut self, operation: impl Into<String>, notes: impl Into<String>, )

Log a successful operation with notes.

Source

pub fn log_failure( &mut self, operation: impl Into<String>, error: impl Into<String>, )

Log a failed operation.

Source

pub fn reset_state(&mut self)

Reset state to default, keeping input, config, and output.

Source

pub fn reset_output(&mut self)

Reset output, keeping input, config, and state.

Source

pub fn reset(&mut self)

Reset everything except config and description.

Source

pub fn to_json(&self) -> Result<String, Error>

Serialize session to JSON string.

§Errors

Returns an error if serialization fails.

Source

pub fn from_json(json: &str) -> Result<CalibrationSession<P>, Error>

Deserialize session from JSON string.

§Errors

Returns an error if:

  • Deserialization fails
  • Problem type does not match P::name()
  • Schema version does not match P::schema_version()

Trait Implementations§

Source§

impl<P> Clone for CalibrationSession<P>

Source§

fn clone(&self) -> CalibrationSession<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P> Debug for CalibrationSession<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<P> Default for CalibrationSession<P>
where P: ProblemType,

Source§

fn default() -> CalibrationSession<P>

Returns the “default value” for a type. Read more
Source§

impl<'de, P> Deserialize<'de> for CalibrationSession<P>
where P: ProblemType,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<CalibrationSession<P>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<P> Serialize for CalibrationSession<P>
where P: ProblemType,

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<P> Freeze for CalibrationSession<P>

§

impl<P> RefUnwindSafe for CalibrationSession<P>

§

impl<P> Send for CalibrationSession<P>
where <P as ProblemType>::Config: Send, <P as ProblemType>::State: Send, <P as ProblemType>::Input: Send, <P as ProblemType>::Output: Send, <P as ProblemType>::Export: Send,

§

impl<P> Sync for CalibrationSession<P>
where <P as ProblemType>::Config: Sync, <P as ProblemType>::State: Sync, <P as ProblemType>::Input: Sync, <P as ProblemType>::Output: Sync, <P as ProblemType>::Export: Sync,

§

impl<P> Unpin for CalibrationSession<P>

§

impl<P> UnsafeUnpin for CalibrationSession<P>

§

impl<P> UnwindSafe for CalibrationSession<P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,