Use norfair uninitialized score history for tracked object and update false positive docs (#8299)

* Update docs

* Use norfair score history to start object history

* Formatting
This commit is contained in:
Nicolas Mowen
2023-10-24 17:24:30 -06:00
committed by GitHub
parent e0e8a6fcc9
commit c141362614
3 changed files with 43 additions and 11 deletions

View File

@@ -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:]

View File

@@ -97,6 +97,12 @@ 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] = {