Improve detection saving

This commit is contained in:
Nicolas Mowen 2025-08-31 09:07:38 -06:00
parent a12063e19d
commit 5b8b096c13

View File

@ -479,31 +479,36 @@ class ReviewSegmentMaintainer(threading.Thread):
and (segment.last_detection_time + THRESHOLD_DETECTION_ACTIVITY) and (segment.last_detection_time + THRESHOLD_DETECTION_ACTIVITY)
> frame_time > frame_time
) )
last_detection_time = segment.last_detection_time
end_time = self._publish_segment_end(segment, prev_data) end_time = self._publish_segment_end(segment, prev_data)
if needs_new_detection: if needs_new_detection:
new_detections = {} new_detections: dict[str, str] = {}
new_zones = set() new_zones = set()
for o in activity.categorized_objects["detections"]: for o in activity.categorized_objects["detections"]:
new_detections[o["id"]] = o["label"] new_detections[o["id"]] = o["label"]
new_zones.update(o["current_zones"]) new_zones.update(o["current_zones"])
self.active_review_segments[activity.camera_config.name] = ( if new_detections:
PendingReviewSegment( self.active_review_segments[activity.camera_config.name] = (
activity.camera_config.name, PendingReviewSegment(
end_time, activity.camera_config.name,
SeverityEnum.detection, end_time,
new_detections, SeverityEnum.detection,
sub_labels={}, new_detections,
audio=set(), sub_labels={},
zones=list(new_zones), audio=set(),
zones=list(new_zones),
)
) )
) self._publish_segment_start(
self._publish_segment_start( self.active_review_segments[activity.camera_config.name]
self.active_review_segments[activity.camera_config.name] )
) self.active_review_segments[
activity.camera_config.name
].last_detection_time = last_detection_time
elif segment.severity == SeverityEnum.detection and frame_time > ( elif segment.severity == SeverityEnum.detection and frame_time > (
segment.last_detection_time + THRESHOLD_DETECTION_ACTIVITY segment.last_detection_time + THRESHOLD_DETECTION_ACTIVITY
): ):