py-motmetrics icon indicating copy to clipboard operation
py-motmetrics copied to clipboard

new_event_dataframe_with_data(indices, events) fails if arguments are empty

Open headdab opened this issue 6 years ago • 4 comments

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.

headdab avatar Nov 26 '18 20:11 headdab

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.```

headdab avatar Nov 27 '18 00:11 headdab

Could you provide a minimal reproducable example, so I can have an in depth look?

cheind avatar Nov 28 '18 05:11 cheind

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)

headdab avatar Nov 28 '18 15:11 headdab

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?

cheind avatar Nov 29 '18 18:11 cheind