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_TRACKED_OBJECTS = ["person"]
|
||||||
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
|
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
|
||||||
|
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
|
||||||
|
|
||||||
|
|
||||||
class FrigateBaseModel(BaseModel):
|
class FrigateBaseModel(BaseModel):
|
||||||
@ -267,9 +268,8 @@ class StationaryConfig(FrigateBaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class DetectConfig(FrigateBaseModel):
|
class DetectConfig(FrigateBaseModel):
|
||||||
autoconf: bool = Field(default=True, title="Auto detect height, width and fps.")
|
height: Optional[int] = Field(title="Height of the stream for the detect role.")
|
||||||
height: int = Field(default=720, title="Height of the stream for the detect role.")
|
width: Optional[int] = Field(title="Width of the stream for the detect role.")
|
||||||
width: int = Field(default=1280, title="Width of the stream for the detect role.")
|
|
||||||
fps: int = Field(
|
fps: int = Field(
|
||||||
default=5, title="Number of frames per second to process through detection."
|
default=5, title="Number of frames per second to process through detection."
|
||||||
)
|
)
|
||||||
@ -671,18 +671,26 @@ class CameraConfig(FrigateBaseModel):
|
|||||||
if has_rtmp:
|
if has_rtmp:
|
||||||
config["ffmpeg"]["inputs"][0]["roles"].append("rtmp")
|
config["ffmpeg"]["inputs"][0]["roles"].append("rtmp")
|
||||||
|
|
||||||
for input in config["ffmpeg"]["inputs"]:
|
if (
|
||||||
if config["detect"].get("autoconf") and (
|
config["detect"].get("height") is None
|
||||||
"detect" in input.get("roles", [])
|
or config["detect"].get("width") is None
|
||||||
):
|
):
|
||||||
try:
|
for input in config["ffmpeg"]["inputs"]:
|
||||||
streamInfo = get_video_properties(input.get("path"))
|
if "detect" in input.get("roles", []):
|
||||||
config["detect"]["width"] = streamInfo["width"]
|
try:
|
||||||
config["detect"]["height"] = streamInfo["height"]
|
streamInfo = get_video_properties(input.get("path"))
|
||||||
break
|
config["detect"]["width"] = streamInfo["width"]
|
||||||
except Exception:
|
config["detect"]["height"] = streamInfo["height"]
|
||||||
logger.debug("Error autoconf url " + input.get("path"))
|
break
|
||||||
continue
|
except Exception:
|
||||||
|
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)
|
super().__init__(**config)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user