pysdic.WorldPlanePerspectiveExtrinsic#

WorldPlanePerspectiveExtrinsic class#

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

Bases: WorldPlaneRigidExtrinsic

Subclass of pysdic.WorldPlaneRigidExtrinsic implementing a perspective camera observing the world plane \(Z_w = 0\).

The 2D world points are transformed into the camera coordinate system by \(\vec{X}_c = A \vec{x}_w + T\) (see pysdic.WorldPlaneRigidExtrinsic), and the normalized point is obtained by perspective division:

\[\begin{split}\vec{x}_n = \frac{1}{Z_c} \begin{bmatrix} X_c \\ Y_c \end{bmatrix}\end{split}\]

In homogeneous coordinates, it is the plane-induced homography:

\[\begin{split}\begin{bmatrix} \vec{x}_n \\ 1 \end{bmatrix} \sim H \begin{bmatrix} \vec{x}_w \\ 1 \end{bmatrix} \quad \text{with} \quad H = \begin{bmatrix} \vec{r}_1 & \vec{r}_2 & T \end{bmatrix}\end{split}\]

The transformation is a bijection between the part of the plane in front of the camera (\(Z_c > 0\)) and the normalized points whose ray hits the plane in front of the camera. The points behind the camera are rejected by apply and invert.

See also

Parameters:

parameters (Optional[ArrayLike], optional (default: None)) – The extrinsic parameters as a 1D array of shape (6,). The first 3 elements represent the rotation vector \(\vec{r} = (r_x, r_y, r_z)\). The last 3 elements represent the translation vector \(T = (t_x, t_y, t_z)\).

Examples

A camera located 5 units above the plane and looking at it perpendicularly:

extrinsic = WorldPlanePerspectiveExtrinsic.from_rt(
    rvec=[0.0, 0.0, 0.0],
    tvec=[0.0, 0.0, 5.0],
)

extrinsic.apply([[1.0, 2.0]]).x          # array([[0.2, 0.4]])
extrinsic.invert([[0.2, 0.4]]).x         # array([[1., 2.]])

Instantiation#

The WorldPlanePerspectiveExtrinsic class can be instantiated in three ways:

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

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

  • From a frame of reference using the classmethod from_frame().

WorldPlanePerspectiveExtrinsic.from_frame(frame)

Create an extrinsic transformation from a 3D frame (convention 4).

WorldPlanePerspectiveExtrinsic.from_rt(rvec, ...)

Create an extrinsic transformation from a rotation vector and a translation vector.

WorldPlanePerspectiveExtrinsic.from_tmatrix(tmatrix)

Create an extrinsic transformation from a 4x4 transformation matrix.

Implemented methods and attributes#

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

Attributes#

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

  • parameters: returns a vector of extrinsic parameters [rvec, tvec].

The pysdic.WorldPlanePerspectiveExtrinsic defines the following attributes:

WorldPlanePerspectiveExtrinsic.frame

[Get/Set] the 3D frame of the extrinsic transformation.

WorldPlanePerspectiveExtrinsic.homography_matrix

[Get] the 3x3 plane-induced homography \(H = [\vec{r}_1, \vec{r}_2, T]\) between the world plane and the normalized plane.

WorldPlanePerspectiveExtrinsic.rotation_matrix

[Get/Set] the rotation matrix \(R\) of the extrinsic transformation.

WorldPlanePerspectiveExtrinsic.rotation_vector

[Get/Set] the rotation vector \(\vec{r}\) of the camera.

WorldPlanePerspectiveExtrinsic.transformation_matrix

[Get/Set] the 4x4 transformation matrix of the extrinsic transformation.

WorldPlanePerspectiveExtrinsic.translation_vector

[Get/Set] the translation vector \(T\) of the camera.

Performing Projections#

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

  • apply: maps world_points (2D points of the plane \(Z_w = 0\)) → normalized_points.

  • invert: maps normalized_points → world_points (intersection of the rays with the plane \(Z_w = 0\), no depth needed).

  • compute_rays: maps normalized_points → rays (origins and unit directions in 3D world coordinates).

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

WorldPlanePerspectiveExtrinsic._apply(...[, ...])

Compute the transformation from 2D world points of the plane \(Z_w = 0\) to 2D normalized points.

WorldPlanePerspectiveExtrinsic._invert(...)

Compute the inverse transformation from 2D normalized points to 2D world points of the plane \(Z_w = 0\) (intersection of the camera rays with the plane).

WorldPlanePerspectiveExtrinsic.compute_rays(...)

Compute the rays of the camera passing through the given normalized points.