drtk.transform#

transform

Projects 3D vertex positions onto the image plane of the camera.

transform_with_v_cam

Same as transform, but also returns the camera-space coordinates.

drtk.transform(v, campos=None, camrot=None, focal=None, princpt=None, K=None, Rt=None, distortion_mode=None, distortion_coeff=None, fov=None)[source]#

Projects 3D vertex positions onto the image plane of the camera.

Parameters:
  • v (th.Tensor) – vertex positions. N x V x 3

  • campos (Tensor) – Camera position. N x 3

  • camrot (Tensor) – Camera rotation matrix. N x 3 x 3

  • focal (Tensor) – Focal length. The upper left 2x2 block of the intrinsic matrix [[f_x, s], [0, f_y]]. N x 2 x 2

  • princpt (Tensor) – Camera principal point [cx, cy]. N x 2

  • K (Tensor) – Camera intrinsic calibration matrix, N x 3 x 3

  • Rt (Tensor) – Camera extrinsic matrix. N x 3 x 4 or N x 4 x 4

  • distortion_mode (List[str]) – Names of the distortion modes.

  • distortion_coeff (Tensor) – Distortion coefficients. N x 4

  • fov (Tensor) – Valid field of view of the distortion model. N x 1

Returns:

Vertex positions projected onto the image plane of the camera. The last dimension has still size 3. The first two components are the x and y coordinates on the image plane, and the z is z component of the vertex positions in the camera frame. The latter is used for depth values that are written to the z-buffer. N x V x 3

Warning

You must specify either K (intrinsic matrix) or both focal and princpt (focal length and principal point).

Additionally, you must provide either Rt (extrinsic matrix) or both campos (camera position) and camrot (camera rotation).

Note

If we split Rt of shape N x 3 x 4 into R of shape N x 3 x 3 and t of shape N x 3 x 1, then: camrot is R, and campos is -R.T @ t.

drtk.transform_with_v_cam(v, campos=None, camrot=None, focal=None, princpt=None, K=None, Rt=None, distortion_mode=None, distortion_coeff=None, fov=None)[source]#

Same as transform, but also returns the camera-space coordinates. In most cases it is not needed, but renderlayer depends on it