-
Notifications
You must be signed in to change notification settings - Fork 30
/
config.py
92 lines (81 loc) · 2.87 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from typing import List, Optional, Union
from pydantic import BaseSettings, Extra
from odrpc import MqttDetectRequest
class DoodsDetectorConfig(BaseSettings):
name: str
type: str
modelFile: str
labelFile: Optional[str]
labelsStartFromZero: Optional[bool] = False
hwAccel: Optional[bool] = False
numThreads: Optional[int] = 2
class Config:
extra = Extra.ignore
class DoodsBoxesConfig(BaseSettings):
enabled: Optional[bool] = True
boxColor: Optional[Union[List[int], str]] = [0, 255, 0]
boxThickness: Optional[int] = 1
fontScale: Optional[float] = 1.2
fontColor: Optional[Union[List[int], str]] = [0, 255, 0]
fontThickness: Optional[int] = 2
class DoodsRegionsConfig(BaseSettings):
enabled: Optional[bool] = True
boxColor: Optional[Union[List[int], str]] = [0, 255, 0]
boxThickness: Optional[int] = 1
fontScale: Optional[float] = 1.2
fontColor: Optional[Union[List[int], str]] = [0, 255, 0]
fontThickness: Optional[int] = 2
class DoodsGlobalsConfig(BaseSettings):
enabled: Optional[bool] = True
fontScale: Optional[float] = 1.2
fontColor: Optional[Union[List[int], str]] = [0, 255, 0]
fontThickness: Optional[int] = 2
class DoodsConfig(BaseSettings):
boxes: Optional[DoodsBoxesConfig] = DoodsBoxesConfig()
regions: Optional[DoodsRegionsConfig] = DoodsRegionsConfig()
globals: Optional[DoodsGlobalsConfig] = DoodsGlobalsConfig()
detectors: List[DoodsDetectorConfig]
log: Optional[str] = 'detections'
class Config:
env_prefix = 'doods_'
extra = Extra.ignore
class LoggerConfig(BaseSettings):
level: Optional[str] = "info"
class Config:
env_prefix = 'logger_'
extra = Extra.ignore
class ServerConfig(BaseSettings):
host: Optional[str] = "0.0.0.0"
port: Optional[int] = 8080
auth_key: Optional[str] = ''
metrics: Optional[bool] = True
trace: Optional[bool] = False
class Config:
env_prefix = 'server_'
extra = Extra.ignore
class MqttBrokerConfig(BaseSettings):
host: Optional[str] = 'localhost'
port: Optional[int] = 1883
user: Optional[str] = None
password: Optional[str] = None
class Config:
env_prefix = 'mqttbroker_'
extra = Extra.ignore
class MqttApiConfig(BaseSettings):
request_topic: Optional[str] = 'doods2/request_topic'
response_topic: Optional[str] = 'doods2/response_topic'
class MqttConfig(BaseSettings):
broker: MqttBrokerConfig
api: Optional[MqttApiConfig]
requests: Optional[List[MqttDetectRequest]] = []
metrics: Optional[bool] = True
class Config:
env_prefix = 'mqtt_'
extra = Extra.ignore
class Config(BaseSettings):
logger: Optional[LoggerConfig] = LoggerConfig()
server: Optional[ServerConfig] = ServerConfig()
doods: DoodsConfig
mqtt: Optional[MqttConfig]
class Config:
extra = Extra.ignore