Dev/fix track order
@matthew.bernstein This is a fix for the annotation order issue.
This changes the CocoDataset.index.trackid_to_aids
from Dict[int, set]
to Dict[int | None, SortedSet | set]
, where most entries are a SortedSet
using the new _lut_annot_frame_index
helper as the sorting key. The one exception is when the trackid is None, in which case the annotations wont always have a frame index, so we can't rely on the sorting logic.
I wish the key didn't have to use multiple levels of lookups, but I don't think there is a way around it.
I also had to modify the remove annotation logic to ensure I'm removing the annotations from the track index before I remove them from the main ann index, otherwise the sorted set tries to use anns
to lookup a value, but it is missing so it fails.