Add support for arbitrary sub labels in reviews (#10990)

* store arbitrary sub labels

* Include sub labels in tooltip

* Update tooltips on filmstrip

* Fix item display

* Fix bug with creating review segment
This commit is contained in:
Nicolas Mowen
2024-04-16 14:56:28 -06:00
committed by GitHub
parent 9be5951076
commit ff823b87c8
4 changed files with 38 additions and 8 deletions

View File

@@ -46,8 +46,9 @@ class PendingReviewSegment:
frame_time: float,
severity: SeverityEnum,
detections: dict[str, str],
zones: set[str] = set(),
audio: set[str] = set(),
sub_labels: set[str],
zones: set[str],
audio: set[str],
):
rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
self.id = f"{frame_time}-{rand_id}"
@@ -55,6 +56,7 @@ class PendingReviewSegment:
self.start_time = frame_time
self.severity = severity
self.detections = detections
self.sub_labels = sub_labels
self.zones = zones
self.audio = audio
self.last_update = frame_time
@@ -111,6 +113,7 @@ class PendingReviewSegment:
ReviewSegment.data: {
"detections": list(set(self.detections.keys())),
"objects": list(set(self.detections.values())),
"sub_labels": list(self.sub_labels),
"zones": list(self.zones),
"audio": list(self.audio),
},
@@ -181,6 +184,7 @@ class ReviewSegmentMaintainer(threading.Thread):
segment.detections[object["id"]] = object["sub_label"][0]
else:
segment.detections[object["id"]] = f'{object["label"]}-verified'
segment.sub_labels.add(object["sub_label"][0])
# if object is alert label
# and has entered required zones or required zones is not set
@@ -233,8 +237,8 @@ class ReviewSegmentMaintainer(threading.Thread):
active_objects = get_active_objects(frame_time, camera_config, objects)
if len(active_objects) > 0:
has_sig_object = False
detections: dict[str, str] = {}
sub_labels = set()
zones: set = set()
severity = None
@@ -245,6 +249,7 @@ class ReviewSegmentMaintainer(threading.Thread):
detections[object["id"]] = object["sub_label"][0]
else:
detections[object["id"]] = f'{object["label"]}-verified'
sub_labels.add(object["sub_label"][0])
# if object is alert label
# and has entered required zones or required zones is not set
@@ -290,8 +295,9 @@ class ReviewSegmentMaintainer(threading.Thread):
self.active_review_segments[camera] = PendingReviewSegment(
camera,
frame_time,
SeverityEnum.alert if has_sig_object else SeverityEnum.detection,
severity,
detections,
sub_labels=sub_labels,
audio=set(),
zones=zones,
)
@@ -435,6 +441,7 @@ class ReviewSegmentMaintainer(threading.Thread):
severity,
{},
set(),
set(),
detections,
)
elif topic == DetectionTypeEnum.api:
@@ -445,6 +452,7 @@ class ReviewSegmentMaintainer(threading.Thread):
{manual_info["event_id"]: manual_info["label"]},
set(),
set(),
set(),
)
if manual_info["state"] == ManualEventState.start: