calibration
Rigid transforms with camera calibration matrices
An X-ray C-arm can be modeled as a pinhole camera with its own extrinsic and intrinsic matrices. This module provides utilities for parsing these matrices and working with rigid transforms.
Rigid transformations
We represent rigid transforms as \(4 \times 4\) matrices (following the right-handed convention of PyTorch3D
),
\[\begin{equation} \begin{bmatrix} \mathbf R^T & \mathbf 0 \\ \mathbf t^T & 1 \end{bmatrix} \in \mathbf{SE}(3) \,, \end{equation}\]
where \(\mathbf R \in \mathbf{SO}(3)\) is a rotation matrix and \(\mathbf t\in \mathbb R^3\) represents a translation.
Note that since rotation matrices are orthogonal, we have a simple closed-form equation for the inverse: \[\begin{equation} \begin{bmatrix} \mathbf R^T & \mathbf 0 \\ \mathbf t^T & 1 \end{bmatrix}^{-1} = \begin{bmatrix} \mathbf R & \mathbf 0 \\ -\mathbf R \mathbf t & 1 \end{bmatrix} \,. \end{equation}\]
For convenience, we add a wrapper of pytorch3d.transforms.Transform3d
that can be construced from a (batched) rotation matrix and translation vector. This module also includes the closed-form inverse specific to rigid transforms.
RigidTransform
RigidTransform (R:jaxtyping.Float[Tensor,'...'], t:jaxtyping.Float[Tensor,'...3'], parameterization:str='matrix', convention:Optional[str]=None, device=None, dtype=torch.float32)
Wrapper of pytorch3d.transforms.Transform3d with extra functionalities.
convert
convert (transform, input_parameterization, output_parameterization, input_convention=None, output_convention=None)
Convert between representations of SE(3).
Computing a perspective projection
Given an extrinsic
and intrinsic
camera matrix, we can compute the perspective projection of a batch of points. This is used for computing where fiducials in world coordinates get mapped onto the image plane.
perspective_projection
perspective_projection (extrinsic:__main__.RigidTransform, intrinsic:jaxtyping.Float[Tensor,'33'], x:jaxtyping.Float[Tensor,'bn3'])
Type | Details | |
---|---|---|
extrinsic | RigidTransform | Extrinsic camera matrix (world to camera) |
intrinsic | Float[Tensor, ‘3 3’] | Intrinsic camera matrix (camera to image) |
x | Float[Tensor, ‘b n 3’] | World coordinates |
Returns | Float[Tensor, ‘b n 2’] |