populate sublabels for cars with logos

This commit is contained in:
Blake Blackshear 2023-06-17 09:31:33 -05:00
parent 5c60c511d1
commit 8584234b7d
2 changed files with 17 additions and 3 deletions

View File

@ -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) Event.insert(event)
.on_conflict( .on_conflict(

View File

@ -204,6 +204,19 @@ class TrackedObject:
if 0 < zone_score < zone.inertia: if 0 < zone_score < zone.inertia:
self.zone_presence[name] = zone_score - 1 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 not self.false_positive:
# if the zones changed, signal an update # if the zones changed, signal an update
if set(self.current_zones) != set(current_zones): 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: if self.obj_data["frame_time"] - self.previous["frame_time"] > 60:
significant_change = True significant_change = True
for attr in obj_data["attributes"]:
self.attributes.add(attr["label"])
self.obj_data.update(obj_data) self.obj_data.update(obj_data)
self.current_zones = current_zones self.current_zones = current_zones
return (thumb_update, significant_change) return (thumb_update, significant_change)