Projection functions#
Project world-space vertices to DRTK pixel coordinates. |
|
Apply the pinhole projection Jacobian to world-space vertex deltas. |
- drtk.utils.projection.project_points(v, campos, camrot, focal, princpt, distortion_mode=None, distortion_coeff=None, fov=None, lut_vector_field=None, lut_spacing=None)[source]#
Project world-space vertices to DRTK pixel coordinates.
The world-to-camera convention is
v_cam = camrot @ (v - campos).v_pixstores pixelx, yfollowed by camera-spacezso it can be passed directly todrtk.rasterize(). Vertices withz <= 0are behind the camera and are rejected by rasterization.distortion_modemay beNone/"pinhole","radial-tangential","fisheye","fisheye62", or"fisheye62_lut". A per-batch list of modes is supported for pinhole, radial-tangential, and fisheye batches; Fisheye62 modes are currently supported only whendistortion_modeis a single string. For Fisheye62 withfov, vertices outside the valid radius getz = -1so any triangle touching them is culled by the rasterizer.- Parameters:
v – World-space vertices with shape
(N, V, 3).campos – Camera positions with shape
(N, 3).camrot – World-to-camera rotation matrices with shape
(N, 3, 3).focal – Camera intrinsic matrices with shape
(N, 2, 2).princpt – Principal points in pixels with shape
(N, 2).distortion_mode – Optional distortion mode string or per-batch list of mode strings.
distortion_coeff – Distortion coefficients. Shape depends on
distortion_mode.fov – Optional maximum normalized radius with shape
(N, 1).lut_vector_field – Optional Fisheye62 LUT offset field with shape
(N, 2, H_lut, W_lut).lut_spacing – Optional Fisheye62 LUT spacing with shape
(N, 2).
- Returns:
(v_pix, v_cam). Both tensors have shape(N, V, 3).v_pixstores(x_pixels, y_pixels, z_camera).
- drtk.utils.projection.project_points_grad(v_grad, v, campos, camrot, focal, distortion_mode=None, distortion_coeff=None)[source]#
Apply the pinhole projection Jacobian to world-space vertex deltas.
This computes
d project_points(v) / d v @ v_gradfor the undistorted pinhole projection path. Distortion gradients are not implemented here; passdistortion_mode=None.- Parameters:
v_grad – World-space vertex perturbations with shape
(N, V, 3).v – World-space vertices with shape
(N, V, 3).campos – Camera positions with shape
(N, 3).camrot – World-to-camera rotation matrices with shape
(N, 3, 3).focal – Camera intrinsic matrices with shape
(N, 2, 2).distortion_mode – Distortion is not implemented and must be
None.distortion_coeff – Distortion is not implemented and must be
None.
- Returns:
Pixel-space perturbations with shape
(N, V, 2).