From ff5b81f82d263cb4a8ee8d5fc210d8efd35c445a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Castro?= Date: Thu, 4 Apr 2024 15:10:43 -0300 Subject: [PATCH 1/2] Add scores attribute to TrackedObject class --- norfair/tracker.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/norfair/tracker.py b/norfair/tracker.py index 275eceee..1b6a44a7 100644 --- a/norfair/tracker.py +++ b/norfair/tracker.py @@ -503,6 +503,7 @@ def __init__( self.last_detection: "Detection" = initial_detection self.age: int = 0 self.is_initializing: bool = self.hit_counter <= self.initialization_delay + self.scores = initial_detection.scores self.initializing_id: Optional[int] = self._obj_factory.get_initializing_id() self.id: Optional[int] = None @@ -545,6 +546,7 @@ def tracker_step(self): self.age += 1 # Advances the tracker's state self.filter.predict() + self.scores = np.array([np.nan] * self.num_points) @property def hit_counter_is_positive(self): @@ -627,6 +629,8 @@ def hit(self, detection: "Detection", period: int = 1): self.last_detection = detection self.hit_counter = min(self.hit_counter + 2 * period, self.hit_counter_max) + self.scores = detection.scores + if self.is_initializing and self.hit_counter > self.initialization_delay: self.is_initializing = False self._acquire_ids() From c9d567f14b073f2bf53d8d714820707092e88d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Castro?= Date: Wed, 10 Apr 2024 13:58:27 -0300 Subject: [PATCH 2/2] Set the scores for TrackedObject Drawables --- norfair/drawing/drawer.py | 5 +---- norfair/tracker.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/norfair/drawing/drawer.py b/norfair/drawing/drawer.py index 83657143..b60ab0e4 100644 --- a/norfair/drawing/drawer.py +++ b/norfair/drawing/drawer.py @@ -340,16 +340,13 @@ def __init__( self.label = obj.label self.scores = obj.scores # TODO: alive points for detections could be the ones over the threshold - # but that info is not available here self.live_points = np.ones(obj.points.shape[0]).astype(bool) elif isinstance(obj, TrackedObject): self.points = obj.estimate self.id = obj.id self.label = obj.label - # TODO: TrackedObject.scores could be an interesting thing to have - # it could be the scores of the last detection or some kind of moving average - self.scores = None + self.scores = obj.scores self.live_points = obj.live_points elif obj is None: self.points = points diff --git a/norfair/tracker.py b/norfair/tracker.py index 1b6a44a7..b9bbd233 100644 --- a/norfair/tracker.py +++ b/norfair/tracker.py @@ -546,7 +546,7 @@ def tracker_step(self): self.age += 1 # Advances the tracker's state self.filter.predict() - self.scores = np.array([np.nan] * self.num_points) + self.scores = None @property def hit_counter_is_positive(self):