1
- from typing import Optional , Sequence , Tuple , Union
1
+ from typing import Any , Optional , Sequence , Tuple , Union
2
2
3
3
import numpy as np
4
4
@@ -304,16 +304,36 @@ class Drawable:
304
304
305
305
Parameters
306
306
----------
307
- obj : Union[Detection, TrackedObject]
307
+ obj : Union[Detection, TrackedObject], optional
308
308
A [Detection][norfair.tracker.Detection] or a [TrackedObject][norfair.tracker.TrackedObject]
309
+ that will be used to initialized the drawable.
310
+ If this parameter is passed, all other arguments are ignored
311
+ points : np.ndarray, optional
312
+ Points included in the drawable, shape is `(N_points, N_dimensions)`. Ignored if `obj` is passed
313
+ id : Any, optional
314
+ Id of this object. Ignored if `obj` is passed
315
+ label : Any, optional
316
+ Label specifying the class of the object. Ignored if `obj` is passed
317
+ scores : np.ndarray, optional
318
+ Confidence scores of each point, shape is `(N_points,)`. Ignored if `obj` is passed
319
+ live_points : np.ndarray, optional
320
+ Bolean array indicating which points are alive, shape is `(N_points,)`. Ignored if `obj` is passed
309
321
310
322
Raises
311
323
------
312
324
ValueError
313
325
If obj is not an instance of the supported classes.
314
326
"""
315
327
316
- def __init__ (self , obj : Union [Detection , TrackedObject ]) -> None :
328
+ def __init__ (
329
+ self ,
330
+ obj : Union [Detection , TrackedObject ] = None ,
331
+ points : np .ndarray = None ,
332
+ id : Any = None ,
333
+ label : Any = None ,
334
+ scores : np .ndarray = None ,
335
+ live_points : np .ndarray = None ,
336
+ ) -> None :
317
337
if isinstance (obj , Detection ):
318
338
self .points = obj .points
319
339
self .id = None
@@ -331,6 +351,12 @@ def __init__(self, obj: Union[Detection, TrackedObject]) -> None:
331
351
# it could be the scores of the last detection or some kind of moving average
332
352
self .scores = None
333
353
self .live_points = obj .live_points
354
+ elif obj is None :
355
+ self .points = points
356
+ self .id = id
357
+ self .label = label
358
+ self .scores = scores
359
+ self .live_points = live_points
334
360
else :
335
361
raise ValueError (
336
362
f"Extecting a Detection or a TrackedObject but received { type (obj )} "
0 commit comments