Camera Calibration File Format
VTKCam 1.0
Overview
The camera calibration file is a yaml and contains all of the information to load a camera into Autoscoper. The file is organized with key value pairs.
Warning
The VTKCam 1.0 format is non-standard and exists purely as an implementation detail. While we are documenting it, the file organization may change from version to version without notice. We mean it.
Key value pairs
Key |
Value |
---|---|
|
The version of the file. Currently only 1.0 is supported. |
|
The XYZ coordinates of the focal point. |
|
The XYZ coordinates of the camera position. |
|
The up vector of the camera. |
|
The view angle of the camera. |
|
The width of the image. |
|
The height of the image. |
|
The range of the closest and farthest objects that will affect the rendering. |
Warning
The clipping-range
is not currently used by Autoscoper. This is used to
communicate information within the AutoscoperM Slicer extension.
Example
{
"@schema": "https://autoscoperm.slicer.org/vtk-schema-1.0.json",
"version": 1.0,
"focal-point": [-7.9999999999999964, -245.50000000000006, -186.65000000000006],
"camera-position": [104.71926635196253, -255.22259800818924, -179.66771669788898],
"view-up": [0.0, 1.0, 0.0],
"view-angle": 30.0,
"image-width": 1760,
"image-height": 1760,
"clipping-range": [0.1, 1000],
}
MayaCam 2.0
Overview
The camera calibration file is a txt and contains all of the information to load a camera into Autoscoper. The file is organized with key value pairs.
Key value pairs
Key |
Value |
---|---|
|
The height and width of the radiograph images. |
|
The intrinsic camera matrix. |
|
The rotation matrix. |
|
The translation matrix. |
Template
Note
The rotation is applied to the camera after the translation. Therefore, the final camera position is calculated by the following equation:
image size
height,width
camera matrix
fx,0,cx
0,fy,cy
0,0,1
rotation
r00,r01,r02
-r10,-r11,-r12
-r20,-r21,-r22
translation
-x
y
-z
Example
image size
1024,1024
camera matrix
1.0,0.0,512.0
0.0,1.0,512.0
0.0,0.0,1.0
rotation
1.0,0.0,-1.0
0.0,1.0,0.0
0.0,0.0,1.0
translation
0.0
0.0
512.0
MayaCam 1.0
Overview
The camera calibration file is a csv and contains all of the information to load a camera into Autoscoper. The file is organized by line.
Line values
Line Number |
Description |
---|---|
1 |
The camera location in world space. |
2 |
Rotations around the local x, y, and z axes of the camera. The order of rotation is z, y, x (Roll, Pitch, Yaw). |
3 |
The position of the film plane relative to the camera. Given in the camera’s local space. |
4 |
u0, v0, z |
5 |
scale, height, width. Scale is ignored and is computed from distance and z. |
Example
1-737.5,-514.9,94.3
289.7,-2.0,-55.2
33.9,4.1,-632.5
4840.2,839.2,-6325.8
50.1,1760,1760
Backend Calculations
Overview
This section describes the calculations that are performed by the backend to convert the camera calibration file into an internal Camera object.
Image Plane
The image plane is the location of the DRR image in world space. The center of the image plane is calculated by the following equation:
Note
The below formula applies to VTKCam 1.0 and MayaCam 2.0. For MayaCam 1.0, c_x`` and
c_yare replaced by
u0and
v0respectively. The value for
z` is also not calculated and is instead pulled from the camera calibration file.
DRR_X
and DRR_Y
are the width and height of the DRR image respectively.
The translation matrix is represented by t
and the rotation matrix is represented by R
.
The constant -0.5
is used so that the z
value is the average of the f_x
and f_y
values, and it is negated to be consistent with the MayaCam 1.0 file format.
The constant -1.5
is used so that the image plane is placed across the origin from the camera.
Viewport
The viewport defines the position of the 2D viewer. The viewport is calculated by the following equation:
Note
The below formula applies to VTKCam 1.0 and MayaCam 2.0. For MayaCam 1.0, c_x and c_y are replaced by u0 and v0 respectively. While f_x and f_y are replaced by z.
DRR_X and DRR_Y are the width and height of the DRR image respectively.
VTKCam 1.0 Unique Calculations
The VTKCam 1.0 file format calculates the camera orientation and the focal length from the camera position, focal point, and view angle.
Camera Orientation
Note
The translation matrix is assumed to be the camera position.
First, a vector is calculated from the camera position to the focal point.
Next, a side vector is calculated from the cross product of the focal vector and the up vector. The up vector is assumed to be (0, 1, 0).
Finally, the up vector is calculated from the cross product of the side vector and the focal vector.
The rotation matrix is then calculated from the side, up, and focal vectors.
Focal Length
Note
The principal point (c_x, c_y) is assumed to be half of the image size in the x and y directions respectively.
The view angle is assumed to be in radians (This is converted from degrees to radians in the backend.).
The focal length is calculated from the view angle and the image size.