Camera profiles
Depth, trajectory and IMU data need the lens values of the camera that filmed the video. The lens values say how the camera maps the scene onto the pixels of the picture.
An input gives the lens values in its camera field, in one of two ways:
- It names a camera profile: a set of lens values that the service keeps under a name.
- It states the lens values itself, in
intrinsics.
camera holds exactly one of the two. Otherwise the request gets 400 with the message camera must be an object with exactly one of profile and intrinsics.
An input without camera gets pii_blur only, and its pictures keep their own aspect ratio. The frames page shows both cases.
Name a profile
"camera": { "profile": "the-profile-name" }
- A name has 1 to 64 characters. A broken name gets 400 with the message
profile must be 1 to 64 lower-case letters, digits, '_', '.' or '-', starting with a letter or a digit. - The name must be a profile that exists. An unknown name gets 400 with the param
inputs[n].camera.profileand the messageNo camera profile has this name. - When the batch is accepted, the profile's lens values are copied into the job. A later change of the profile does not change jobs that were already accepted.
State the lens values
"camera": {
"intrinsics": {
"model": "pinhole",
"width": 1920,
"height": 1080,
"fx": 1400.0,
"fy": 1400.0,
"cx": 959.5,
"cy": 539.5,
"distortion": [-0.12, 0.03, 0.0, 0.0, 0.0],
"rotation_deg": 0
}
}
The values above are an example, not a real camera.
Stating lens values needs a switch on your organisation. The switch is off by default, and the service's staff turn it on. While it is off, intrinsics gets 400 with the param inputs[n].camera.intrinsics and the message This organisation may not state camera intrinsics. Name a camera profile instead.
intrinsics holds exactly the nine keys model, width, height, fx, fy, cx, cy, distortion and rotation_deg. A missing key gets 400 with the message intrinsics must be an object with exactly model, width, height, fx, fy, cx, cy, distortion and rotation_deg. An extra key gets 400 with the message This field is not accepted.
The rules
When a batch arrives, the API checks the keys in this order. The first broken rule answers 400, with the key's path as the param.
| Key | Message when the value breaks the rule |
|---|---|
model | model must be "pinhole" or "fisheye". |
width | width must be a whole number of at least 2. |
height | height must be a whole number of at least 2. |
fx | fx must be a number above 0. |
fy | fy must be a number above 0. |
cx | cx must be a number from 0 to width - 1. |
cy | cy must be a number from 0 to height - 1. |
distortion | distortion must be 5 numbers for pinhole or 4 numbers for fisheye. |
rotation_deg | rotation_deg must be 0, 90, 180 or 270. |
A whole number may be written in any JSON form of a whole number, such as 1920.0.
What the values mean
The two models are the pinhole and the fisheye models of OpenCV.
| Key | Meaning |
|---|---|
model | pinhole for the OpenCV pinhole model with its distortion. fisheye for the OpenCV fisheye model. |
width, height | The size of the picture as it is displayed, in pixels, after its rotation. |
fx, fy | The focal lengths, in pixels. |
cx, cy | The principal point, in pixels. |
distortion | pinhole: k1, k2, p1, p2, k3, in this order. fisheye: k1, k2, k3, k4. |
rotation_deg | The clockwise rotation for display that the video file states. |
All pixel values refer to the displayed picture, after its rotation. The centre of a pixel is at a whole number, and the centre of the top-left pixel is at 0, 0.
A point at X, Y, Z in the camera's optical frame, with x to the right, y down and z forward, lands on the pixel u, v as follows:
x = X / Z
y = Y / Z
r2 = x * x + y * y
pinhole:
radial = 1 + k1 * r2 + k2 * r2^2 + k3 * r2^3
xd = x * radial + 2 * p1 * x * y + p2 * (r2 + 2 * x * x)
yd = y * radial + p1 * (r2 + 2 * y * y) + 2 * p2 * x * y
fisheye:
theta = atan(sqrt(r2))
thetad = theta * (1 + k1 * theta^2 + k2 * theta^4 + k3 * theta^6 + k4 * theta^8)
xd = x * thetad / sqrt(r2)
yd = y * thetad / sqrt(r2)
u = fx * xd + cx
v = fy * yd + cy
For fisheye, a point on the optical axis, where r2 is 0, has xd = x and yd = y.
Checks at processing
The API checks only the rules above. The service checks more when it reads the video. If one of these checks fails, the job fails:
widthandheightmust equal the size of the displayed picture of the video.rotation_degmust equal the clockwise display rotation that the video file states.- The lens values must leave room for an undistorted 16:9 view inside the picture.
Published profiles
No camera profile is published yet.