mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-09 15:05:26 +03:00
add config validator for face and lpr
This commit is contained in:
parent
0947bffeef
commit
06ac23c886
@ -292,13 +292,30 @@ def verify_autotrack_zones(camera_config: CameraConfig) -> ValueError | None:
|
|||||||
|
|
||||||
|
|
||||||
def verify_motion_and_detect(camera_config: CameraConfig) -> ValueError | None:
|
def verify_motion_and_detect(camera_config: CameraConfig) -> ValueError | None:
|
||||||
"""Verify that required_zones are specified when autotracking is enabled."""
|
"""Verify that motion detection is not disabled and object detection is enabled."""
|
||||||
if camera_config.detect.enabled and not camera_config.motion.enabled:
|
if camera_config.detect.enabled and not camera_config.motion.enabled:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Camera {camera_config.name} has motion detection disabled and object detection enabled but object detection requires motion detection."
|
f"Camera {camera_config.name} has motion detection disabled and object detection enabled but object detection requires motion detection."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def verify_lpr_and_face(
|
||||||
|
frigate_config: FrigateConfig, camera_config: CameraConfig
|
||||||
|
) -> ValueError | None:
|
||||||
|
"""Verify that lpr and face are enabled at the global level if enabled at the camera level."""
|
||||||
|
if camera_config.lpr.enabled and not frigate_config.lpr.enabled:
|
||||||
|
raise ValueError(
|
||||||
|
f"Camera {camera_config.name} has lpr enabled but lpr is disabled at the global level of the config. You must enable lpr at the global level."
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
camera_config.face_recognition.enabled
|
||||||
|
and not frigate_config.face_recognition.enabled
|
||||||
|
):
|
||||||
|
raise ValueError(
|
||||||
|
f"Camera {camera_config.name} has face_recognition enabled but face_recognition is disabled at the global level of the config. You must enable face_recognition at the global level."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FrigateConfig(FrigateBaseModel):
|
class FrigateConfig(FrigateBaseModel):
|
||||||
version: Optional[str] = Field(default=None, title="Current config version.")
|
version: Optional[str] = Field(default=None, title="Current config version.")
|
||||||
|
|
||||||
@ -607,6 +624,7 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
verify_required_zones_exist(camera_config)
|
verify_required_zones_exist(camera_config)
|
||||||
verify_autotrack_zones(camera_config)
|
verify_autotrack_zones(camera_config)
|
||||||
verify_motion_and_detect(camera_config)
|
verify_motion_and_detect(camera_config)
|
||||||
|
verify_lpr_and_face(self, camera_config)
|
||||||
|
|
||||||
self.objects.parse_all_objects(self.cameras)
|
self.objects.parse_all_objects(self.cameras)
|
||||||
self.model.create_colormap(sorted(self.objects.all_objects))
|
self.model.create_colormap(sorted(self.objects.all_objects))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user