cvtkit.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.
load_pretrained_model(model, ckpt)
Loads model weights from disk.
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 |
---|---|
ndarray
|
Array of camera extrinsics, intrinsics, and view metadata (Nx2x4x4). |
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 |
---|---|
NDArray[float32]
|
Array of camera extrinsics, intrinsics, and view metadata (Nx2x4x4). |
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,..]) |
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] | None
|
Indices corresponding to the desired keyframes. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
Array of camera extrinsics (Nx4x4). |
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 |
---|---|
ndarray
|
The matrix stored in the given file. |
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 |
---|---|
TriangleMesh
|
The mesh stored in the given file. |
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 |
---|---|
NDArray[float32]
|
Data map that was stored in the *.pfm file. |
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 |
---|---|
PointCloud
|
The point cloud stored in the given file. |
read_point_cloud_np(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 |
---|---|
NDArray[float32]
|
The point cloud as an NDArray stored in the given file. |
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 |
---|---|
ndarray
|
Camera extrinsics, intrinsics, and view metadata (2x4x4). |
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 |
NDArray[float32]
|
Intrinsics matrix (3x3) of left camera. |
D_left |
NDArray[float32]
|
Distortion coefficients vector (1x4) of left camera. |
K_right |
NDArray[float32]
|
Intrinsics matrix (3x3) of right camera. |
D_right |
NDArray[float32]
|
Distortion coefficients vector (1x4) of right camera. |
R |
NDArray[float32]
|
Relative rotation matrix (3x3) from left -> right cameras. |
T |
NDArray[float32]
|
Relative translation vector (1x3) from left -> right cameras. |
sfm_to_trajectory(cams, log_file)
Convert a set of cameras from SFM format to Trajectory File format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cams
|
NDArray[Any] | Tensor
|
Array of camera extrinsics (Nx4x4) to be converted. |
required |
log_file
|
str
|
Output path to the *.log file that is to be created. |
required |
trajectory_to_sfm(log_file, camera_path, intrinsics)
Convert a set of cameras from Trajectory File format to SFM format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_file
|
str
|
Input *.log file that stores the trajectory information. |
required |
camera_path
|
str
|
Output path where the SFM camera files will be written. |
required |
intrinsics
|
ndarray
|
Array of intrinsics matrices (Nx3x3) for each camera. |
required |
write_cam_sfm(cam_file, intrinsics, extrinsics)
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 |
intrinsics
|
ndarray
|
Camera intrinsic data to be written. |
required |
extrinsics
|
ndarray
|
Camera extrinsic data to be written. |
required |
write_matrix(M, mat_file)
Writes a single matrix to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M
|
ndarray
|
Matrix to be stored. |
required |
mat_file
|
str
|
Output file where the given matrix is to be writen. |
required |
write_mesh(mesh_file, mesh)
Writes a mesh to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file
|
str
|
Output mesh file. |
required |
mesh
|
TriangleMesh
|
Mesh to be stored. |
required |
write_pfm(filename, data_map, scale=1.0)
Writes a data map to a file in *.pfm format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pfm_file
|
Output *.pfm file to store the data map. |
required | |
data_map
|
ndarray
|
Data map to be stored. |
required |
scale
|
float
|
Value used to scale the data map. |
1.0
|