From 8584234b7d7a09001f146e2f8cfc473686fd905a Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sat, 17 Jun 2023 09:31:33 -0500 Subject: [PATCH] populate sublabels for cars with logos --- frigate/events/maintainer.py | 4 ++++ frigate/object_processing.py | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/frigate/events/maintainer.py b/frigate/events/maintainer.py index 0ac73f4f4..264ab1142 100644 --- a/frigate/events/maintainer.py +++ b/frigate/events/maintainer.py @@ -194,6 +194,10 @@ class EventProcessor(threading.Thread): }, } + # only overwrite the sub_label in the database if it's set + if event_data.get("sub_label") is not None: + event[Event.sub_label] = event_data["sub_label"] + ( Event.insert(event) .on_conflict( diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 1359ff773..6d31c3cdd 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -204,6 +204,19 @@ class TrackedObject: if 0 < zone_score < zone.inertia: self.zone_presence[name] = zone_score - 1 + # maintain attributes + for attr in obj_data["attributes"]: + self.attributes.add(attr["label"]) + + # populate the sub_label for car with first logo if it exists + if self.obj_data["label"] == "car" and "sub_label" not in self.obj_data: + recognized_logos = self.attributes.intersection( + set(["ups", "fedex", "amazon"]) + ) + if len(recognized_logos) > 0: + self.obj_data["sub_label"] = recognized_logos.pop() + + # check for significant change if not self.false_positive: # if the zones changed, signal an update if set(self.current_zones) != set(current_zones): @@ -224,9 +237,6 @@ class TrackedObject: if self.obj_data["frame_time"] - self.previous["frame_time"] > 60: significant_change = True - for attr in obj_data["attributes"]: - self.attributes.add(attr["label"]) - self.obj_data.update(obj_data) self.current_zones = current_zones return (thumb_update, significant_change)