pycvcam.core.TransformResult#
- class TransformResult(transformed_points, jacobian_dx=None, jacobian_dp=None, transpose=False)[source]#
Bases:
objectA 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.core.Transformfor the base class of all transformations.pycvcam.core.Transform.transform()for applying the transformation to points.pycvcam.core.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. Shape (…, output_dim).
- Type:
- jacobian_dx#
The Jacobian matrix with respect to the input points. Shape (…, output_dim, input_dim).
- Type:
Optional[numpy.ndarray]
- jacobian_dp#
The Jacobian matrix with respect to the parameters of the transformation. 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.).- add_alias(name)[source]#
Add an alias for the transformed points in the
TransformResultobject.This method allows to add an alias for the transformed points, which can be used to access the transformed points using a more convenient name.
- Parameters:
name (str) – The name of the alias to add.
- Return type:
None
- add_jacobian(name, start, end, doc=None)[source]#
Add a custom view of the
jacobian_dpmatrix to theTransformResultobject.This method allows to add custom views of the
jacobian_dpmatrix with respect to the parameters of the transformation. The custom Jacobian can be accessed using thenameattribute.- Parameters:
name (str) – The name of the custom Jacobian view.
start (int) – The starting index of the parameters to include in the custom Jacobian view.
end (int) – The ending index of the parameters to include in the custom Jacobian view.
doc (Optional[str], optional) – A documentation string for the custom Jacobian view. Default is None.
- Return type:
None
- print_help()[source]#
Print the descriptions of the properties and custom Jacobian views.
This method prints the names and documentation strings of the custom Jacobian views added to the
TransformResultobject.
- property x#
Alias for the transformed points.