pointset_utils
Utility functions to handle pointsets.
change_orientation_camera_convention(in_orientation_q, in_convention, out_convention)
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).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_orientation_q |
Tensor
|
Quaternion(s) which transforms from coordinate frame A to in_convention camera frame. Scalar-last convention. Shape (...,4). |
required |
in_convention |
str
|
Camera convention for the in_transform. One of "opengl", "opencv". |
required |
out_convention |
str
|
Camera convention for the returned transform. One of "opengl", "opencv". |
required |
Returns: Quaternion(s) which transforms from coordinate frame A to in_convention camera frame. Scalar-last convention. Same shape as in_orientation_q.
Source code in sdfest/initialization/pointset_utils.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
change_position_camera_convention(in_position, in_convention, out_convention)
Change the camera convention for a position in a camera frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_position |
Tensor
|
Position(s) of coordinate frame A in in_convention camera frame. Shape (...,3). |
required |
in_convention |
str
|
Camera convention for the in_position. One of "opengl", "opencv". |
required |
out_convention |
str
|
Camera convention for the returned transform. One of "opengl", "opencv". |
required |
Returns: Position(s) of coordinate frame A in out_convention camera frame. Shape (...,3).
Source code in sdfest/initialization/pointset_utils.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
change_transform_camera_convention(in_transform, in_convention, out_convention)
Change the camera convention for a frame A -> camera frame transform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_transform |
Tensor
|
Transformtion matrix(es) from coordinate frame A to in_convention camera frame. Shape (...,4,4). |
required |
in_convention |
str
|
Camera convention for the in_transform. One of "opengl", "opencv". |
required |
out_convention |
str
|
Camera convention for the returned transform. One of "opengl", "opencv". |
required |
Returns: Transformtion matrix(es) from coordinate frame A to out_convention camera frame. Same shape as in_transform.
Source code in sdfest/initialization/pointset_utils.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
depth_to_pointcloud(depth_image, camera, normalize=False, mask=None, convention='opengl')
Convert depth image to pointcloud.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_image |
Tensor
|
The depth image to convert to pointcloud, shape (H,W). |
required |
camera |
Camera
|
The camera used to lift the points. |
required |
normalize |
bool
|
Whether to normalize the pointcloud with 0 centroid. |
False
|
mask |
Optional[Tensor]
|
Only points with mask != 0 will be added to pointcloud. No masking will be performed if None. |
None
|
convention |
str
|
The camera frame convention to use. One of: "opengl": x right, y up, z back "opencv": x right, y down, z forward |
'opengl'
|
Returns: The pointcloud in the camera frame, in OpenGL convention, shape (N,3).
Source code in sdfest/initialization/pointset_utils.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
normalize_points(points)
Normalize pointset to have zero mean.
Normalization will be performed along second last dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points |
Tensor
|
The pointsets which will be normalized, shape (N, M, D) or shape (M, D), N pointsets with M points of dimension D. |
required |
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 sdfest/initialization/pointset_utils.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
visualize_pointset(pointset, max_points=1000)
Visualize pointset as 3D scatter plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pointset |
Tensor
|
The pointset to visualize. Either shape (N,3), xyz, or shape (N,6), xyzrgb. |
required |
max_points |
int
|
Maximum number of points. If N>max_points only a random subset will be shown. |
1000
|
Source code in sdfest/initialization/pointset_utils.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|