mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 10:45:21 +03:00
Add default detect dimensions if autoconfiguration failed and log a warning message
This commit is contained in:
parent
838f246b06
commit
2fff932979
@ -44,6 +44,7 @@ FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE
|
||||
|
||||
DEFAULT_TRACKED_OBJECTS = ["person"]
|
||||
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
|
||||
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
|
||||
|
||||
|
||||
class FrigateBaseModel(BaseModel):
|
||||
@ -267,9 +268,8 @@ class StationaryConfig(FrigateBaseModel):
|
||||
|
||||
|
||||
class DetectConfig(FrigateBaseModel):
|
||||
autoconf: bool = Field(default=True, title="Auto detect height, width and fps.")
|
||||
height: int = Field(default=720, title="Height of the stream for the detect role.")
|
||||
width: int = Field(default=1280, title="Width of the stream for the detect role.")
|
||||
height: Optional[int] = Field(title="Height of the stream for the detect role.")
|
||||
width: Optional[int] = Field(title="Width of the stream for the detect role.")
|
||||
fps: int = Field(
|
||||
default=5, title="Number of frames per second to process through detection."
|
||||
)
|
||||
@ -671,17 +671,25 @@ class CameraConfig(FrigateBaseModel):
|
||||
if has_rtmp:
|
||||
config["ffmpeg"]["inputs"][0]["roles"].append("rtmp")
|
||||
|
||||
for input in config["ffmpeg"]["inputs"]:
|
||||
if config["detect"].get("autoconf") and (
|
||||
"detect" in input.get("roles", [])
|
||||
if (
|
||||
config["detect"].get("height") is None
|
||||
or config["detect"].get("width") is None
|
||||
):
|
||||
for input in config["ffmpeg"]["inputs"]:
|
||||
if "detect" in input.get("roles", []):
|
||||
try:
|
||||
streamInfo = get_video_properties(input.get("path"))
|
||||
config["detect"]["width"] = streamInfo["width"]
|
||||
config["detect"]["height"] = streamInfo["height"]
|
||||
break
|
||||
except Exception:
|
||||
logger.debug("Error autoconf url " + input.get("path"))
|
||||
config["detect"]["width"] = DEFAULT_DETECT_DIMENSIONS["width"]
|
||||
config["detect"]["height"] = DEFAULT_DETECT_DIMENSIONS["height"]
|
||||
logger.warn(
|
||||
"Error autoconfiguration url "
|
||||
+ input.get("path")
|
||||
+ ". Appliing default values."
|
||||
)
|
||||
continue
|
||||
|
||||
super().__init__(**config)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user