Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scores attribute to TrackedObject class #311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions norfair/drawing/drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions norfair/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -545,6 +546,7 @@ def tracker_step(self):
self.age += 1
# Advances the tracker's state
self.filter.predict()
self.scores = None

@property
def hit_counter_is_positive(self):
Expand Down Expand Up @@ -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()
Expand Down
Loading