pysdic.PlanarRigidExtrinsic#

PlanarRigidExtrinsic class#

class PlanarRigidExtrinsic(*args, **kwargs)[source]#

Bases: Transformation

Subclass of pysdic.Transformation implementing a planar rigid motion (rotation and translation in 2D).

This class represents an extrinsic transformation in 2D, used to run the camera algorithms on planar problems. It transforms 2D world points into 2D normalized points, without projection:

world_points → normalized_points → distorted_points → image_points

Given a world point \(\vec{x}_w = (x_w, y_w)^T\), the corresponding point in the normalized coordinate system is:

\[\vec{x}_n = R(\theta) \cdot \vec{x}_w + \vec{t}\]

where:

\[\begin{split}R(\theta) = \begin{bmatrix} \cos(\theta) & -\sin(\theta) \\ \sin(\theta) & \cos(\theta) \end{bmatrix}, \qquad \vec{t} = \begin{bmatrix} t_x \\ t_y \end{bmatrix}\end{split}\]

The transformation is parameterized by 3 parameters \((\theta, t_x, t_y)\), with \(\theta\) the rotation angle in radians. It is a bijection of the plane, and the inverse transformation is \(\vec{x}_w = R(\theta)^T \cdot (\vec{x}_n - \vec{t})\).

See also

  • Class pysdic.RigidExtrinsic for the rigid motions of 3D world points with a projection.

  • Class pysdic.WorldPlaneRigidExtrinsic for the plane \(Z_w = 0\) observed by a camera with a 3D pose.

  • Class pysdic.PlanarHomographicExtrinsic for the projective transformations of the plane.

Note

The class can be instantiated in three ways:

  • providing the parameters directly as a numpy array of shape (3,).

  • using the from_rt() class method with a rotation angle and a translation vector.

  • using the from_tmatrix() class method with a 3x3 homogeneous transformation matrix.

Parameters:

parameters (Optional[ArrayLike], optional (default: None)) – The extrinsic parameters as a 1D array of shape (3,) ordered as \((\theta, t_x, t_y)\), where \(\theta\) is the rotation angle in radians and \((t_x, t_y)\) is the translation vector.

Examples

A rotation of 90° followed by a translation along \(x\):

extrinsic = PlanarRigidExtrinsic.from_rt(theta=numpy.pi / 2, tvec=[1.0, 0.0])

extrinsic.apply([[1.0, 0.0]]).x      # array([[1., 1.]])
extrinsic.invert([[1.0, 1.0]]).x     # array([[1., 0.]])

Instantiation#

The PlanarRigidExtrinsic class can be instantiated in two ways:

  • From a rotation angle and a translation vector using the classmethod from_rt().

  • From a 3×3 homogeneous transformation matrix using the classmethod from_tmatrix().

PlanarRigidExtrinsic.from_rt(theta, tvec)

Create a pysdic.PlanarRigidExtrinsic from a rotation angle and a translation vector.

PlanarRigidExtrinsic.from_tmatrix(tmatrix)

Create a pysdic.PlanarRigidExtrinsic from a 3x3 homogeneous transformation matrix.

Implemented methods and attributes#

The following sections provide an overview of the attributes and methods defined in the pysdic.PlanarRigidExtrinsic class.

Attributes#

The extrinsic parameters can be accessed via the base class pysdic.Transformation:

  • parameters: returns a vector of extrinsic parameters [theta, t_x, t_y].

The pysdic.PlanarRigidExtrinsic defines the following attributes:

PlanarRigidExtrinsic.rotation_angle

[Get/Set] the rotation angle \(\theta\) in radians.

PlanarRigidExtrinsic.rotation_matrix

[Get/Set] the 2D rotation matrix \(R(\theta)\).

PlanarRigidExtrinsic.transformation_matrix

[Get/Set] the 3x3 homogeneous transformation matrix.

PlanarRigidExtrinsic.translation_vector

[Get/Set] the translation vector \(\vec{t} = (t_x, t_y)\).

Performing Projections#

Use the apply and invert methods from pysdic.Transformation to perform extrinsic projections:

  • apply: maps world_points (2D) → normalized_points.

  • invert: maps normalized_points → world_points (2D).

Jacobians with respect to the input points and extrinsic parameters can be computed by enabling the dx and dp flags:

  • dx=True: compute ∂normalized_points / ∂world_points

  • dp=True: compute ∂normalized_points / ∂extrinsic_parameters

PlanarRigidExtrinsic._apply(world_points, *)

Compute the transformation from 2D world points to 2D normalized points.

PlanarRigidExtrinsic._invert(...[, dx, dp])

Compute the inverse transformation from 2D normalized points to 2D world points.