fix birdseye config

This commit is contained in:
Blake Blackshear 2022-04-16 08:44:04 -05:00
parent b86b2d6602
commit a1afade9ba
2 changed files with 34 additions and 9 deletions

View File

@ -326,7 +326,8 @@ class BirdseyeConfig(FrigateBaseModel):
) )
class BirdseyeCameraConfig(FrigateBaseModel): # uses BaseModel because some global attributes are not available at the camera level
class BirdseyeCameraConfig(BaseModel):
enabled: bool = Field(default=True, title="Enable birdseye view for camera.") enabled: bool = Field(default=True, title="Enable birdseye view for camera.")
mode: BirdseyeModeEnum = Field( mode: BirdseyeModeEnum = Field(
default=BirdseyeModeEnum.objects, title="Tracking mode for camera." default=BirdseyeModeEnum.objects, title="Tracking mode for camera."

View File

@ -84,7 +84,7 @@ class TestConfig(unittest.TestCase):
def test_override_birdseye(self): def test_override_birdseye(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"birdseye": { "enabled": True, "mode": "continuous" }, "birdseye": {"enabled": True, "mode": "continuous"},
"cameras": { "cameras": {
"back": { "back": {
"ffmpeg": { "ffmpeg": {
@ -97,10 +97,7 @@ class TestConfig(unittest.TestCase):
"width": 1920, "width": 1920,
"fps": 5, "fps": 5,
}, },
"birdseye": { "birdseye": {"enabled": False, "mode": "motion"},
"enabled": False,
"mode": "motion"
},
} }
}, },
} }
@ -111,10 +108,10 @@ class TestConfig(unittest.TestCase):
assert not runtime_config.cameras["back"].birdseye.enabled assert not runtime_config.cameras["back"].birdseye.enabled
assert runtime_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.motion assert runtime_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.motion
def test_inherit_birdseye(self): def test_override_birdseye_non_inheritable(self):
config = { config = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
"birdseye": { "enabled": True, "mode": "continuous" }, "birdseye": {"enabled": True, "mode": "continuous", "height": 1920},
"cameras": { "cameras": {
"back": { "back": {
"ffmpeg": { "ffmpeg": {
@ -135,7 +132,34 @@ class TestConfig(unittest.TestCase):
runtime_config = frigate_config.runtime_config runtime_config = frigate_config.runtime_config
assert runtime_config.cameras["back"].birdseye.enabled assert runtime_config.cameras["back"].birdseye.enabled
assert runtime_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.continuous
def test_inherit_birdseye(self):
config = {
"mqtt": {"host": "mqtt"},
"birdseye": {"enabled": True, "mode": "continuous"},
"cameras": {
"back": {
"ffmpeg": {
"inputs": [
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
]
},
"detect": {
"height": 1080,
"width": 1920,
"fps": 5,
},
}
},
}
frigate_config = FrigateConfig(**config)
assert config == frigate_config.dict(exclude_unset=True)
runtime_config = frigate_config.runtime_config
assert runtime_config.cameras["back"].birdseye.enabled
assert (
runtime_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.continuous
)
def test_override_tracked_objects(self): def test_override_tracked_objects(self):
config = { config = {