IMU data
An IMU is the motion sensor of a camera: an accelerometer and a gyroscope. The trajectory output needs IMU data on every input of the batch.
An input carries IMU data in its imu field. An input with imu also needs lens values in camera, as the camera profiles page describes.
The imu field
"imu": {
"source": "csv",
"url": "https://videos.example.com/kitchen-imu.csv",
"clock_offset_s": 0.0,
"imu_in_camera": {
"rotation": [[1, 0, 0], [0, 1, 0], [0, 0, 1]],
"translation_m": [0.0, 0.0, 0.0]
}
}
The values above are an example.
| Field | What it is | Message when the value breaks a rule |
|---|---|---|
source | "csv" for a CSV file at a link, or "embedded" for GoPro telemetry inside the video file. | source must be "csv" or "embedded". |
url | The https link to the CSV file. | url is required when source is csv and refused when source is embedded. |
clock_offset_s | The seconds to add to the IMU times to get the video's times. See Clocks. | clock_offset_s must be a number from -3600 to 3600. |
imu_in_camera | Where the IMU sits in the camera. See IMU in camera. | imu_in_camera must be an object with exactly rotation and translation_m. |
imu_in_camera.rotation | Three rows of three numbers. | rotation must be 3 rows of 3 numbers that form a rotation matrix. |
imu_in_camera.translation_m | Three numbers, in metres. | translation_m must be 3 numbers from -10 to 10. |
A missing source, clock_offset_s or imu_in_camera gets the message imu must be an object with source, clock_offset_s and imu_in_camera, and url when source is csv. A missing url gets the message of url in the table above.
The CSV link follows the link rules of the video link. A CSV link that the API cannot read gets 400, as a video link does. A CSV link that breaks one of the five rules fails the job at acceptance. The service downloads an IMU file of at most 256 MiB.
The CSV format: imu_csv_v1
A CSV file holds one row for each IMU sample. Each row holds the accelerometer and the gyroscope values at one time.
t,accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z
1000000000,0.12,-9.79,0.31,0.002,-0.015,0.004
1005000000,0.15,-9.81,0.29,0.003,-0.014,0.004
The rows above are an example.
- The first line is exactly
t,accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z. - Every other line is one sample with exactly 7 fields, separated by commas.
tis the time of the sample in nanoseconds: a whole number of 1 to 19 digits, with no sign.tis at most 4,611,686,018,427,387,904, which is 2 to the power of 62.- Each
tis larger than thetof the row before it. accel_x,accel_yandaccel_zare specific force, including gravity, in metres per second squared. A camera at rest shows the pull of gravity.gyro_x,gyro_yandgyro_zare angular velocity in radians per second.- A value is a decimal number, such as
-9.81,0.5,.5or1e-3. It has no plus sign before it. It must be finite. - The axes keep the order of your IMU. The frames page describes how the delivered file holds them.
The file itself:
- It holds ASCII characters only.
- Each line ends with LF or with CRLF. The last line may also end with a CR alone, or with no line end. A CR anywhere else is refused.
- A line is at most 512 bytes, including its line end.
- It holds no empty lines.
- It is at most 256 MiB.
A file that breaks one of these rules makes the job fail.
Embedded GoPro telemetry
With "source": "embedded", the service reads the IMU data from the video file itself. The video file must carry GoPro telemetry in the GPMF format, as a GoPro camera writes it into its MP4 files.
- The file holds exactly one telemetry track.
- The accelerometer stream,
ACCL, states its unit as metres per second squared. - The gyroscope stream,
GYRO, states its unit as radians per second. - The telemetry is at most 64 MiB.
If one of these rules is broken, the job fails.
The times of embedded samples come from the clock of the video file. So clock_offset_s is usually 0 with embedded telemetry.
Clocks
The service moves each IMU sample onto the clock of the video. It adds clock_offset_s to the sample's time:
time on the video's clock, in nanoseconds = t + clock_offset_s * 1,000,000,000
The result is rounded to a whole nanosecond. The video's clock is the presentation clock of the video file: the clock of the frames' presentation times.
A sample whose time on the video's clock equals the presentation time of the first frame lands on the first frame. For example, say your IMU logger read 1 second more than the video's clock at the same moment. Then clock_offset_s is -1.
The delivered file uses one clock for the frames and the IMU samples. The frames page describes that clock.
IMU in camera
imu_in_camera says where the IMU sits in the camera. Its rotation and translation_m map a point of the IMU frame into the optical frame of the displayed picture:
p_optical = rotation * p_imu + translation_m
- The optical frame of the displayed picture has
xto the right,ydown andzforward, along the optical axis. The picture is the one displayed, after its rotation. - The IMU frame has the axes of your IMU values.
rotationis written as three rows.translation_mis in metres.
An IMU that sits in the camera with the same axes as the optical frame has the rotation of the example above.
Checks at processing
The API checks only the field rules above. The service checks the IMU data when it processes the video. Each series, the accelerometer and the gyroscope, is checked on its own.
| Check | Rule |
|---|---|
| Samples kept | Samples from 1 second before the first frame to 1 second after the last frame are kept. Other samples are dropped. |
| Samples near frames | Each kept sample is at most 1 second from a frame. |
| Frames near samples | Each frame is at most 1 second from a kept sample. A series needs at least 2 kept samples. |
| Accelerometer | The median of the accelerometer's magnitude is from 9.0 to 10.6 metres per second squared. |
| Gyroscope | The largest magnitude of the gyroscope is at most 35 radians per second. |
| Rate | The rate of each series is from 50 to 1,000 samples per second. |
If one of these checks fails, the job fails.
The accelerometer check is why accel_x, accel_y and accel_z must include gravity. Without gravity, the median would be near 0.