cheind / py-motmetrics

:bar_chart: Benchmark multiple object trackers (MOT) in Python
MIT License
1.37k stars 258 forks source link

Fixed issue when object ID suddenly appears #181

Closed Lihi-Gur-Arie closed 1 year ago

cheind commented 1 year ago

hey, thanks for your contribution. could you explain which bug you address?

Lihi-Gur-Arie commented 1 year ago

Sure!

When evaluating my tracker using py-motmetrics on a custom dataset, I encountered a KeyError on line 262 in mot.py:

abs(frameid - self.last_occurrence[o]) <= self.max_switch_time) Upon investigation, I found that the error occurs when an object ID (o) that has not been seen in previous frames suddenly appears in the current frame. This is especially common in scenarios where objects are temporarily occluded or not detected in some frames and then reappear. The self.last_occurrence dictionary does not have an entry for such object IDs, leading to the KeyError.

I noticed that other users have faced a similar issue, as mentioned in this thread: https://github.com/cheind/py-motmetrics/issues/129.

My PR addresses this bug by ensuring that the object ID (o) exists in the self.last_occurrence dictionary before referencing it, thereby preventing the KeyError. This provides a more robust way of handling scenarios where object IDs might not appear continuously in every frame.

cheind commented 1 year ago

@Lihi-Gur-Arie thanks for your explanation. Did you run the unit-tests?

cheind commented 1 year ago

I just added some fixes to the develop branch to make the unit-testing pipeline working again. would you mind rebasing your PR on the current state of develop and resubmit? then the above 3 checks should pass

Lihi-Gur-Arie commented 1 year ago

@cheind Sure, just merged it. Thanks!

cheind commented 1 year ago

thanks - didn't notice that I had to manually trigger the CI.

cheind commented 1 year ago

thanks again - merged into develop.