2021-06-24 07:45:27 +02:00
|
|
|
import unittest
|
|
|
|
import numpy as np
|
|
|
|
from pydantic import ValidationError
|
2022-11-09 02:47:45 +01:00
|
|
|
|
2021-06-24 07:45:27 +02:00
|
|
|
from frigate.config import (
|
2022-04-15 13:59:30 +02:00
|
|
|
BirdseyeModeEnum,
|
2021-06-24 07:45:27 +02:00
|
|
|
FrigateConfig,
|
|
|
|
DetectorTypeEnum,
|
|
|
|
)
|
2022-11-09 02:47:45 +01:00
|
|
|
from frigate.util import load_config_with_no_duplicates
|
2020-11-01 13:17:44 +01:00
|
|
|
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2021-06-24 07:45:27 +02:00
|
|
|
class TestConfig(unittest.TestCase):
|
2020-11-03 15:15:58 +01:00
|
|
|
def setUp(self):
|
|
|
|
self.minimal = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2021-06-24 07:45:27 +02:00
|
|
|
def test_config_class(self):
|
|
|
|
frigate_config = FrigateConfig(**self.minimal)
|
|
|
|
assert self.minimal == frigate_config.dict(exclude_unset=True)
|
2020-11-01 13:17:44 +01:00
|
|
|
|
2021-06-24 07:45:27 +02:00
|
|
|
runtime_config = frigate_config.runtime_config
|
2021-08-28 15:16:25 +02:00
|
|
|
assert "cpu" in runtime_config.detectors.keys()
|
|
|
|
assert runtime_config.detectors["cpu"].type == DetectorTypeEnum.cpu
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2021-06-24 07:45:27 +02:00
|
|
|
def test_invalid_mqtt_config(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt", "user": "test"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-06-24 07:45:27 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
self.assertRaises(ValidationError, lambda: FrigateConfig(**config))
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-11-03 15:15:58 +01:00
|
|
|
def test_inherit_tracked_objects(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"objects": {"track": ["person", "dog"]},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "dog" in runtime_config.cameras["back"].objects.track
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2022-04-15 13:59:30 +02:00
|
|
|
def test_override_birdseye(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2022-04-16 15:44:04 +02:00
|
|
|
"birdseye": {"enabled": True, "mode": "continuous"},
|
2022-04-15 13:59:30 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2022-04-16 15:44:04 +02:00
|
|
|
"birdseye": {"enabled": False, "mode": "motion"},
|
2022-04-15 13:59:30 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert not runtime_config.cameras["back"].birdseye.enabled
|
|
|
|
assert runtime_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.motion
|
|
|
|
|
2022-04-16 15:44:04 +02:00
|
|
|
def test_override_birdseye_non_inheritable(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"birdseye": {"enabled": True, "mode": "continuous", "height": 1920},
|
|
|
|
"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
|
|
|
|
|
2022-04-15 13:59:30 +02:00
|
|
|
def test_inherit_birdseye(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2022-04-16 15:44:04 +02:00
|
|
|
"birdseye": {"enabled": True, "mode": "continuous"},
|
2022-04-15 13:59:30 +02:00
|
|
|
"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
|
2022-04-16 15:44:04 +02:00
|
|
|
assert (
|
|
|
|
runtime_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.continuous
|
|
|
|
)
|
2022-04-15 13:59:30 +02:00
|
|
|
|
2020-11-03 15:15:58 +01:00
|
|
|
def test_override_tracked_objects(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"objects": {"track": ["person", "dog"]},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"objects": {"track": ["cat"]},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "cat" in runtime_config.cameras["back"].objects.track
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-11-03 15:15:58 +01:00
|
|
|
def test_default_object_filters(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"objects": {"track": ["person", "dog"]},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "dog" in runtime_config.cameras["back"].objects.filters
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-11-03 15:15:58 +01:00
|
|
|
def test_inherit_object_filters(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"objects": {
|
|
|
|
"track": ["person", "dog"],
|
|
|
|
"filters": {"dog": {"threshold": 0.7}},
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "dog" in runtime_config.cameras["back"].objects.filters
|
|
|
|
assert runtime_config.cameras["back"].objects.filters["dog"].threshold == 0.7
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-11-03 15:15:58 +01:00
|
|
|
def test_override_object_filters(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"objects": {
|
|
|
|
"track": ["person", "dog"],
|
|
|
|
"filters": {"dog": {"threshold": 0.7}},
|
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-03 15:15:58 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "dog" in runtime_config.cameras["back"].objects.filters
|
|
|
|
assert runtime_config.cameras["back"].objects.filters["dog"].threshold == 0.7
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2021-02-06 13:30:26 +01:00
|
|
|
def test_global_object_mask(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"objects": {"track": ["person", "dog"]},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2021-02-06 13:30:26 +01:00
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"objects": {
|
|
|
|
"mask": "0,0,1,1,0,1",
|
|
|
|
"filters": {"dog": {"mask": "1,1,1,1,1,1"}},
|
|
|
|
},
|
2021-02-06 13:30:26 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2021-02-06 13:30:26 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
back_camera = runtime_config.cameras["back"]
|
|
|
|
assert "dog" in back_camera.objects.filters
|
|
|
|
assert len(back_camera.objects.filters["dog"].raw_mask) == 2
|
|
|
|
assert len(back_camera.objects.filters["person"].raw_mask) == 1
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2021-07-10 03:21:35 +02:00
|
|
|
def test_default_input_args(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-07-10 03:21:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "-rtsp_transport" in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
|
|
|
|
2021-02-05 14:22:33 +01:00
|
|
|
def test_ffmpeg_params_global(self):
|
2020-11-03 15:15:58 +01:00
|
|
|
config = {
|
2021-06-24 22:45:15 +02:00
|
|
|
"ffmpeg": {"input_args": "-re"},
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-03 15:15:58 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"objects": {
|
|
|
|
"track": ["person", "dog"],
|
|
|
|
"filters": {"dog": {"threshold": 0.7}},
|
|
|
|
},
|
2020-11-01 13:17:44 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-01 13:17:44 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "-re" in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
2021-02-05 14:22:33 +01:00
|
|
|
|
|
|
|
def test_ffmpeg_params_camera(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-06-24 22:45:15 +02:00
|
|
|
"ffmpeg": {"input_args": ["test"]},
|
2021-02-17 14:23:32 +01:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2021-02-05 14:22:33 +01:00
|
|
|
],
|
2021-02-17 14:23:32 +01:00
|
|
|
"input_args": ["-re"],
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"objects": {
|
|
|
|
"track": ["person", "dog"],
|
|
|
|
"filters": {"dog": {"threshold": 0.7}},
|
2021-02-05 14:22:33 +01:00
|
|
|
},
|
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2021-02-05 14:22:33 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "-re" in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
2021-06-24 22:45:15 +02:00
|
|
|
assert "test" not in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
2021-02-05 14:22:33 +01:00
|
|
|
|
|
|
|
def test_ffmpeg_params_input(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-06-24 22:45:15 +02:00
|
|
|
"ffmpeg": {"input_args": ["test2"]},
|
2021-02-17 14:23:32 +01:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
2021-06-24 22:45:15 +02:00
|
|
|
"input_args": "-re test",
|
2021-02-17 14:23:32 +01:00
|
|
|
}
|
2021-06-24 22:45:15 +02:00
|
|
|
],
|
|
|
|
"input_args": "test3",
|
2021-02-05 14:22:33 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"objects": {
|
|
|
|
"track": ["person", "dog"],
|
|
|
|
"filters": {"dog": {"threshold": 0.7}},
|
|
|
|
},
|
2021-02-05 14:22:33 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2021-02-05 14:22:33 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert "-re" in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
2021-06-24 22:45:15 +02:00
|
|
|
assert "test" in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
|
|
|
assert "test2" not in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
|
|
|
assert "test3" not in runtime_config.cameras["back"].ffmpeg_cmds[0]["cmd"]
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-12-23 14:16:37 +01:00
|
|
|
def test_inherit_clips_retention(self):
|
2020-11-23 15:25:46 +01:00
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-08-15 15:30:27 +02:00
|
|
|
"record": {
|
|
|
|
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
2020-11-23 15:25:46 +01:00
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2020-11-23 15:25:46 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-23 15:25:46 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2021-08-15 15:30:27 +02:00
|
|
|
assert (
|
|
|
|
runtime_config.cameras["back"].record.events.retain.objects["person"] == 30
|
|
|
|
)
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-11-29 22:55:53 +01:00
|
|
|
def test_roles_listed_twice_throws_error(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-08-15 15:30:27 +02:00
|
|
|
"record": {
|
|
|
|
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]},
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video2", "roles": ["detect"]},
|
2020-11-29 22:55:53 +01:00
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2020-11-29 22:55:53 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-29 22:55:53 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
self.assertRaises(ValidationError, lambda: FrigateConfig(**config))
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-11-30 02:00:46 +01:00
|
|
|
def test_zone_matching_camera_name_throws_error(self):
|
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-08-15 15:30:27 +02:00
|
|
|
"record": {
|
|
|
|
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-11-30 02:00:46 +01:00
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"zones": {"back": {"coordinates": "1,1,1,1,1,1"}},
|
2020-11-30 02:00:46 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-11-30 02:00:46 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
self.assertRaises(ValidationError, lambda: FrigateConfig(**config))
|
|
|
|
|
|
|
|
def test_zone_assigns_color_and_contour(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-08-15 15:30:27 +02:00
|
|
|
"record": {
|
|
|
|
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
|
|
|
},
|
2021-06-24 07:45:27 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-06-24 07:45:27 +02:00
|
|
|
"zones": {"test": {"coordinates": "1,1,1,1,1,1"}},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert isinstance(
|
|
|
|
runtime_config.cameras["back"].zones["test"].contour, np.ndarray
|
|
|
|
)
|
|
|
|
assert runtime_config.cameras["back"].zones["test"].color != (0, 0, 0)
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-12-23 14:16:37 +01:00
|
|
|
def test_clips_should_default_to_global_objects(self):
|
2020-12-04 13:59:03 +01:00
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-08-15 15:30:27 +02:00
|
|
|
"record": {
|
|
|
|
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
|
|
|
},
|
2021-02-17 14:23:32 +01:00
|
|
|
"objects": {"track": ["person", "dog"]},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
2020-12-04 13:59:03 +01:00
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-09-08 15:02:26 +02:00
|
|
|
"record": {"events": {}},
|
2020-12-04 13:59:03 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-12-04 13:59:03 +01:00
|
|
|
}
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
back_camera = runtime_config.cameras["back"]
|
2021-08-15 15:30:27 +02:00
|
|
|
assert back_camera.record.events.objects is None
|
|
|
|
assert back_camera.record.events.retain.objects["person"] == 30
|
2021-02-17 14:23:32 +01:00
|
|
|
|
2020-12-07 15:07:35 +01:00
|
|
|
def test_role_assigned_but_not_enabled(self):
|
2021-06-24 07:45:27 +02:00
|
|
|
config = {
|
2021-02-17 14:23:32 +01:00
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
2022-11-02 12:36:09 +01:00
|
|
|
"roles": ["detect", "rtmp", "restream"],
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
|
|
|
{"path": "rtsp://10.0.0.1:554/record", "roles": ["record"]},
|
2020-12-07 15:07:35 +01:00
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2020-12-07 15:07:35 +01:00
|
|
|
}
|
2021-02-17 14:23:32 +01:00
|
|
|
},
|
2020-12-07 15:07:35 +01:00
|
|
|
}
|
|
|
|
|
2021-06-24 07:45:27 +02:00
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
ffmpeg_cmds = runtime_config.cameras["back"].ffmpeg_cmds
|
2021-02-17 14:23:32 +01:00
|
|
|
assert len(ffmpeg_cmds) == 1
|
|
|
|
assert not "clips" in ffmpeg_cmds[0]["roles"]
|
2020-12-07 15:07:35 +01:00
|
|
|
|
2021-06-26 20:18:06 +02:00
|
|
|
def test_max_disappeared_default(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"enabled": True,
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-06-26 20:18:06 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].detect.max_disappeared == 5 * 5
|
|
|
|
|
2021-07-01 14:47:22 +02:00
|
|
|
def test_motion_frame_height_wont_go_below_120(self):
|
2021-07-01 14:33:53 +02:00
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-07-01 14:33:53 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2022-01-14 14:31:25 +01:00
|
|
|
assert runtime_config.cameras["back"].motion.frame_height == 50
|
2021-07-01 14:47:22 +02:00
|
|
|
|
|
|
|
def test_motion_contour_area_dynamic(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-07-01 14:47:22 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2022-01-14 14:31:25 +01:00
|
|
|
assert round(runtime_config.cameras["back"].motion.contour_area) == 30
|
2021-07-01 14:33:53 +02:00
|
|
|
|
2021-07-08 05:57:19 +02:00
|
|
|
def test_merge_labelmap(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"model": {"labelmap": {7: "truck"}},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-07-08 05:57:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.model.merged_labelmap[7] == "truck"
|
|
|
|
|
|
|
|
def test_default_labelmap_empty(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-07-08 05:57:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.model.merged_labelmap[0] == "person"
|
|
|
|
|
|
|
|
def test_default_labelmap(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"model": {"width": 320, "height": 320},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-08-14 21:18:35 +02:00
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
2021-07-08 05:57:19 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.model.merged_labelmap[0] == "person"
|
|
|
|
|
2021-08-28 15:16:25 +02:00
|
|
|
def test_fails_on_invalid_role(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
2021-10-23 02:41:28 +02:00
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video2",
|
|
|
|
"roles": ["clips"],
|
2021-08-28 15:16:25 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
self.assertRaises(ValidationError, lambda: FrigateConfig(**config))
|
|
|
|
|
2021-10-23 02:41:28 +02:00
|
|
|
def test_fails_on_missing_role(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video2",
|
|
|
|
"roles": ["record"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
|
|
|
"rtmp": {"enabled": True},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
self.assertRaises(ValueError, lambda: frigate_config.runtime_config)
|
|
|
|
|
2021-10-24 20:33:13 +02:00
|
|
|
def test_works_on_missing_role_multiple_cams(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2022-11-02 12:36:09 +01:00
|
|
|
"restream": {"enabled": False},
|
2021-10-24 20:33:13 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video2",
|
|
|
|
"roles": ["record"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cam2": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video2",
|
|
|
|
"roles": ["record"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"detect": {
|
|
|
|
"height": 1080,
|
|
|
|
"width": 1920,
|
|
|
|
"fps": 5,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
|
2021-08-28 15:51:29 +02:00
|
|
|
def test_global_detect(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"detect": {"max_disappeared": 1},
|
|
|
|
"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"].detect.max_disappeared == 1
|
|
|
|
assert runtime_config.cameras["back"].detect.height == 1080
|
|
|
|
|
|
|
|
def test_default_detect(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].detect.max_disappeared == 25
|
|
|
|
assert runtime_config.cameras["back"].detect.height == 720
|
|
|
|
|
|
|
|
def test_global_detect_merge(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"detect": {"max_disappeared": 1, "height": 720},
|
|
|
|
"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"].detect.max_disappeared == 1
|
|
|
|
assert runtime_config.cameras["back"].detect.height == 1080
|
|
|
|
assert runtime_config.cameras["back"].detect.width == 1920
|
|
|
|
|
2021-08-28 16:14:00 +02:00
|
|
|
def test_global_snapshots(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"snapshots": {"enabled": True},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"snapshots": {
|
|
|
|
"height": 100,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].snapshots.enabled
|
|
|
|
assert runtime_config.cameras["back"].snapshots.height == 100
|
|
|
|
|
|
|
|
def test_default_snapshots(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].snapshots.bounding_box
|
|
|
|
assert runtime_config.cameras["back"].snapshots.quality == 70
|
|
|
|
|
|
|
|
def test_global_snapshots_merge(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"snapshots": {"bounding_box": False, "height": 300},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"snapshots": {
|
|
|
|
"height": 150,
|
|
|
|
"enabled": True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].snapshots.bounding_box == False
|
|
|
|
assert runtime_config.cameras["back"].snapshots.height == 150
|
|
|
|
assert runtime_config.cameras["back"].snapshots.enabled
|
|
|
|
|
2022-11-02 12:36:09 +01:00
|
|
|
def test_global_restream(self):
|
2021-09-03 14:03:36 +02:00
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2022-11-02 12:36:09 +01:00
|
|
|
"restream": {"enabled": True},
|
2021-09-03 14:03:36 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2022-11-02 12:36:09 +01:00
|
|
|
assert runtime_config.cameras["back"].restream.enabled
|
2021-09-03 14:03:36 +02:00
|
|
|
|
2022-11-02 12:36:09 +01:00
|
|
|
def test_global_rtmp_disabled(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert not runtime_config.cameras["back"].rtmp.enabled
|
|
|
|
|
|
|
|
def test_default_not_rtmp(self):
|
2021-09-03 14:03:36 +02:00
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2022-11-02 12:36:09 +01:00
|
|
|
assert not runtime_config.cameras["back"].rtmp.enabled
|
|
|
|
|
|
|
|
def test_default_restream(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].restream.enabled
|
|
|
|
|
|
|
|
def test_global_restream_merge(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"restream": {"enabled": False},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"restream": {
|
|
|
|
"enabled": True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].restream.enabled
|
2021-09-03 14:03:36 +02:00
|
|
|
|
|
|
|
def test_global_rtmp_merge(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"rtmp": {"enabled": False},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
2022-11-02 12:36:09 +01:00
|
|
|
"roles": ["detect", "rtmp"],
|
2021-09-03 14:03:36 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"rtmp": {
|
|
|
|
"enabled": True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].rtmp.enabled
|
|
|
|
|
2021-10-23 02:41:28 +02:00
|
|
|
def test_global_rtmp_default(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2022-11-02 12:36:09 +01:00
|
|
|
"restream": {"enabled": False},
|
2021-10-23 02:41:28 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video2",
|
|
|
|
"roles": ["record"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert not runtime_config.cameras["back"].rtmp.enabled
|
|
|
|
|
2022-11-02 12:36:09 +01:00
|
|
|
def test_global_jsmpeg(self):
|
2021-09-14 03:33:00 +02:00
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2022-11-02 12:36:09 +01:00
|
|
|
"restream": {"jsmpeg": {"quality": 4}},
|
2021-09-14 03:33:00 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2022-11-02 12:36:09 +01:00
|
|
|
assert runtime_config.cameras["back"].restream.jsmpeg.quality == 4
|
2021-09-14 03:33:00 +02:00
|
|
|
|
|
|
|
def test_default_live(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2022-11-02 12:36:09 +01:00
|
|
|
assert runtime_config.cameras["back"].restream.jsmpeg.quality == 8
|
2021-09-14 03:33:00 +02:00
|
|
|
|
|
|
|
def test_global_live_merge(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2022-11-02 12:36:09 +01:00
|
|
|
"restream": {"jsmpeg": {"quality": 4, "height": 480}},
|
2021-09-14 03:33:00 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2022-11-02 12:36:09 +01:00
|
|
|
"restream": {
|
|
|
|
"jsmpeg": {
|
|
|
|
"quality": 7,
|
|
|
|
}
|
2021-09-14 03:33:00 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
2022-11-02 12:36:09 +01:00
|
|
|
assert runtime_config.cameras["back"].restream.jsmpeg.quality == 7
|
|
|
|
assert runtime_config.cameras["back"].restream.jsmpeg.height == 480
|
2021-09-14 03:33:00 +02:00
|
|
|
|
2021-09-03 14:03:36 +02:00
|
|
|
def test_global_timestamp_style(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
2021-09-04 23:56:01 +02:00
|
|
|
"timestamp_style": {"position": "bl"},
|
2021-09-03 14:03:36 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].timestamp_style.position == "bl"
|
|
|
|
|
|
|
|
def test_default_timestamp_style(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].timestamp_style.position == "tl"
|
|
|
|
|
|
|
|
def test_global_timestamp_style_merge(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"rtmp": {"enabled": False},
|
2021-09-04 23:56:01 +02:00
|
|
|
"timestamp_style": {"position": "br", "thickness": 2},
|
2021-09-03 14:03:36 +02:00
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2021-09-04 23:56:01 +02:00
|
|
|
"timestamp_style": {"position": "bl", "thickness": 4},
|
2021-09-03 14:03:36 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].timestamp_style.position == "bl"
|
2021-09-04 23:56:01 +02:00
|
|
|
assert runtime_config.cameras["back"].timestamp_style.thickness == 4
|
2021-09-03 14:03:36 +02:00
|
|
|
|
2021-09-21 01:59:16 +02:00
|
|
|
def test_allow_retain_to_be_a_decimal(self):
|
|
|
|
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"snapshots": {"retain": {"default": 1.5}},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
assert config == frigate_config.dict(exclude_unset=True)
|
|
|
|
|
|
|
|
runtime_config = frigate_config.runtime_config
|
|
|
|
assert runtime_config.cameras["back"].snapshots.retain.default == 1.5
|
|
|
|
|
2022-02-02 14:21:03 +01:00
|
|
|
def test_fails_on_bad_camera_name(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"snapshots": {"retain": {"default": 1.5}},
|
|
|
|
"cameras": {
|
|
|
|
"back camer#": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
|
|
|
|
self.assertRaises(
|
|
|
|
ValidationError, lambda: frigate_config.runtime_config.cameras
|
|
|
|
)
|
|
|
|
|
2022-11-09 02:47:45 +01:00
|
|
|
def test_fails_zone_defines_untracked_object(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"objects": {"track": ["person"]},
|
|
|
|
"cameras": {
|
|
|
|
"back": {
|
|
|
|
"ffmpeg": {
|
|
|
|
"inputs": [
|
|
|
|
{
|
|
|
|
"path": "rtsp://10.0.0.1:554/video",
|
|
|
|
"roles": ["detect"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"zones": {
|
|
|
|
"steps": {
|
|
|
|
"coordinates": "0,0,0,0",
|
|
|
|
"objects": ["car", "person"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
frigate_config = FrigateConfig(**config)
|
|
|
|
|
|
|
|
self.assertRaises(ValueError, lambda: frigate_config.runtime_config.cameras)
|
|
|
|
|
|
|
|
def test_fails_duplicate_keys(self):
|
|
|
|
raw_config = """
|
|
|
|
cameras:
|
|
|
|
test:
|
|
|
|
ffmpeg:
|
|
|
|
inputs:
|
|
|
|
- one
|
|
|
|
- two
|
|
|
|
inputs:
|
|
|
|
- three
|
|
|
|
- four
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.assertRaises(
|
|
|
|
ValueError, lambda: load_config_with_no_duplicates(raw_config)
|
|
|
|
)
|
|
|
|
|
2022-04-10 15:25:18 +02:00
|
|
|
def test_object_filter_ratios_work(self):
|
|
|
|
config = {
|
|
|
|
"mqtt": {"host": "mqtt"},
|
|
|
|
"objects": {
|
|
|
|
"track": ["person", "dog"],
|
|
|
|
"filters": {"dog": {"min_ratio": 0.2, "max_ratio": 10.1}},
|
|
|
|
},
|
|
|
|
"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 "dog" in runtime_config.cameras["back"].objects.filters
|
|
|
|
assert runtime_config.cameras["back"].objects.filters["dog"].min_ratio == 0.2
|
|
|
|
assert runtime_config.cameras["back"].objects.filters["dog"].max_ratio == 10.1
|
|
|
|
|
2020-11-01 13:17:44 +01:00
|
|
|
|
2021-02-17 14:23:32 +01:00
|
|
|
if __name__ == "__main__":
|
2021-06-24 07:45:27 +02:00
|
|
|
unittest.main(verbosity=2)
|