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.39k stars 243 forks source link

Enable users to draw custom objects #229

Closed javiber closed 1 year ago

javiber commented 1 year ago

This PR addresses a specific use-case when the users want to draw a TrackedObject but they only have the data of the object and not the instance. This can happen when the TrackedObject is serialized and restored.

It's hard (if not impossible) for users to instantiate a TrackedObject directly when they want to draw it. With this change, the Drawable class can be instantiated directly and then drawn like so:

draw_boxes(
    frame,
    drawables=[
        Drawable(
            points=np.array([[20, 20], [50, 90]]),
            label="person",
            id=123,
            scores=np.array([0.88]),
        )
    ],
)