kornia.geometry.linalg

relative_transformation(trans_01: torch.Tensor, trans_02: torch.Tensor) → torch.Tensor[source]

Function that computes the relative homogenous transformation from a reference transformation \(T_1^{0} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}\) to destination \(T_2^{0} = \begin{bmatrix} R_2 & t_2 \\ \mathbf{0} & 1 \end{bmatrix}\).

The relative transformation is computed as follows:

\[T_1^{2} = (T_0^{1})^{-1} \cdot T_0^{2}\]
Parameters:
  • trans_01 (torch.Tensor) – reference transformation tensor of shape \((N, 4, 4)\) or \((4, 4)\).
  • trans_02 (torch.Tensor) – destination transformation tensor of shape \((N, 4, 4)\) or \((4, 4)\).
Shape:
  • Output: \((N, 4, 4)\) or \((4, 4)\).
Returns:the relative transformation between the transformations.
Return type:torch.Tensor
Example::
>>> trans_01 = torch.eye(4)  # 4x4
>>> trans_02 = torch.eye(4)  # 4x4
>>> trans_12 = kornia.relative_transformation(trans_01, trans_02)  # 4x4
compose_transformations(trans_01: torch.Tensor, trans_12: torch.Tensor) → torch.Tensor[source]

Functions that composes two homogeneous transformations.

\[\begin{split}T_0^{2} = \begin{bmatrix} R_0^1 R_1^{2} & R_0^{1} t_1^{2} + t_0^{1} \\ \mathbf{0} & 1\end{bmatrix}\end{split}\]
Parameters:
  • trans_01 (torch.Tensor) – tensor with the homogenous transformation from a reference frame 1 respect to a frame 0. The tensor has must have a shape of \((B, 4, 4)\) or \((4, 4)\).
  • trans_12 (torch.Tensor) – tensor with the homogenous transformation from a reference frame 2 respect to a frame 1. The tensor has must have a shape of \((B, 4, 4)\) or \((4, 4)\).
Shape:
  • Output: \((N, 4, 4)\) or \((4, 4)\)
Returns:the transformation between the two frames.
Return type:torch.Tensor
Example::
>>> trans_01 = torch.eye(4)  # 4x4
>>> trans_12 = torch.eye(4)  # 4x4
>>> trans_02 = kornia.compose_transformations(trans_01, trans_12)  # 4x4
inverse_transformation(trans_12)[source]

Function that inverts a 4x4 homogeneous transformation \(T_1^{2} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}\)

The inverse transformation is computed as follows:

\[\begin{split}T_2^{1} = (T_1^{2})^{-1} = \begin{bmatrix} R_1^T & -R_1^T t_1 \\ \mathbf{0} & 1\end{bmatrix}\end{split}\]
Parameters:trans_12 (torch.Tensor) – transformation tensor of shape \((N, 4, 4)\) or \((4, 4)\).
Returns:tensor with inverted transformations.
Return type:torch.Tensor
Shape:
  • Output: \((N, 4, 4)\) or \((4, 4)\)

Example

>>> trans_12 = torch.rand(1, 4, 4)  # Nx4x4
>>> trans_21 = kornia.inverse_transformation(trans_12)  # Nx4x4
transform_points(trans_01: torch.Tensor, points_1: torch.Tensor) → torch.Tensor[source]

Function that applies transformations to a set of points.

Parameters:
  • trans_01 (torch.Tensor) – tensor for transformations of shape \((B, D+1, D+1)\).
  • points_1 (torch.Tensor) – tensor of points of shape \((B, N, D)\).
Returns:

tensor of N-dimensional points.

Return type:

torch.Tensor

Shape:
  • Output: \((B, N, D)\)

Examples

>>> points_1 = torch.rand(2, 4, 3)  # BxNx3
>>> trans_01 = torch.eye(4).view(1, 4, 4)  # Bx4x4
>>> points_0 = kornia.transform_points(trans_01, points_1)  # BxNx3