pycvcam.core.TransformResult#

class TransformResult(transformed_points, jacobian_dx=None, jacobian_dp=None, transpose=False)[source]#

Bases: object

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

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 transpose is 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:

numpy.ndarray

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:

bool

Jacobians Short-hand Notations#

Short-hand notations for the Jacobian matrices can be added to the TransformResult class using the add_jacobian() method. This allows adding custom views of the jacobian_dp matrix 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 TransformResult class to provide more convenient access to the transformed points, depending on the context of the transformation, via the add_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 x is an alias for the transformed points, but additional aliases can be added using the add_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 TransformResult object.

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_dp matrix to the TransformResult object.

This method allows to add custom views of the jacobian_dp matrix with respect to the parameters of the transformation. The custom Jacobian can be accessed using the name attribute.

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 TransformResult object.

property x#

Alias for the transformed points.