Data import
- glitter2.storage.imports.map_frame_rate_to_timestamps(timestamps: Union[List[float], numpy.ndarray], frame_rate: float, min_frame: int, max_frame: int) Dict[int, List[float]]
Maps video frames given as integer multiples of a frame rate to a monotonic list of timestamps.
E.g. given a frame rate of
10
, a start frame number of5
and a end frame number of10
, and a list of timestamps of[.1, .2, .3, .4, .5, .58, .6, .66, .7, .9, 1.0, 1.1]
, it returns:>>> map_frame_rate_to_timestamps( [.1, .2, .3, .4, .5, .58, .6, .66, .7, .74, .9, 1.0, 1.1], 10., 5, 10) {5: [0.5], 6: [0.58, 0.6], 7: [0.66, 0.7, 0.74], 9: [0.9], 10: [1.0] }
Target timestamps outside the first/last frame time (with some fuzzy factor) are not assigned to any frames.
- Parameters
timestamps – The sorted list of timestamps to be mapped to. It is assumed to be continuous with no gaps (i.e. all value between start and end of timestamps can be coded).
frame_rate – The frame rate used to convert the frame numbers into estimated timestamps.
min_frame – The frame number of the start frame (as integer multiple of the frame rate).
max_frame – The frame number of the end frame (as integer multiple of the frame rate).
- Returns
The mapping.
- glitter2.storage.imports.map_timestamps_to_timestamps(src_timestamps: Union[List[float], numpy.ndarray], target_timestamps: Union[List[float], numpy.ndarray]) Dict[float, List[float]]
Maps a continuous list of timestamps into another list of timestamps so that given an event occurring in the source timestamps, we can translate that event’s occurrence into target timestamps.
E.g.:
>>> target_timestamps = [.1, .2, .3, .4, .5, .58, .6, .66, .7, .9, 1.0, 1.1] >>> source_timestamps = [.1, .2, .4, .5, .7, .8, .96] >>> map_timestamps_to_timestamps(source_timestamps, target_timestamps) {0.1: [0.1], 0.2: [0.2, 0.3], 0.4: [0.4], 0.5: [0.5, 0.58], 0.7: [0.6, 0.66, 0.7], 0.96: [0.9, 1.0] }
Target timestamps outside the first/last timestamp of the source timestamps (with some fuzzy factor) are not assigned to any source timestamps.
- Parameters
src_timestamps – The sorted list of timestamps to map from. It is assumed to be continuous with no gaps (i.e. all value between start and end of timestamps can be coded).
target_timestamps – The sorted list of timestamps to be mapped to. It is assumed to be continuous with no gaps (i.e. all value between start and end of timestamps can be coded).
- Returns
The mapping.