Commit ef4a6ec1 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[utils] added functions shared among scripts

parent 109f432a
#!/usr/bin/env python
# encoding: utf-8
def load_timestamps(filename):
""" load timestamps of a recording.
Each line of the file contains two numbers:
the frame index and the corresponding time in milliseconds.
Parameters
----------
filename: str
The file to extract timestamps from.
Returns
-------
dict:
Dictionary with frame index as key and timestamp as value.
"""
timestamps = {}
f = open(filename, 'r')
for line in f:
line = line.rstrip('\n')
splitted = line.split(' ')
timestamps[int(splitted[0])] = int(splitted[1])
f.close()
return timestamps
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment