* Use list for zones to keep chronological order

* Replace when changing playbackRate
This commit is contained in:
Nicolas Mowen 2024-06-25 06:38:37 -06:00 committed by GitHub
parent c3455518c2
commit bfbacee7b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View File

@ -53,7 +53,7 @@ class PendingReviewSegment:
severity: SeverityEnum, severity: SeverityEnum,
detections: dict[str, str], detections: dict[str, str],
sub_labels: set[str], sub_labels: set[str],
zones: set[str], zones: list[str],
audio: set[str], audio: set[str],
): ):
rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6)) rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
@ -137,7 +137,7 @@ class PendingReviewSegment:
"detections": list(set(self.detections.keys())), "detections": list(set(self.detections.keys())),
"objects": list(set(self.detections.values())), "objects": list(set(self.detections.values())),
"sub_labels": list(self.sub_labels), "sub_labels": list(self.sub_labels),
"zones": list(self.zones), "zones": self.zones,
"audio": list(self.audio), "audio": list(self.audio),
}, },
}.copy() }.copy()
@ -279,7 +279,9 @@ class ReviewSegmentMaintainer(threading.Thread):
# keep zones up to date # keep zones up to date
if len(object["current_zones"]) > 0: if len(object["current_zones"]) > 0:
segment.zones.update(object["current_zones"]) for zone in object["current_zones"]:
if zone not in segment.zones:
segment.zones.append(zone)
if len(active_objects) > segment.frame_active_count: if len(active_objects) > segment.frame_active_count:
should_update = True should_update = True
@ -329,7 +331,7 @@ class ReviewSegmentMaintainer(threading.Thread):
if len(active_objects) > 0: if len(active_objects) > 0:
detections: dict[str, str] = {} detections: dict[str, str] = {}
sub_labels = set() sub_labels = set()
zones: set = set() zones: list[str] = []
severity = None severity = None
for object in active_objects: for object in active_objects:
@ -379,7 +381,9 @@ class ReviewSegmentMaintainer(threading.Thread):
): ):
severity = SeverityEnum.detection severity = SeverityEnum.detection
zones.update(object["current_zones"]) for zone in object["current_zones"]:
if zone not in zones:
zones.append(zone)
if severity: if severity:
self.active_review_segments[camera] = PendingReviewSegment( self.active_review_segments[camera] = PendingReviewSegment(
@ -534,7 +538,7 @@ class ReviewSegmentMaintainer(threading.Thread):
severity, severity,
{}, {},
set(), set(),
set(), [],
detections, detections,
) )
elif topic == DetectionTypeEnum.api: elif topic == DetectionTypeEnum.api:
@ -544,7 +548,7 @@ class ReviewSegmentMaintainer(threading.Thread):
SeverityEnum.alert, SeverityEnum.alert,
{manual_info["event_id"]: manual_info["label"]}, {manual_info["event_id"]: manual_info["label"]},
set(), set(),
set(), [],
set(), set(),
) )

View File

@ -202,7 +202,7 @@ export default function HlsVideoPlayer({
videoRef.current.currentTime = Math.max(0, currentTime + diff); videoRef.current.currentTime = Math.max(0, currentTime + diff);
}} }}
onSetPlaybackRate={(rate) => { onSetPlaybackRate={(rate) => {
setPlaybackRate(rate); setPlaybackRate(rate, true);
if (videoRef.current) { if (videoRef.current) {
videoRef.current.playbackRate = rate; videoRef.current.playbackRate = rate;