Batch3D

class lib.align.pose.Batch3D

Bases: object

Functions to perform 3D space calculations on batches

Methods Summary

get_offsets(centering, rotation_vectors, ...)

Obtain the offset for moving normalized 68 point landmarks from legacy centering

pitch(vectors)

Obtain the pitch, in degrees, for a batch of rotation matrices

project_points(points, rotation_vectors, ...)

Batch protection of points from 3D space to 2D space

rodrigues(vectors)

Perform batch conversion of rotation vectors to rotation matrices

roll(vectors)

Obtain the roll, in degrees, for a batch of rotation matrices

solve_pnp(landmarks)

Estimate rotation and translation from a mean 3D head model

yaw(vectors)

Obtain the yaw, in degrees, for a batch of rotation matrices

Methods Documentation

classmethod get_offsets(centering: CenteringType, rotation_vectors: npt.NDArray[np.float32], translation_vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the offset for moving normalized 68 point landmarks from legacy centering

Parameters:
  • centering (CenteringType) – The centering type to obtain the offset for

  • rotation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) batch of rotation vectors to receive offsets for

  • translation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) batch of translation vectors to receive offsets for

Return type:

The (N, 2) offsets for the given rotation/translation vector

classmethod pitch(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the pitch, in degrees, for a batch of rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, ) pitch, in degrees

classmethod project_points(points: npt.NDArray[np.float32], rotation_vectors: npt.NDArray[np.float32], translation_vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Batch protection of points from 3D space to 2D space

Parameters:
  • points (npt.NDArray[np.float32]) – The (N, M, 3) points to project

  • rotation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors for projection

  • translation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) translation vectors for projection

Return type:

The (N, M, 2) projected points in 2D space

classmethod rodrigues(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Perform batch conversion of rotation vectors to rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, 3, 3) rotation matrices

classmethod roll(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the roll, in degrees, for a batch of rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, ) rolls, in degrees

classmethod solve_pnp(landmarks: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Estimate rotation and translation from a mean 3D head model

Parameters:

landmarks (npt.NDArray[np.float32]) – The (N, 68, 2) 2D normalized landmark points to obtain the rotation and translation vectors for

Returns:

  • The rotation and translation vectors for the given landmarks in format

  • ```

  • (rotation, N, 3, 1 – translation, N, 3, 1)

  • ```

Return type:

npt.NDArray[np.float32]

classmethod yaw(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the yaw, in degrees, for a batch of rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, ) yaw, in degrees

classmethod get_offsets(centering: CenteringType, rotation_vectors: npt.NDArray[np.float32], translation_vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the offset for moving normalized 68 point landmarks from legacy centering

Parameters:
  • centering (CenteringType) – The centering type to obtain the offset for

  • rotation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) batch of rotation vectors to receive offsets for

  • translation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) batch of translation vectors to receive offsets for

Return type:

The (N, 2) offsets for the given rotation/translation vector

classmethod pitch(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the pitch, in degrees, for a batch of rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, ) pitch, in degrees

classmethod project_points(points: npt.NDArray[np.float32], rotation_vectors: npt.NDArray[np.float32], translation_vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Batch protection of points from 3D space to 2D space

Parameters:
  • points (npt.NDArray[np.float32]) – The (N, M, 3) points to project

  • rotation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors for projection

  • translation_vectors (npt.NDArray[np.float32]) – The (N, 3, 1) translation vectors for projection

Return type:

The (N, M, 2) projected points in 2D space

classmethod rodrigues(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Perform batch conversion of rotation vectors to rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, 3, 3) rotation matrices

classmethod roll(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the roll, in degrees, for a batch of rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, ) rolls, in degrees

classmethod solve_pnp(landmarks: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Estimate rotation and translation from a mean 3D head model

Parameters:

landmarks (npt.NDArray[np.float32]) – The (N, 68, 2) 2D normalized landmark points to obtain the rotation and translation vectors for

Returns:

  • The rotation and translation vectors for the given landmarks in format

  • ```

  • (rotation, N, 3, 1 – translation, N, 3, 1)

  • ```

Return type:

npt.NDArray[np.float32]

classmethod yaw(vectors: npt.NDArray[np.float32]) npt.NDArray[np.float32]

Obtain the yaw, in degrees, for a batch of rotation matrices

Parameters:

vectors (npt.NDArray[np.float32]) – The (N, 3, 1) rotation vectors to convert

Return type:

The (N, ) yaw, in degrees