py-motmetrics
py-motmetrics copied to clipboard
new_event_dataframe_with_data(indices, events) fails if arguments are empty
The following line:
raw_type = pd.Categorical(tevents[0], categories=['RAW', 'FP', 'MISS', 'SWITCH', 'MATCH'], ordered=False)
fails with:
IndexError: list index out of range
tevents[0] fails.
I think you can fix this as such:
@staticmethod
def new_event_dataframe_with_data(indices, events):
"""DOCSTRING..."""
if len(events) == 0: return MOTAccumulator.new_event_dataframe()
tevents = list(zip(*events))
although, I think some computations fails in this case. I got some divide by zero errors, but didn't track them `down.```
Could you provide a minimal reproducable example, so I can have an in depth look?
The failure mode is simple to understand.
If there are no objects or predictions for a frame, which can happen, e.g., when you are processing videos, then there are no events when this function is called.
While creating an example, I found an even simpler failure mode, at the same point.
import motmetrics as mm
acc = mm.MOTAccumulator(auto_id=True)
acc.update([], [], [[],[]])
print(acc.events)
Sorry I might have misunderstood. Are you saying it fails in adding empty frames to the accumulator, or when computing the metrics with an empty accumulator?