kaolin.render.camera¶
API¶
- kaolin.render.camera.generate_perspective_projection(fovyangle, ratio=1.0, dtype=torch.float32)¶
Generate perspective projection matrix for a given camera fovy angle.
- kaolin.render.camera.generate_rotate_translate_matrices(camera_position, look_at, camera_up_direction)¶
Generate rotation and translation matrix for given camera parameters.
Formula is \(\text{P_cam} = \text{rot_mtx} * (\text{P_world} - \text{trans_mtx})\)
- Parameters
camera_position (torch.FloatTensor) – camera positions of shape \((\text{batch_size}, 3)\), it means where your cameras are
look_at (torch.FloatTensor) – where the camera is watching, of shape \((\text{batch_size}, 3)\),
camera_up_direction (torch.FloatTensor) – camera up directions of shape \((\text{batch_size}, 3)\), it means what are your camera up directions, generally [0, 1, 0]
- Returns
the camera rotation matrix of shape \((\text{batch_size}, 3, 3)\) and the camera transformation matrix of shape \((\text{batch_size}, 3)\)
- Return type
(torch.FloatTensor, torch.FloatTensor)
- kaolin.render.camera.generate_transformation_matrix(camera_position, look_at, camera_up_direction)¶
Generate transformation matrix for given camera parameters.
Formula is \(\text{P_cam} = \text{P_world} * {\text{transformation_mtx}\), with \(\text{P_world}\) being the points coordinates padded with 1.
- Parameters
camera_position (torch.FloatTensor) – camera positions of shape \((\text{batch_size}, 3)\), it means where your cameras are
look_at (torch.FloatTensor) – where the camera is watching, of shape \((\text{batch_size}, 3)\),
camera_up_direction (torch.FloatTensor) – camera up directions of shape \((\text{batch_size}, 3)\), it means what are your camera up directions, generally [0, 1, 0]
- Returns
The camera transformation matrix of shape \((\text{batch_size, 4, 3)\).
- Return type
(torch.FloatTensor)
- kaolin.render.camera.perspective_camera(points, camera_proj)¶
Projects 3D points on 2D images in perspective projection mode.
- Parameters
points (torch.FloatTensor) – 3D points in camera coordinate, of shape \((\text{batch_size}, \text{num_points}, 3)\).
camera_proj (torch.FloatTensor) – projection matrix of shape \((3, 1)\).
- Returns
2D points on image plane of shape \((\text{batch_size}, \text{num_points}, 2)\).
- Return type
(torch.FloatTensor)
- kaolin.render.camera.rotate_translate_points(points, camera_rot, camera_trans)¶
Rotate and translate 3D points on based on rotation matrix and transformation matrix.
Formula is \(\text{P_new} = R * (\text{P_old} - T)\)
- Parameters
points (torch.FloatTensor) – 3D points, of shape \((\text{batch_size}, \text{num_points}, 3)\).
camera_rot (torch.FloatTensor) – rotation matrix, of shape \((\text{batch_size}, 3, 3)\).
camera_trans (torch.FloatTensor) – translation matrix, of shape \((\text{batch_size}, 3, 1)\).
- Returns
3D points in new rotation, of same shape than points.
- Return type
(torch.FloatTensor)