mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-03 22:04:53 +03:00
add validator for detect width and height
require both or neither
This commit is contained in:
parent
257dae11c1
commit
a911735ccb
@ -1,6 +1,6 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field, model_validator
|
||||||
|
|
||||||
from ..base import FrigateBaseModel
|
from ..base import FrigateBaseModel
|
||||||
|
|
||||||
@ -88,3 +88,11 @@ class DetectConfig(FrigateBaseModel):
|
|||||||
title="Annotation offset",
|
title="Annotation offset",
|
||||||
description="Milliseconds to shift detect annotations to better align timeline bounding boxes with recordings; can be positive or negative.",
|
description="Milliseconds to shift detect annotations to better align timeline bounding boxes with recordings; can be positive or negative.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def validate_dimensions(self) -> "DetectConfig":
|
||||||
|
if (self.width is None) != (self.height is None):
|
||||||
|
raise ValueError(
|
||||||
|
"detect -> both width and height must be specified together, or both omitted"
|
||||||
|
)
|
||||||
|
return self
|
||||||
|
|||||||
@ -1188,7 +1188,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
def test_global_detect_merge(self):
|
def test_global_detect_merge(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"detect": {"max_disappeared": 1, "height": 720},
|
"detect": {"max_disappeared": 1, "height": 720, "width": 1280},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user