pysdic.project_points#

project_points(world_points, intrinsic, distortion, extrinsic, *, dx=False, dp=False, bypass_dp=None, intrinsic_kwargs=None, distortion_kwargs=None, extrinsic_kwargs=None)[source]#

Project world points \(\vec{X}_w\) to 2D image points \(\vec{x}_i\) using the camera extrinsic, distortion and intrinsic transformations.

\[\begin{split}\vec{x}_n &= \text{Extrinsic}(\vec{X}_w) \\ \vec{x}_d &= \text{Distortion}(\vec{x}_n) \\ \vec{x}_i &= \text{Intrinsic}(\vec{x}_d)\end{split}\]

Where:

  • \(\vec{X}_w\) are the world points (3D, or 2D for planar problems) in the world coordinate system.

  • \(\vec{x}_n\) are the 2D normalized points in the normalized coordinate system.

  • \(\vec{x}_d\) are the 2D distorted points in the normalized coordinate system.

  • \(\vec{x}_i\) are the 2D image points in the image coordinate system.

Note

The image points can be then converted to pixel coordinates \((u, v)\) by applying a swap of the axes.

The projection is computed with the composition \(T = \text{Intrinsic} \circ \text{Distortion} \circ \text{Extrinsic}\) (see pysdic.compose_projection()), and the Jacobians are obtained with the chain rule:

\[\frac{\partial \vec{x}_i}{\partial \vec{X}_w} = J_i \, J_d \, \frac{\partial \vec{x}_n}{\partial \vec{X}_w}, \qquad \frac{\partial \vec{x}_i}{\partial \vec{p}} = \begin{bmatrix} J_i \, J_d \, \frac{\partial \vec{x}_n}{\partial \vec{p}_e} & J_i \, \frac{\partial \vec{x}_d}{\partial \vec{p}_d} & \frac{\partial \vec{x}_i}{\partial \vec{p}_i} \end{bmatrix}\]

with \(J_d = \frac{\partial \vec{x}_d}{\partial \vec{x}_n}\) and \(J_i = \frac{\partial \vec{x}_i}{\partial \vec{x}_d}\).

The Jacobians can be accessed with the following attributes of the result:

  • jacobian_dx: The Jacobian of the image points with respect to the world points. Shape \((\dots, 2, n_w)\).

  • jacobian_dp: The Jacobian of the image points with respect to all the parameters. Shape \((\dots, 2, N_e + N_d + N_i)\).

  • jacobian_dextrinsic: View of jacobian_dp[..., :N_e] for the extrinsic parameters.

  • jacobian_ddistortion: View of jacobian_dp[..., N_e:N_e + N_d] for the distortion parameters.

  • jacobian_dintrinsic: View of jacobian_dp[..., N_e + N_d:] for the intrinsic parameters.

See also

Parameters:
  • world_points (ArrayLike) – The world points with shape \((\dots, n_w)\), with \(n_w = 3\) (or \(n_w = 2\) for planar problems).

  • intrinsic (Optional[Transformation]) – The intrinsic transformation to be applied to the distorted points. If None, pysdic.NoIntrinsic is used (identity).

  • distortion (Optional[Transformation]) – The distortion transformation to be applied to the normalized points. If None, pysdic.NoDistortion is used (identity).

  • extrinsic (Optional[Transformation]) – The extrinsic transformation to be applied to the world points. If None, pysdic.NoExtrinsic is used with the dimension of the world points.

  • dx (bool, optional (default: False)) – If True, compute the Jacobian of the image points with respect to the world points.

  • dp (bool, optional (default: False)) – If True, compute the Jacobian of the image points with respect to the parameters of the extrinsic, distortion and intrinsic transformations.

  • bypass_dp (Optional[Sequence[bool]], optional (default: None)) – Three booleans for the extrinsic, distortion and intrinsic transformations (in this order). If dp=True, the Jacobian with respect to the parameters of the transformations with True is not computed and its columns in jacobian_dp are filled with NaN, which saves computations when only some parameters are needed. If None, all the Jacobians are computed. For example, bypass_dp=(False, True, True) only computes jacobian_dextrinsic.

  • intrinsic_kwargs (Optional[Dict[str, Any]], optional (default: None)) – Additional keyword arguments passed to the apply method of the intrinsic transformation.

  • distortion_kwargs (Optional[Dict[str, Any]], optional (default: None)) – Additional keyword arguments passed to the apply method of the distortion transformation.

  • extrinsic_kwargs (Optional[Dict[str, Any]], optional (default: None)) – Additional keyword arguments passed to the apply method of the extrinsic transformation.

Returns:

The image points (x or image_points) with shape \((\dots, 2)\) and the Jacobians if requested.

Return type:

pysdic.ProjectionResult