Skip to content

Adjust to latest gyroflow file format #6

Open
@AdrianEddy

Description

Hi,

In latest dev build, and soon to be v1.5.1, I've changed the format of the extended data a bit. Instead of using bincode I now use standard CBOR, which should be easier to parse

If version == 3, then gyro_data = cbor2.decoder.loads(raw)

This was needed because we now have additional data from certain files, like per-frame offset, per-frame exposure time and hopefully soon per-frame lens profile information. Adding all these additional information using bincode would be pretty hard to parse in external tools, so I decided to switch to CBOR, which has parsers in all languages

raw_imu and quaternions fields were removed from gyro_source. Instead, there's now file_metadata there which contains:

pub struct FileMetadata {
    pub imu_orientation:     Option<String>,
    pub raw_imu:             Vec<telemetry_parser::util::IMUData>, 
    pub quaternions:         BTreeMap<i64, Quaternion<f64>>,
    pub gravity_vectors:     Option<BTreeMap<i64, Vector3<f64>>>,
    pub image_orientations:  Option<BTreeMap<i64, Quaternion<f64>>>,
    pub detected_source:     Option<String>,
    pub frame_readout_time:  Option<f64>,
    pub frame_rate:          Option<f64>,
    pub camera_identifier:   Option<CameraIdentifier>,
    pub lens_profile:        Option<serde_json::Value>,
    pub lens_positions:      Option<BTreeMap<i64, f64>>,
    pub has_accurate_timestamps: bool,
    pub additional_data:     serde_json::Value,
    pub per_frame_time_offsets: Vec<f64>,
    pub per_frame_data:      Vec<serde_json::Value>,
}

// definition of telemetry_parser::util::IMUData
pub struct IMUData {
    pub timestamp_ms: f64,
    pub gyro: Option<[f64; 3]>,
    pub accl: Option<[f64; 3]>,
    pub magn: Option<[f64; 3]>
}

// definition of CameraIdentifier
pub struct CameraIdentifier {
    pub brand: String,
    pub model: String,
    pub lens_model: String,
    pub lens_info: String,
    pub focal_length: Option<f64>,
    pub camera_setting: String,
    pub fps: usize,
    pub video_width: usize,
    pub video_height: usize,
    pub additional: String,
    pub identifier: String
}

Additionally, I added:

  • synced_imu_timestamps - array of timestamps for every IMU sample, with added interpolated offsets
  • synced_imu_timestamps_with_per_frame_offset - same as above + per frame time offset, which involves exposure time and custom VSYNC offset from the file metadata - this is the final offset. The timestamps represent middle of the frame, ie. in case of 59.94 video, 0 is the middle row of first frame, 16.68 middle row of the second frame etc.
  • adaptive_zoom_fovs - per frame smoothed FOV for adaptive zoom

So instead of interpolating the offsets on your side in python, you can just use imu.timestamp = synced_imu_timestamps_with_per_frame_offset[imu_index]

file_metadata = cbor2.decoder.loads(zlib.decompress(decode(data['gyro_source']['file_metadata'])))
synced_imu_timestamps_with_per_frame_offset = cbor2.decoder.loads(zlib.decompress(decode(data['gyro_source']['synced_imu_timestamps_with_per_frame_offset'])))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions