cheind / py-motmetrics

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

Do we need to keep original detection order? #165

Closed SuperbTUM closed 1 year ago

SuperbTUM commented 1 year ago

When comparing with ground truth, do we need to generate our tracking result with the same order of detection? For example, under frame A, there may be a couple of detections. Let's say, one detection with embedding E1 and another with embedding E2, and in ground truth the order is

 Frame_ID  Tracking_ID                  Bbox_detail                          Others
 A              1               detection bbox with embedding E1             ...
 A              2               detection bbox with embedding E2             ...

When generating tracking results, is it acceptable to say tracking result of embedding E2 is placed prior to embedding E1?

SuperbTUM commented 1 year ago

I suspect this is not allowed as I read the code, here we need to calculate pairwise distance grouped by frame ID, no matter what distance metric is using. So given a frame ID, the detections should be in the same order. But pending for confirmation from the author or other users. Thanks.

amm272 commented 1 year ago

Hi @SuperbTUM, for each detection bounding box E within a frame F, the algorithm will assign a matching ground truth bounding box E' from the same frame F based on the distance metric. If for a certain bounding box E all the ground truth bounding boxes within a frame F are more than a threshold distance t away, it will be considered a false positive. If a ground truth bounding box E' has no match, then it will be considered a miss. Hence, you do not need to order the detections and ground truth labels prior to running the tracking. The matching will be handled in the code. However, you do need to compute the distance metrics before starting the tracking as explained in the Readme file.

SuperbTUM commented 1 year ago

@amm272 Thanks for the explanation! Yes, with tutorial on readme, the order within a frame does not matter, but if we simply call mm.utils.compare_to_groundtruth, I assume there is no Hungarian matching logic inside and order does matter in this case. But we should follow the instructions on readme to avoid this issue.

cheind commented 1 year ago

@SuperbTUM as mentioned by @amm272 the order of detections per frame is irrelevant. what is relevant is consistency of the detection ids that you assign. I.e if E1 is named E1 in frame 0, then it should also be named E1 in all other frames it is detected.

As far as the example compare_to_groundtruth holds, the same applies. The IDs detection ids are extracted via

https://github.com/cheind/py-motmetrics/blob/develop/motmetrics/utils.py#L79

and distances are then computed in this order by

https://github.com/cheind/py-motmetrics/blob/develop/motmetrics/utils.py#L81

SuperbTUM commented 1 year ago

Thank you all for the explanation! Yeah, the detection order inside the same frame does not matter the performance. Thanks again.