mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-26 13:47:03 +02:00
Cleanup detections updater
This commit is contained in:
parent
107007a636
commit
0250db70d0
@ -3,7 +3,7 @@
|
||||
import multiprocessing as mp
|
||||
from _pickle import UnpicklingError
|
||||
from multiprocessing.synchronize import Event as MpEvent
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
import zmq
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Facilitates communication between processes."""
|
||||
|
||||
from enum import Enum
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from .zmq_proxy import Publisher, Subscriber
|
||||
|
||||
@ -19,8 +19,7 @@ class DetectionPublisher(Publisher):
|
||||
|
||||
topic_base = "detection/"
|
||||
|
||||
def __init__(self, topic: DetectionTypeEnum) -> None:
|
||||
topic = topic.value
|
||||
def __init__(self, topic: str) -> None:
|
||||
super().__init__(topic)
|
||||
|
||||
|
||||
@ -29,16 +28,15 @@ class DetectionSubscriber(Subscriber):
|
||||
|
||||
topic_base = "detection/"
|
||||
|
||||
def __init__(self, topic: DetectionTypeEnum) -> None:
|
||||
topic = topic.value
|
||||
def __init__(self, topic: str) -> None:
|
||||
super().__init__(topic)
|
||||
|
||||
def check_for_update(
|
||||
self, timeout: float = None
|
||||
) -> Optional[tuple[DetectionTypeEnum, Any]]:
|
||||
self, timeout: float | None = None
|
||||
) -> tuple[str, Any] | tuple[None, None]:
|
||||
return super().check_for_update(timeout)
|
||||
|
||||
def _return_object(self, topic: str, payload: Any) -> Any:
|
||||
if payload is None:
|
||||
return (None, None)
|
||||
return (DetectionTypeEnum[topic[len(self.topic_base) :]], payload)
|
||||
return (topic[len(self.topic_base) :], payload)
|
||||
|
@ -83,7 +83,7 @@ class Subscriber:
|
||||
self.socket.connect(SOCKET_SUB)
|
||||
|
||||
def check_for_update(
|
||||
self, timeout: float = FAST_QUEUE_TIMEOUT
|
||||
self, timeout: float | None = FAST_QUEUE_TIMEOUT
|
||||
) -> tuple[str, Any] | tuple[None, None]:
|
||||
"""Returns message or None if no update."""
|
||||
try:
|
||||
|
@ -143,7 +143,7 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
self.recordings_subscriber = RecordingsDataSubscriber(
|
||||
RecordingsDataTypeEnum.recordings_available_through
|
||||
)
|
||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video)
|
||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video.value)
|
||||
self.embeddings_responder = EmbeddingsResponder()
|
||||
self.frame_manager = SharedMemoryFrameManager()
|
||||
|
||||
|
@ -183,7 +183,7 @@ class AudioEventMaintainer(threading.Thread):
|
||||
CameraConfigUpdateEnum.audio_transcription,
|
||||
],
|
||||
)
|
||||
self.detection_publisher = DetectionPublisher(DetectionTypeEnum.audio)
|
||||
self.detection_publisher = DetectionPublisher(DetectionTypeEnum.audio.value)
|
||||
self.event_metadata_publisher = EventMetadataPublisher()
|
||||
|
||||
if self.camera_config.audio_transcription.enabled_in_config:
|
||||
|
@ -96,7 +96,7 @@ class OutputProcess(FrigateProcess):
|
||||
websocket_server.initialize_websockets_manager()
|
||||
websocket_thread = threading.Thread(target=websocket_server.serve_forever)
|
||||
|
||||
detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video)
|
||||
detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video.value)
|
||||
config_subscriber = CameraConfigUpdateSubscriber(
|
||||
self.config,
|
||||
self.config.cameras,
|
||||
|
@ -79,7 +79,7 @@ class RecordingMaintainer(threading.Thread):
|
||||
self.config.cameras,
|
||||
[CameraConfigUpdateEnum.add, CameraConfigUpdateEnum.record],
|
||||
)
|
||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all)
|
||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all.value)
|
||||
self.recordings_publisher = RecordingsDataPublisher(
|
||||
RecordingsDataTypeEnum.recordings_available_through
|
||||
)
|
||||
@ -545,7 +545,7 @@ class RecordingMaintainer(threading.Thread):
|
||||
if not topic:
|
||||
break
|
||||
|
||||
if topic == DetectionTypeEnum.video:
|
||||
if topic == DetectionTypeEnum.video.value:
|
||||
(
|
||||
camera,
|
||||
_,
|
||||
@ -564,7 +564,7 @@ class RecordingMaintainer(threading.Thread):
|
||||
regions,
|
||||
)
|
||||
)
|
||||
elif topic == DetectionTypeEnum.audio:
|
||||
elif topic == DetectionTypeEnum.audio.value:
|
||||
(
|
||||
camera,
|
||||
frame_time,
|
||||
@ -580,7 +580,7 @@ class RecordingMaintainer(threading.Thread):
|
||||
audio_detections,
|
||||
)
|
||||
)
|
||||
elif topic == DetectionTypeEnum.api or DetectionTypeEnum.lpr:
|
||||
elif topic == DetectionTypeEnum.api.value or DetectionTypeEnum.lpr.value:
|
||||
continue
|
||||
|
||||
if frame_time < run_start - stale_frame_count_threshold:
|
||||
|
@ -164,7 +164,7 @@ class ReviewSegmentMaintainer(threading.Thread):
|
||||
CameraConfigUpdateEnum.review,
|
||||
],
|
||||
)
|
||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all)
|
||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all.value)
|
||||
|
||||
# manual events
|
||||
self.indefinite_events: dict[str, dict[str, Any]] = {}
|
||||
@ -484,7 +484,7 @@ class ReviewSegmentMaintainer(threading.Thread):
|
||||
if not topic:
|
||||
continue
|
||||
|
||||
if topic == DetectionTypeEnum.video:
|
||||
if topic == DetectionTypeEnum.video.value:
|
||||
(
|
||||
camera,
|
||||
frame_name,
|
||||
@ -493,14 +493,14 @@ class ReviewSegmentMaintainer(threading.Thread):
|
||||
_,
|
||||
_,
|
||||
) = data
|
||||
elif topic == DetectionTypeEnum.audio:
|
||||
elif topic == DetectionTypeEnum.audio.value:
|
||||
(
|
||||
camera,
|
||||
frame_time,
|
||||
_,
|
||||
audio_detections,
|
||||
) = data
|
||||
elif topic == DetectionTypeEnum.api or DetectionTypeEnum.lpr:
|
||||
elif topic == DetectionTypeEnum.api.value or DetectionTypeEnum.lpr.value:
|
||||
(
|
||||
camera,
|
||||
frame_time,
|
||||
|
@ -78,7 +78,7 @@ class TrackedObjectProcessor(threading.Thread):
|
||||
)
|
||||
|
||||
self.requestor = InterProcessRequestor()
|
||||
self.detection_publisher = DetectionPublisher(DetectionTypeEnum.all)
|
||||
self.detection_publisher = DetectionPublisher(DetectionTypeEnum.all.value)
|
||||
self.event_sender = EventUpdatePublisher()
|
||||
self.event_end_subscriber = EventEndSubscriber()
|
||||
self.sub_label_subscriber = EventMetadataSubscriber(EventMetadataTypeEnum.all)
|
||||
|
Loading…
Reference in New Issue
Block a user