From ae650a112847f167c11c27140f31785fb1676eb3 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Tue, 24 Oct 2023 07:48:04 -0600 Subject: [PATCH] Use norfair score history to start object history --- frigate/object_processing.py | 12 +++++++----- frigate/track/norfair_tracker.py | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 94855a398..64794361f 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -105,6 +105,10 @@ class TrackedObject: def __init__( self, camera, colormap, camera_config: CameraConfig, frame_cache, obj_data ): + # set the score history then remove as it is not part of object state + self.score_history = obj_data["score_history"] + del obj_data["score_history"] + self.obj_data = obj_data self.camera = camera self.colormap = colormap @@ -136,11 +140,8 @@ class TrackedObject: return self.computed_score < threshold def compute_score(self): - scores = self.score_history[:] - # pad with zeros if you dont have at least 3 scores - if len(scores) < 3: - scores += [0.0] * (3 - len(scores)) - return median(scores) + """get median of scores for object.""" + return median(self.score_history) def update(self, current_frame_time, obj_data): thumb_update = False @@ -151,6 +152,7 @@ class TrackedObject: self.score_history.append(0.0) else: self.score_history.append(obj_data["score"]) + # only keep the last 10 scores if len(self.score_history) > 10: self.score_history = self.score_history[-10:] diff --git a/frigate/track/norfair_tracker.py b/frigate/track/norfair_tracker.py index e11a38d44..185009d29 100644 --- a/frigate/track/norfair_tracker.py +++ b/frigate/track/norfair_tracker.py @@ -97,6 +97,7 @@ class NorfairTracker(ObjectTracker): obj["start_time"] = obj["frame_time"] obj["motionless_count"] = 0 obj["position_changes"] = 0 + obj["score_history"] = [p.data['score'] for p in next((o for o in self.tracker.tracked_objects if o.global_id == track_id)).past_detections] self.tracked_objects[id] = obj self.disappeared[id] = 0 self.positions[id] = {