Camera
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 camera utilities.
This module includes several functions for manipulating and extracting information from camera intrinsics and extrinsics, as well as converting between specific formats.
This module contains the following functions:
camera_center(cam)
- Computes the center of a camera in world coordinates.relative_transform(cams_1, cams_2)
- Computes the relative transformation between two sets of cameras.sfm_to_trajectory(cams, log_file)
- Convert a set of cameras from SFM format to Trajectory File format.trajectory_to_sfm(log_file, camera_path, intrinsics)
- Convert a set of cameras from Trajectory File format to SFM format.y_axis_rotation(P, theta)
- Applies a rotation to the given camera extrinsics matrix along the y-axis.
camera_center(cam)
Computes the center of a camera in world coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cam |
np.ndarray
|
The extrinsics matrix (4x4) of a given camera. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
The camera center vector (3x1) in world coordinates. |
Source code in cvt/camera.py
101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
relative_transform(cams_1, cams_2)
Computes the relative transformation between two sets of cameras.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cams_1 |
np.ndarray
|
Array of the first set of cameras (Nx4x4). |
required |
cams_2 |
np.ndarray
|
Array of the second set of cameras (Nx4x4). |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
The relative transformation matrix (4x4) between the two trajectories. |
Source code in cvt/camera.py
115 116 117 118 119 120 121 122 123 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 153 154 155 156 157 158 159 160 161 162 |
|
sfm_to_trajectory(cams, log_file)
Convert a set of cameras from SFM format to Trajectory File format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cams |
np.ndarray
|
Array of camera extrinsics (Nx4x4) to be converted. |
required |
log_file |
str
|
Output path to the *.log file that is to be created. |
required |
Source code in cvt/camera.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
to_opengl_pose(pose)
OpenGL pose: (right-up-back) (cam-to-world)
Source code in cvt/camera.py
49 50 51 52 53 54 55 56 57 |
|
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 |
np.ndarray
|
Array of intrinsics matrices (Nx3x3) for each camera. |
required |
Source code in cvt/camera.py
185 186 187 188 189 190 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 |
|
y_axis_rotation(P, theta)
Applies a rotation to the given camera extrinsics matrix along the y-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
P |
np.ndarray
|
Initial extrinsics camera matrix. |
required |
theta |
float
|
Angle (in radians) to rotate the camera. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
The rotated extrinsics matrix for the camera. |
Source code in cvt/camera.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|