2024-10-26 19:07:45 +02:00
|
|
|
from typing import Dict, List, Optional
|
2024-09-28 21:21:42 +02:00
|
|
|
|
|
|
|
from pydantic import Field
|
|
|
|
|
|
|
|
from .base import FrigateBaseModel
|
|
|
|
|
2024-10-26 19:07:45 +02:00
|
|
|
__all__ = [
|
|
|
|
"FaceRecognitionConfig",
|
|
|
|
"SemanticSearchConfig",
|
|
|
|
"LicensePlateRecognitionConfig",
|
|
|
|
]
|
2024-10-23 00:05:48 +02:00
|
|
|
|
|
|
|
|
2025-01-13 16:09:04 +01:00
|
|
|
class BirdClassificationConfig(FrigateBaseModel):
|
|
|
|
enabled: bool = Field(default=False, title="Enable bird classification.")
|
|
|
|
threshold: float = Field(
|
|
|
|
default=0.9,
|
|
|
|
title="Minimum classification score required to be considered a match.",
|
|
|
|
gt=0.0,
|
|
|
|
le=1.0,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class ClassificationConfig(FrigateBaseModel):
|
|
|
|
bird: BirdClassificationConfig = Field(
|
|
|
|
default_factory=BirdClassificationConfig, title="Bird classification config."
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-09-28 21:21:42 +02:00
|
|
|
class SemanticSearchConfig(FrigateBaseModel):
|
|
|
|
enabled: bool = Field(default=False, title="Enable semantic search.")
|
|
|
|
reindex: Optional[bool] = Field(
|
|
|
|
default=False, title="Reindex all detections on startup."
|
|
|
|
)
|
2024-10-11 00:46:21 +02:00
|
|
|
model_size: str = Field(
|
|
|
|
default="small", title="The size of the embeddings model used."
|
|
|
|
)
|
2024-10-23 17:03:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
class FaceRecognitionConfig(FrigateBaseModel):
|
|
|
|
enabled: bool = Field(default=False, title="Enable face recognition.")
|
2024-12-31 22:56:01 +01:00
|
|
|
min_score: float = Field(
|
|
|
|
title="Minimum face distance score required to save the attempt.",
|
|
|
|
default=0.8,
|
|
|
|
gt=0.0,
|
|
|
|
le=1.0,
|
|
|
|
)
|
2024-10-23 17:03:18 +02:00
|
|
|
threshold: float = Field(
|
2024-12-31 22:56:01 +01:00
|
|
|
default=0.9,
|
|
|
|
title="Minimum face distance score required to be considered a match.",
|
2024-11-26 21:41:49 +01:00
|
|
|
gt=0.0,
|
|
|
|
le=1.0,
|
2024-10-23 17:03:18 +02:00
|
|
|
)
|
|
|
|
min_area: int = Field(
|
|
|
|
default=500, title="Min area of face box to consider running face recognition."
|
|
|
|
)
|
2024-12-31 22:56:01 +01:00
|
|
|
save_attempts: bool = Field(
|
|
|
|
default=True, title="Save images of face detections for training."
|
2024-12-26 03:52:35 +01:00
|
|
|
)
|
2024-10-26 19:07:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class LicensePlateRecognitionConfig(FrigateBaseModel):
|
|
|
|
enabled: bool = Field(default=False, title="Enable license plate recognition.")
|
2025-02-14 23:12:36 +01:00
|
|
|
detection_threshold: float = Field(
|
|
|
|
default=0.7,
|
|
|
|
title="License plate object confidence score required to begin running recognition.",
|
|
|
|
gt=0.0,
|
|
|
|
le=1.0,
|
2024-10-26 19:07:45 +02:00
|
|
|
)
|
|
|
|
min_area: int = Field(
|
2025-02-14 00:08:56 +01:00
|
|
|
default=1000,
|
2025-02-14 23:12:36 +01:00
|
|
|
title="Minimum area of license plate to begin running recognition.",
|
|
|
|
)
|
|
|
|
recognition_threshold: float = Field(
|
|
|
|
default=0.9,
|
|
|
|
title="Recognition confidence score required to add the plate to the object as a sub label.",
|
|
|
|
gt=0.0,
|
|
|
|
le=1.0,
|
2025-02-14 00:08:56 +01:00
|
|
|
)
|
|
|
|
min_plate_length: int = Field(
|
|
|
|
default=4,
|
|
|
|
title="Minimum number of characters a license plate must have to be added to the object as a sub label.",
|
|
|
|
)
|
2025-02-14 23:12:36 +01:00
|
|
|
format: Optional[str] = Field(
|
|
|
|
default=None,
|
|
|
|
title="Regular expression for the expected format of license plate.",
|
|
|
|
)
|
2025-02-14 00:08:56 +01:00
|
|
|
match_distance: int = Field(
|
|
|
|
default=1,
|
|
|
|
title="Allow this number of missing/incorrect characters to still cause a detected plate to match a known plate.",
|
2025-02-14 23:12:36 +01:00
|
|
|
ge=0,
|
2024-10-26 19:07:45 +02:00
|
|
|
)
|
|
|
|
known_plates: Optional[Dict[str, List[str]]] = Field(
|
2025-02-14 23:12:36 +01:00
|
|
|
default={}, title="Known plates to track (strings or regular expressions)."
|
2024-10-26 19:07:45 +02:00
|
|
|
)
|