pysdic.SDICUnknowns#

SDICUnknowns class#

class SDICUnknowns(optimized_frames, optimized_transformations)[source]#

The description of the unknowns of an optimization: the frames whose displacements are optimized and the transformations of the cameras whose parameters are optimized, in the order of the vector of unknowns

\[\vec{p} = [\vec{p}_U, \vec{p}_T]\]
  • \(\vec{p}_U\): the total displacements \((N_v, E)\) (from the reference mesh, not increments) of the optimized_frames, each one flattened in Fortran order (all the \(x\) components, then all the \(y\) components, …) and concatenated in the order of optimized_frames;

  • \(\vec{p}_T\): the parameters of the optimized_transformations, concatenated in the order of optimized_transformations.

The component \(e\) of the displacement of the vertex \(v\) at the optimized frame \(k\) (in the order of optimized_frames) has the index \(k N_v E + e N_v + v\).

The unknowns do not know the analysis. As a pysdic.Pairing, a SDICUnknowns is a light frozen description, validated by an analysis with pysdic.SDICAnalysis.validate_unknowns(). The same unknowns can be used with several analyses (e.g. an analysis and the analysis given by its with_mesh). The vector itself is built by the analysis, which knows the sizes and holds the values:

The objects of a pysolvegn problem (pysdic.SDICCorrelationTerm, pysdic.SDICTemporalRegularizationTerm, pysdic.SDICFixedParametrization) are all created with the same analysis and the same unknowns objects, checked by pysdic.check_same_problem() before solving.

Warning

With a parametrization, do not use pack_unknowns, unpack_unknowns or apply_unknowns on the vectors of the solver: they are reduced vectors \(\vec{q}\). Use parametrization.reparametrized_pack(), reparametrized_unpack(q) and reparametrized_apply(q) (see pysdic.SDICFixedParametrization).

The object cannot be modified after its creation. It is compared by identity: the objects of a problem must share the same SDICUnknowns object.

Parameters:
  • optimized_frames (Union[Integral, Sequence[Integral]]) – The frames whose displacements are optimized, in the order of the unknowns: a single frame index or a sequence of distinct non-negative indices (possibly empty).

  • optimized_transformations (Sequence[Tuple[str, Integral]]) – The optimized transformations, as tuples (kind, index) with kind in "extrinsic", "distortion" and "intrinsic" (see pysdic.SDICAnalysis.get_transformation()), in the order of the unknowns (possibly empty), without duplicates.

Raises:
  • TypeError – If an input has a wrong type.

  • ValueError – If a frame or a transformation is given twice, or a kind is not valid.

Examples

from pysdic import SDICUnknowns

unknowns = SDICUnknowns([1, 2], [("extrinsic", 1)])
analysis.validate_unknowns(unknowns)       # Frames and transformations exist, parameters not locked, ...

p0 = analysis.pack_unknowns(unknowns)
...
analysis.apply_unknowns(unknowns, result.parameters)  # Displacements and extrinsic written

Instantiation#

A SDICUnknowns is created by the user with the optimized frames and the optimized transformations (kind, index). It does not know the analysis: as a pysdic.Pairing, it is a light frozen description, validated by an analysis with pysdic.SDICAnalysis.validate_unknowns() (the objects of a problem call it at their creation). The same unknowns can be used with several analyses.

from pysdic import SDICUnknowns

unknowns = SDICUnknowns([1], [])                  # Measurement of the frame 1
unknowns = SDICUnknowns([], [("extrinsic", 1)])   # Calibration of the extrinsic 1
unknowns = SDICUnknowns([1], [("extrinsic", 1)])  # Joint optimization

analysis.validate_unknowns(unknowns)  # The frames and transformations exist, have parameters, are not locked

The objects of a pysolvegn problem (pysdic.SDICCorrelationTerm, pysdic.SDICTemporalRegularizationTerm, pysdic.SDICFixedParametrization) are created with the same analysis object and the same unknowns object: pysdic.check_same_problem() checks it by identity. To change the unknowns (e.g. the next frame of a measurement), create new unknowns and give them to each object of the problem with its with_unknowns method.

Attributes#

SDICUnknowns.optimized_frames

The optimized frames, in the order of the unknowns.

SDICUnknowns.optimized_transformations

The optimized transformations (kind, index), in the order of the unknowns.

SDICUnknowns.n_frames

The number of optimized frames \(N_f\).

SDICUnknowns.n_transformations

The number of optimized transformations.

SDICUnknowns.is_empty

Whether there is neither optimized frame nor optimized transformation.

Vector of unknowns#

The vector \(\vec{p} = [\vec{p}_U, \vec{p}_T]\): the total displacement \((N_v, E)\) of each optimized frame (from the reference mesh, not an increment) in Fortran order (the component \(e\) of the vertex \(v\) at the optimized frame \(k\) has the index \(k N_v E + e N_v + v\)), then the parameters of the optimized transformations.

The unknowns do not know the sizes nor the values: the vector is built by the analysis.

p0 = analysis.pack_unknowns(unknowns)                                 # Current state -> p
displacements, parameters = analysis.unpack_unknowns(unknowns, p)     # p -> copies
analysis.apply_unknowns(unknowns, result.parameters)                  # p -> analysis

Warning

With a parametrization, do not use pack_unknowns, unpack_unknowns or apply_unknowns on the vectors of the solver: they are reduced vectors \(\vec{q}\). Use parametrization.reparametrized_pack(), reparametrized_unpack(q) and reparametrized_apply(q) (see pysdic.SDICFixedParametrization).