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.34k stars 237 forks source link

Detection confidence when drawing tracked_objects' boxes? #310

Open utility-aagrawal opened 3 months ago

utility-aagrawal commented 3 months ago

Hi @aguscas ,

I am drawing bounding boxes from tracked_objects but I don't see an option to display detection confidence.

1) Why is that so? 2) What's the easiest way to get detection confidence? For my use case, I need the ability to track but also to display detection confidence in the output.

Let me know in case of any questions. Thanks!

aguscas commented 3 months ago

Doesn't the argument draw_scores of the draw_boxes function allow you to draw the confidences?

utility-aagrawal commented 3 months ago

No, I just gave it a try. draw_scores doesn't seem to work with tracking_objects but works with Detection objects. For my use case, I would need it to work with tracking_objects since I also want tracking object id to keep track of the same object. Let me know if you need anything additional. Thanks!

aguscas commented 3 months ago

Alright, makes sense since the score is an attribute of the Detection instead of the TrackedObject.

I can make a PR to add an score attribute to the TrackedObject to draw it (setting it to None in the TrackedObject. tracker_step method, and setting it equal to detection.score in the TrackedObject.hit method), but we would have to see with @facundo-lezama or @javiber if that would be a desirable feature to have in general before.

Anyway, I am not sure I understood the exact reason you want to be able to draw the score. What did you mean by 'I also want tracking object id to keep track of the same object'?

utility-aagrawal commented 3 months ago

Yeah, PR would be great!

I am using norfair to track faces. When I present my users with the output, I want to show them: 1) detected faces with their confidence 2) if the same person is present in multiple frames, "id" from tracked_object to denote that it's the same person you have seen in other frames so essentially group faces by person.

Does that make sense?

aguscas commented 3 months ago

I made this PR which adds the scores attribute to TrackedObject instances. It is still not merged (since we need to first discuss if that is a feature we would like to have), but you can try installing that version of norfair if you want to use it