pysdic.OrthographicExtrinsic#

OrthographicExtrinsic class#

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

Bases: RigidExtrinsic

Subclass of pysdic.RigidExtrinsic implementing the orthographic extrinsic camera model.

The world points are first transformed into the camera coordinate system by the rigid motion \(\vec{X}_c = R \cdot \vec{X}_w + T\) (see pysdic.RigidExtrinsic).

The normalized point is then obtained by orthographic projection, i.e. by dropping the depth \(Z_c\):

\[\vec{x}_n = (X_c, Y_c)^T\]

The transformation is parameterized by 6 parameters \((r_x, r_y, r_z, t_x, t_y, t_z)\).

Since the depth is lost by the projection, the inverse transformation needs the depth \(Z_c\) of the points in the camera coordinate system (see _invert()). It is a right inverse (\(T(T^{-1}(\vec{x}_n)) = \vec{x}_n\) for any depth) but not a left inverse.

See also

  • Class pysdic.RigidExtrinsic for the rigid motion, its parameters and accessors (rvec, tvec, rmat, tmatrix, frame) and the construction methods.

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 rotated by 90° around the \(z\) axis and translated along \(x\):

extrinsic = OrthographicExtrinsic.from_rt(
    rvec=[0.0, 0.0, numpy.pi / 2],
    tvec=[1.0, 0.0, 5.0],
)

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

Instantiation#

The OrthographicExtrinsic 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().

OrthographicExtrinsic.from_frame(frame)

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

OrthographicExtrinsic.from_rt(rvec, tvec)

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

OrthographicExtrinsic.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.OrthographicExtrinsic 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.OrthographicExtrinsic defines the following attributes:

OrthographicExtrinsic.frame

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

OrthographicExtrinsic.rotation_matrix

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

OrthographicExtrinsic.rotation_vector

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

OrthographicExtrinsic.transformation_matrix

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

OrthographicExtrinsic.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 → normalized_points.

  • invert: maps normalized_points → world_points (at the depth given by the depth argument).

  • compute_rays: maps normalized_points → rays (origins and unit directions in 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

OrthographicExtrinsic._apply(world_points, *)

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

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

Compute the inverse transformation from 2D normalized points to 3D world points at a given depth.

OrthographicExtrinsic.compute_rays(...)

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