TransformComposition Class#

Note

See the main pycvcam.Transform documentation for more details on how to use transformations.

TransformComposition Class#

class TransformComposition(transforms)[source]#

A class representing the composition of several transformations.

This class allows multiple transformations to be combined into a single transformation that applies them sequentially to input points.

Let \(T_1, T_2, \dots, T_n\) be a sequence of transformations. The composed transformation is defined as

\[T_{\text{composed}} = T_n \circ T_{n-1} \circ \dots \circ T_2 \circ T_1\]

which means that the transformations are applied in the following order:

\[ \begin{align}\begin{aligned}X_1 = T_1(X_I)\\X_2 = T_2(X_1)\\\dots\\X_O = T_n(X_{n-1})\end{aligned}\end{align} \]

where \(X_I\) are the input points and \(X_O\) are the output points.

The parameters and constants of the composed transformation are obtained by concatenating the parameters and constants of the individual transformations.

The Jacobians of the composed transformation are computed using the chain rule, combining the Jacobians of each transformation in the composition.

Warning

Note that modifying the parameters or constants of the individual transformations after creating the composition will affect the behavior of the composed transformation, since the composition does not create independent copies of the parameters and constants.

Moreover, modifying the parameters or constants of the composed transformation will modify the parameters and constants of the individual transformations, since they are shared.

Parameters:

transforms (list[Transform]) – A list of transformations to compose. The transformations are applied sequentially in the order they appear in the list.

Accessing sub-Transform objects#

The following attributes and methods are available for accessing the individual Transform objects that make up a TransformComposition:

TransformComposition.n_transforms

[Get] The number of individual transformations in the composition.

TransformComposition.get_transform(index)

Get the individual transformation at the specified index in the composition.

TransformComposition.get_transforms()

Get the list of individual transformations in the composition.

Modified methods of TransformComposition objects#

The following methods are modified for TransformComposition objects to handle the composition of multiple transformations:

TransformComposition.copy()

Create a copy of the TransformComposition object by copying each of the individual transformations in the composition.

TransformComposition.from_dict(data)

Create a TransformComposition object from a dictionary.

TransformComposition.to_dict()

Serialize the transformation composition to a dictionary.

TransformComposition.__repr__()

String representation of the Transform class.

Performing transformations with TransformComposition objects#

TransformComposition._transform(points, *[, ...])

Apply the composed transformation to the given points.

TransformComposition._inverse_transform(...)

Apply the inverse of the composed transformation to the given points.