tryolabs / norfair

Lightweight Python library for adding real-time multi-object tracking to any detector.

Home Page:https://tryolabs.github.io/norfair/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get object/track id and their bbox coordinates for a video?

utility-aagrawal opened this issue · comments

Hi,

I am using norfair to track faces. I want to know how can I get how many distinct objects are there in my video, bbox coordinates for each object. What's the easiest way to fetch this information? I am looking at the code right now but wanted to post the question here in hope of getting a quick response :)

Thanks!

At any given moment when you are iterating over the frames of your video, when you call the Tracker.update method it should return a list with all the different objects that still exist.

So when you do

tracked_objects = tracker.update(detections)

you can know the amount of tracked objects at that instant by doing len(tracked_objects), and the coordinates of the bounding box of each tracked object in the current frame is just the TrackedObject.estimate attribute of each TrackedObject element in the tracked_objects list.

for obj in tracked_objects:
    print(f"bbox of object {obj.id}: {obj.estimate}")

I am not sure if this answered your question.

It does! Thanks so much, @aguscas !