tryolabs / norfair

Lightweight Python library for adding real-time multi-object tracking to any detector.
https://tryolabs.github.io/norfair/
BSD 3-Clause "New" or "Revised" License
2.41k stars 247 forks source link

Unable to access history of each tracked object after the tracker.update() method #245

Closed ghost closed 1 year ago

ghost commented 1 year ago

Describe the situation you are working on

@DiegoFernandezC

I cannot find any method that would let me access the bboxes associated with each tracked object as a list

Describe what is it that you need help with A method/attribute that can help me retrieve the bbox history as a list

Additional context I have created a self-contained google colab file that contains the highlighted section of the code where I am facing difficulty https://colab.research.google.com/drive/1Sq2v0T910ob3xNO5qdC-6UKqZfUvp2dM?usp=sharing

facundo-lezama commented 1 year ago

Hi @avadhut-00, I reviewed your notebook and saw that you were using TrackedObject.past_detections to access the list of past bounding boxes associated with the specific object. That's currently the way Norfair expects you to do it. So I don't fully understand the problem you are facing when using it. Are you getting empty lists? Are you getting an incomplete list of past bounding boxes? Can you provide some more information?

ghost commented 1 year ago

I have made the required changes in the public notebook to explain my point further:

  1. Trying to get the list of past detections with 't1.past_detections' cmd gives an object memory location instead of bbox co-ordinates--->[<norfair.tracker.Detection object at 0x7f19c469a610>]

  2. When I issue the command 't1.past_detections' I am expecting list of the form [[[x1,y1],[x2,y2]],[[x1,y1],[x2,y2]],[[x1,y1],[x2,y2]],[[x1,y1],[x2,y2]]]

  3. The list above is for a single tracked object having its detection co-ordinate history for the frames it was detected & tracked on

facundo-lezama commented 1 year ago

Thanks for the detailed explanation, I now understand what's happening.

The output of TrackedObject.past_detections is a list of Detection objects with the past detections. So if you want to get the actual bounding boxes, you should access Detection.points for each of the past detections in the list.

ghost commented 1 year ago

@facundo-lezama : yes ,the explanation you provided above has resolved my query.