motpy
motpy copied to clipboard
How to pass detection meta-information through the tracker?
As already slightly discussed in https://github.com/wmuron/motpy/issues/9, it can be necessary to pass information of the detection through the tracker, to be used in a later step. For example, I have more information per detection, which is not relevant for the tracker, but for my later pipeline.
In most of the examples, the detection and active-tracks are not "related" to each other and just drawn onto the image. But I have the case where I would like to know, which detection object has become which tracked-object. Is there a way to determine this?
@cansik If you need to know which detections (from current frame) were matched with which single object trackers, you can look at matches here: https://github.com/wmuron/motpy/blob/master/motpy/tracker.py#L399 - just make them accessible as a class member or just return both active tracks and matches.
If you want the property you have in mind to be a part of a Track (kind of a "state"), you need to modify the Track, Tracker and Detection classes to contain such information; also it'll require you to provide the logic of how to apply the "update" step.
Anyway, both approaches require doing small modifications by you in the motpy library.
@wmuron Thank you, would you be open for a PR if I am going to add this functionality in a way that the current API is still valid? Or would I have to publish my own package to be used in my projects?
I tried to implement it with a public matches
attribute, but this is not working because the tracker list is changed after the matching, so the indexes are wrong.
It was necessary to add a reference
field to the trackers and the track output to being able to later match input detections to trackers.