mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-10-04 11:15:55 +02:00
* config options * processing in maintainer * detect and process dedicated lpr plates * create camera type, add manual event and save snapshot * use const * ensure lpr events are always detections, typing fixes * docs * docs tweaks * add preprocessing and penalization for low confidence chars
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""Facilitates communication between processes."""
|
|
|
|
from enum import Enum
|
|
from typing import Optional
|
|
|
|
from .zmq_proxy import Publisher, Subscriber
|
|
|
|
|
|
class DetectionTypeEnum(str, Enum):
|
|
all = ""
|
|
api = "api"
|
|
video = "video"
|
|
audio = "audio"
|
|
lpr = "lpr"
|
|
|
|
|
|
class DetectionPublisher(Publisher):
|
|
"""Simplifies receiving video and audio detections."""
|
|
|
|
topic_base = "detection/"
|
|
|
|
def __init__(self, topic: DetectionTypeEnum) -> None:
|
|
topic = topic.value
|
|
super().__init__(topic)
|
|
|
|
|
|
class DetectionSubscriber(Subscriber):
|
|
"""Simplifies receiving video and audio detections."""
|
|
|
|
topic_base = "detection/"
|
|
|
|
def __init__(self, topic: DetectionTypeEnum) -> None:
|
|
topic = topic.value
|
|
super().__init__(topic)
|
|
|
|
def check_for_update(
|
|
self, timeout: float = None
|
|
) -> Optional[tuple[DetectionTypeEnum, any]]:
|
|
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)
|