IO
Pose File Formats
Please see the resources page on pose file formats to learn more about the expected/supported formats commonly used in this library.
A suite of common input/output functions.
This module includes several functions for reading and writing different types of data useful for computer vision applications.
This module contains the following functions:
read_cams_sfm(camera_path, extension)
- Reads an entire directory of camera files in SFM format.read_cams_trajectory(log_file)
- Reads camera file in Trajectory File format.read_extrinsics_tum(tum_file, key_frames)
- Reads extrinsic camera trajectories in TUM format [timestamp tx ty tz qx qy qz qw].read_matrix(mat_file)
- Reads a single matrix of float values from a file.read_mesh(mesh_file)
- Reads a mesh from a file.read_cluster_list(filename)
- Reads a cluster list file encoding supporting camera viewpoints.read_pfm(pfm_file)
- Reads a file in *.pfm format.read_point_cloud(point_cloud_file)
- Reads a point cloud from a file.read_single_cam_sfm(cam_file, depth_planes)
- Reads a single camera file in SFM format.read_stereo_intrinsics_yaml(intrinsics_file)
- Reads intrinsics information for a stereo camera pair from a *.yaml file.write_cam_sfm()
-write_matrix(M, mat_file)
- Writes a single matrix to a file.write_mesh(mesh_file, mesh)
- Writes a mesh to a file.write_pfm(pfm_file, data_map, scale)
- Writes a data map to a file in *.pfm format.
load_pretrained_model(model, ckpt)
Loads model weights from disk.
Source code in cvt/io.py
450 451 452 453 454 455 456 457 458 459 |
|
read_cams_sfm(camera_path, extension='cam.txt')
Reads an entire directory of camera files in SFM format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
camera_path |
str
|
Path to the directory of camera files. |
required |
extension |
str
|
File extension being used for the camera files. |
'cam.txt'
|
Returns:
Type | Description |
---|---|
np.ndarray
|
Array of camera extrinsics, intrinsics, and view metadata (Nx2x4x4). |
Source code in cvt/io.py
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 |
|
read_cams_trajectory(log_file)
Reads camera file in Trajectory File format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_file |
str
|
Input *.log file to be read. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
Array of camera extrinsics, intrinsics, and view metadata (Nx2x4x4). |
Source code in cvt/io.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
read_cluster_list(filename)
Reads a cluster list file encoding supporting camera viewpoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
Input file encoding per-camera viewpoints. |
required |
Returns:
Type | Description |
---|---|
List[Tuple[int, List[int]]]
|
An array of tuples encoding (ref_view, [src_1,src_2,..]) |
Source code in cvt/io.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
read_extrinsics_tum(tum_file, key_frames=None)
Reads extrinsic camera trajectories in TUM format [timestamp tx ty tz qx qy qz qw].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tum_file |
str
|
Input extrinsics file. |
required |
key_frames |
List[int]
|
Indices corresponding to the desired keyframes. |
None
|
Returns:
Type | Description |
---|---|
np.ndarray
|
Array of camera extrinsics (Nx4x4). |
Source code in cvt/io.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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
read_matrix(mat_file)
Reads a single matrix of float values from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mat_file |
str
|
Input file for the matrix to be read. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
The matrix stored in the given file. |
Source code in cvt/io.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
read_mesh(mesh_file)
Reads a mesh from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file |
str
|
Input mesh file. |
required |
Returns:
Type | Description |
---|---|
o3d.geometry.TriangleMesh
|
The mesh stored in the given file. |
Source code in cvt/io.py
158 159 160 161 162 163 164 165 166 167 |
|
read_pfm(pfm_file)
Reads a file in *.pfm format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pfm_file |
str
|
Input *.pfm file to be read. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
Data map that was stored in the *.pfm file. |
Source code in cvt/io.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 223 224 225 226 227 228 229 230 |
|
read_point_cloud(point_cloud_file)
Reads a point cloud from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point_cloud_file |
str
|
Input point cloud file. |
required |
Returns:
Type | Description |
---|---|
o3d.geometry.PointCloud
|
The point cloud stored in the given file. |
Source code in cvt/io.py
232 233 234 235 236 237 238 239 240 241 |
|
read_single_cam_sfm(cam_file, depth_planes=256)
Reads a single camera file in SFM format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cam_file |
str
|
Input camera file to be read. |
required |
depth_planes |
int
|
Number of depth planes to store in the view metadata. |
256
|
Returns:
Type | Description |
---|---|
np.ndarray
|
Camera extrinsics, intrinsics, and view metadata (2x4x4). |
Source code in cvt/io.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
read_stereo_intrinsics_yaml(intrinsics_file)
Reads intrinsics information for a stereo camera pair from a *.yaml file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intrinsics_file |
str
|
Input *.yaml file storing the intrinsics information. |
required |
Returns:
Name | Type | Description |
---|---|---|
K_left |
np.ndarray
|
Intrinsics matrix (3x3) of left camera. |
D_left |
np.ndarray
|
Distortion coefficients vector (1x4) of left camera. |
K_right |
np.ndarray
|
Intrinsics matrix (3x3) of right camera. |
D_right |
np.ndarray
|
Distortion coefficients vector (1x4) of right camera. |
R |
np.ndarray
|
Relative rotation matrix (3x3) from left -> right cameras. |
T |
np.ndarray
|
Relative translation vector (1x3) from left -> right cameras. |
Source code in cvt/io.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
save_model(model, cfg, name='ckpt_model.pth')
Saves model weights to disk.
Source code in cvt/io.py
440 441 442 443 444 445 446 447 448 |
|
write_cam_sfm(cam_file, cam)
Writes intrinsic and extrinsic camera parameters to a file in sfm format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cam_file |
str
|
The file to be writen to. |
required |
cam |
np.ndarray
|
Camera extrinsic and intrinsic data to be written. |
required |
Source code in cvt/io.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
write_matrix(M, mat_file)
Writes a single matrix to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
np.ndarray
|
Matrix to be stored. |
required |
mat_file |
str
|
Output file where the given matrix is to be writen. |
required |
Source code in cvt/io.py
361 362 363 364 365 366 367 368 369 370 371 372 |
|
write_mesh(mesh_file, mesh)
Writes a mesh to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file |
str
|
Output mesh file. |
required |
mesh |
o3d.geometry.TriangleMesh
|
Mesh to be stored. |
required |
Source code in cvt/io.py
374 375 376 377 378 379 380 381 |
|
write_pfm(pfm_file, data_map, scale=1.0)
Writes a data map to a file in *.pfm format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pfm_file |
str
|
Output *.pfm file to store the data map. |
required |
data_map |
np.ndarray
|
Data map to be stored. |
required |
scale |
float
|
Value used to scale the data map. |
1.0
|
Source code in cvt/io.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
|