Data Class TransformResult#
- class TransformResult(transformed_points, jacobian_dx=None, jacobian_dp=None, transpose=False)[source]#
A class to represent the result of a transformation.
This class is used to store the results of a transformation, including the transformed points and the Jacobian matrices.
See also
pycvcam.Transformfor the base class of all transformations.pycvcam.Transform.transform()for applying the transformation to points.pycvcam.Transform.inverse_transform()for applying the inverse transformation to points (output_dimandinput_dimare swapped).
For a transformation from \(\mathbb{R}^{\text{input dim}}\) to \(\mathbb{R}^{\text{output dim}}\), the input points are assumed to have shape (…, input_dim) and the output points will have shape (…, output_dim).
The Jacobian matrices are computed with respect to the input points and the parameters of the transformation:
The Jacobian with respect to the input points has shape (…, output_dim, input_dim).
The Jacobian with respect to the parameters has shape (…, output_dim, n_params), where n_params is the number of parameters of the transformation.
Note
If
transposeis set to True during the transformation, the output points will have shape (output_dim, …) instead of (…, output_dim), same for the Jacobian matrices (ie. shape (output_dim, …, input_dim) and (output_dim, …, n_params) respectively).- Parameters:
- transformed_points#
The transformed points after applying the transformation. Can be accessed using the
xalias. Shape (…, output_dim).- Type:
- jacobian_dx#
The Jacobian matrix with respect to the input points. Can be None if not computed and accessed using the
dxalias. Shape (…, output_dim, input_dim).- Type:
Optional[numpy.ndarray]
- jacobian_dp#
The Jacobian matrix with respect to the parameters of the transformation. Can be None if not computed and accessed using the
dpalias. Shape (…, output_dim, n_params).- Type:
Optional[numpy.ndarray]
- transpose#
If True, the output points and Jacobian matrices will have shape (output_dim, …) instead of (…, output_dim). True if set during the transformation, otherwise False.
- Type:
Jacobians Short-hand Notations#
Short-hand notations for the Jacobian matrices can be added to the
TransformResultclass using theadd_jacobian()method. This allows adding custom views of thejacobian_dpmatrix with respect to the parameters of the transformation.result = TransformResult(transformed_points, jacobian_dx, jacobian_dp) result.add_jacobian("dk", start=0, end=2, doc="Custom Jacobian view for the first two parameters related to k1 and k2") result.jacobian_dk # Returns a view of the jacobian_dp matrix for parameters k1 and k2, i.e., jacobian_dp[..., 0:2]
Aliases for Transformed Points#
Aliases can be added to the
TransformResultclass to provide more convenient access to the transformed points, depending on the context of the transformation, via theadd_alias()method.result = TransformResult(transformed_points, jacobian_dx, jacobian_dp) result.add_alias("image_points") result.image_points # Returns the transformed_points array
By default
xis an alias for the transformed points, but additional aliases can be added using theadd_alias()method. This allows to access the transformed points using a more convenient name depending on the context of the transformation (e.g., “image_points” for transformations related to image processing, “world_points” for transformations related to 3D world coordinates, etc.).