pysdic.Camera.project#

Camera.project(world_points, *, dx=False, dextrinsic=False, ddistortion=False, dintrinsic=False)[source]#

Project world points to 2D images points using the camera’s extrinsic, distortion and intrinsic transformations.

This method calls pysdic.project_points().

Note

The output are the image points in the image coordinate system \((x, y)\) and not the pixel points (rows, columns).

Important

The Jacobian with respect to the parameters is computed for all the transformations at once (jacobian_dp). The blocks of the transformations that are not requested (e.g. jacobian_ddistortion if ddistortion=False while dextrinsic=True) are filled with NaN. If no Jacobian with respect to the parameters is requested, jacobian_dp and its blocks are None.

See also

Parameters:
  • world_points (Union[ArrayLike, pysdic.PointCloud, pysdic.Mesh]) – An array of shape \((..., E)\) representing the points in the world coordinate system, with \(E\) the input dimension of the camera. For a point cloud or a mesh, the coordinates of the points or vertices are used.

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

  • dextrinsic (bool, optional (default: False)) – If True, compute the jacobian of the image points with respect to the extrinsic parameters.

  • ddistortion (bool, optional (default: False)) – If True, compute the jacobian of the image points with respect to the distortion parameters.

  • dintrinsic (bool, optional (default: False)) – If True, compute the jacobian of the image points with respect to the intrinsic parameters.

Returns:

The projection result:

  • image_points: shape \((..., 2)\), the image points \((x, y)\).

  • jacobian_dx: shape \((..., 2, E)\) if dx is True.

  • jacobian_dextrinsic: shape \((..., 2, N_e)\).

  • jacobian_ddistortion: shape \((..., 2, N_d)\).

  • jacobian_dintrinsic: shape \((..., 2, N_i)\).

  • jacobian_dp: shape \((..., 2, N_e + N_d + N_i)\), the three blocks above in this order.

Return type:

pysdic.ProjectionResult

Examples

Lets create a simple camera and project some 3D points:

import numpy
from pysdic import Camera, PerspectiveExtrinsic, PinholeIntrinsic

extrinsic = PerspectiveExtrinsic.from_rt(rvec=[0.1, 0.2, 0.3], tvec=[12.0, 34.0, 56.0])
intrinsic = PinholeIntrinsic.from_matrix([[1000.0, 0.0, 320.0],
                                          [0.0, 1000.0, 240.0],
                                          [0.0, 0.0, 1.0]])

camera = Camera(480, 640, intrinsic=intrinsic, extrinsic=extrinsic)

world_points = numpy.array([
    [0, 0, 1000],
    [100, 0, 1000],
    [0, 100, 1000],
    [100, 100, 1000]
])

result = camera.project(world_points, dx=True, dintrinsic=True, dextrinsic=True)

result.image_points         # shape (4, 2)
result.jacobian_dx          # shape (4, 2, 3)
result.jacobian_dintrinsic  # shape (4, 2, N_i)
result.jacobian_dextrinsic  # shape (4, 2, N_e)