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 ofoptimized_frames;\(\vec{p}_T\): the parameters of the
optimized_transformations, concatenated in the order ofoptimized_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, aSDICUnknownsis a light frozen description, validated by an analysis withpysdic.SDICAnalysis.validate_unknowns(). The same unknowns can be used with several analyses (e.g. an analysis and the analysis given by itswith_mesh). The vector itself is built by the analysis, which knows the sizes and holds the values:pysdic.SDICAnalysis.pack_unknowns(): the vector \(\vec{p}\) of the current state;pysdic.SDICAnalysis.unpack_unknowns(): split a vector into displacements and parameters;pysdic.SDICAnalysis.apply_unknowns(): write a vector in the analysis;pysdic.SDICAnalysis.n_unknowns(),pysdic.SDICAnalysis.get_unknowns_frame_slice(),pysdic.SDICAnalysis.get_unknowns_transformation_slice()andpysdic.SDICAnalysis.compute_unknowns_indices(): the layout of the vector.
The objects of a
pysolvegnproblem (pysdic.SDICCorrelationTerm,pysdic.SDICTemporalRegularizationTerm,pysdic.SDICFixedParametrization) are all created with the same analysis and the same unknowns objects, checked bypysdic.check_same_problem()before solving.Warning
With a parametrization, do not use
pack_unknowns,unpack_unknownsorapply_unknownson the vectors of the solver: they are reduced vectors \(\vec{q}\). Useparametrization.reparametrized_pack(),reparametrized_unpack(q)andreparametrized_apply(q)(seepysdic.SDICFixedParametrization).The object cannot be modified after its creation. It is compared by identity: the objects of a problem must share the same
SDICUnknownsobject.- 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)withkindin"extrinsic","distortion"and"intrinsic"(seepysdic.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#
The optimized frames, in the order of the unknowns. |
|
The optimized transformations |
|
The number of optimized frames \(N_f\). |
|
The number of optimized transformations. |
|
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
pysdic.SDICAnalysis.pack_unknowns(),pysdic.SDICAnalysis.unpack_unknowns(),pysdic.SDICAnalysis.apply_unknowns()pysdic.SDICAnalysis.get_unknowns_frame_slice(),pysdic.SDICAnalysis.get_unknowns_transformation_slice(),pysdic.SDICAnalysis.compute_unknowns_indices()
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).