pointset_utils.py
cpas_toolbox.pointset_utils ¶
Utility functions to handle pointsets.
normalize_points ¶
Normalize pointset to have zero mean.
Normalization will be performed along second last dimension.
PARAMETER | DESCRIPTION |
---|---|
points |
The pointsets which will be normalized, shape (N, M, D) or shape (M, D), N pointsets with M points of dimension D.
TYPE:
|
Return
normalized_points: The normalized pointset, same shape as points. centroids: The means of the pointclouds used to normalize points. Shape (N, D) or (D,), for (N, M, D) and (M, D) inputs, respectively.
Source code in cpas_toolbox/pointset_utils.py
depth_to_pointcloud ¶
depth_to_pointcloud(
depth_image: torch.Tensor,
camera: camera_utils.Camera,
normalize: bool = False,
mask: Optional[torch.Tensor] = None,
convention: str = "opengl",
) -> torch.Tensor
Convert depth image to pointcloud.
PARAMETER | DESCRIPTION |
---|---|
depth_image |
The depth image to convert to pointcloud, shape (H,W).
TYPE:
|
camera |
The camera used to lift the points.
TYPE:
|
normalize |
Whether to normalize the pointcloud with 0 centroid.
TYPE:
|
mask |
Only points with mask != 0 will be added to pointcloud. No masking will be performed if None.
TYPE:
|
convention |
The camera frame convention to use. One of: "opengl": x right, y up, z back "opencv": x right, y down, z forward
TYPE:
|
Returns: The pointcloud in the camera frame, in OpenGL convention, shape (N,3).
Source code in cpas_toolbox/pointset_utils.py
change_transform_camera_convention ¶
change_transform_camera_convention(
in_transform: torch.Tensor, in_convention: str, out_convention: str
) -> torch.Tensor
Change the camera convention for a frame A -> camera frame transform.
PARAMETER | DESCRIPTION |
---|---|
in_transform |
Transformtion matrix(es) from coordinate frame A to in_convention camera frame. Shape (...,4,4).
TYPE:
|
in_convention |
Camera convention for the in_transform. One of "opengl", "opencv".
TYPE:
|
out_convention |
Camera convention for the returned transform. One of "opengl", "opencv".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
Transformtion matrix(es) from coordinate frame A to out_convention camera frame. |
Tensor
|
Same shape as in_transform. |
Source code in cpas_toolbox/pointset_utils.py
change_position_camera_convention ¶
change_position_camera_convention(
in_position: torch.Tensor, in_convention: str, out_convention: str
) -> tuple
Change the camera convention for a position in a camera frame.
PARAMETER | DESCRIPTION |
---|---|
in_position |
Position(s) of coordinate frame A in in_convention camera frame. Shape (...,3).
TYPE:
|
in_convention |
Camera convention for the in_position. One of "opengl", "opencv".
TYPE:
|
out_convention |
Camera convention for the returned transform. One of "opengl", "opencv".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Position(s) of coordinate frame A in out_convention camera frame. Shape (...,3). |
Source code in cpas_toolbox/pointset_utils.py
change_orientation_camera_convention ¶
change_orientation_camera_convention(
in_orientation_q: torch.Tensor, in_convention: str, out_convention: str
) -> tuple
Change the camera convention for an orientation in a camera frame.
Orientation is represented as a quaternion, that rotates points from a coordinate frame A to a camera frame (if those frames had the same origin).
PARAMETER | DESCRIPTION |
---|---|
in_orientation_q |
Quaternion(s) which transforms from coordinate frame A to in_convention camera frame. Scalar-last convention. Shape (...,4).
TYPE:
|
in_convention |
Camera convention for the in_transform. One of "opengl", "opencv".
TYPE:
|
out_convention |
Camera convention for the returned transform. One of "opengl", "opencv".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Quaternion(s) which transforms from coordinate frame A to in_convention camera |
tuple
|
frame. Scalar-last convention. Same shape as in_orientation_q. |
Source code in cpas_toolbox/pointset_utils.py
visualize_pointset ¶
Visualize pointset as 3D scatter plot.
PARAMETER | DESCRIPTION |
---|---|
pointset |
The pointset to visualize. Either shape (N,3), xyz, or shape (N,6), xyzrgb.
TYPE:
|
max_points |
Maximum number of points. If N>max_points only a random subset will be shown.
TYPE:
|