Skip to content

Commit

Permalink
Merge branch 'ratio-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanh7 committed Jan 25, 2024
2 parents cb432a6 + b9e5371 commit 3e67639
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frigate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import logging
import os
import math
from enum import Enum
from pathlib import Path
from typing import Dict, List, Optional, Tuple, Union
Expand All @@ -21,6 +22,7 @@
DEFAULT_DB_PATH,
MAX_PRE_CAPTURE,
REGEX_CAMERA_NAME,
REGEX_CAMERA_RATIO,
YAML_EXT,
)
from frigate.detectors import DetectorConfig, ModelConfig
Expand Down Expand Up @@ -789,6 +791,7 @@ class CameraConfig(FrigateBaseModel):
timestamp_style: TimestampStyleConfig = Field(
default_factory=TimestampStyleConfig, title="Timestamp style configuration."
)
ratio: Optional[str] = Field(title="Aspect ratio", regex=REGEX_CAMERA_RATIO)
_ffmpeg_cmds: List[Dict[str, List[str]]] = PrivateAttr()

def __init__(self, **config):
Expand Down Expand Up @@ -1138,6 +1141,12 @@ def runtime_config(self, plus_api: PlusApi = None) -> FrigateConfig:
{"name": name, **merged_config}
)

if (
camera_config.detect.height is not None
and camera_config.ratio is not None
):
camera_config.detect.width = math.ceil(eval(camera_config.ratio) * camera_config.detect.height)

if (
camera_config.detect.height is None
or camera_config.detect.width is None
Expand Down
1 change: 1 addition & 0 deletions frigate/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# Regex Consts

REGEX_CAMERA_NAME = r"^[a-zA-Z0-9_-]+$"
REGEX_CAMERA_RATIO = r"^\d+/\d+$"
REGEX_RTSP_CAMERA_USER_PASS = r":\/\/[a-zA-Z0-9_-]+:[\S]+@"
REGEX_HTTP_CAMERA_USER_PASS = r"user=[a-zA-Z0-9_-]+&password=[\S]+"

Expand Down

0 comments on commit 3e67639

Please sign in to comment.