mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Isort
This commit is contained in:
parent
40f21e7346
commit
eb6d440eb8
@ -387,24 +387,6 @@ class BirdsEyeFrameManager:
|
||||
) -> tuple[any]:
|
||||
"""Calculate the optimal layout for 2+ cameras."""
|
||||
|
||||
def get_standard_aspect_ratio(camera_width, camera_height) -> tuple[int, int]:
|
||||
"""Ensure that only standard aspect ratios are used."""
|
||||
known_aspects = [
|
||||
(16, 9),
|
||||
(9, 16),
|
||||
(32, 9),
|
||||
(12, 9),
|
||||
(9, 12),
|
||||
] # aspects are scaled to be same ratio
|
||||
known_aspects_ratios = list(
|
||||
map(lambda aspect: aspect[0] / aspect[1], known_aspects)
|
||||
)
|
||||
closest = min(
|
||||
known_aspects_ratios,
|
||||
key=lambda x: abs(x - (camera_width / camera_height)),
|
||||
)
|
||||
return known_aspects[known_aspects_ratios.index(closest)]
|
||||
|
||||
def map_layout(row_height: int):
|
||||
"""Map the calculated layout."""
|
||||
candidate_layout = []
|
||||
@ -462,9 +444,17 @@ class BirdsEyeFrameManager:
|
||||
for camera in cameras_to_add:
|
||||
camera_dims = self.cameras[camera]["dimensions"].copy()
|
||||
camera_gcd = math.gcd(camera_dims[0], camera_dims[1])
|
||||
camera_aspect_x, camera_aspect_y = get_standard_aspect_ratio(
|
||||
camera_dims[0] / camera_gcd, camera_dims[1] / camera_gcd
|
||||
)
|
||||
camera_aspect_x = camera_dims[0] / camera_gcd
|
||||
camera_aspect_y = camera_dims[1] / camera_gcd
|
||||
|
||||
if round(camera_aspect_x / camera_aspect_y, 1) == 1.8:
|
||||
# account for slightly off 16:9 cameras
|
||||
camera_aspect_x = 16
|
||||
camera_aspect_y = 9
|
||||
elif round(camera_aspect_x / camera_aspect_y, 1) == 1.3:
|
||||
# make 4:3 cameras the same relative size as 16:9
|
||||
camera_aspect_x = 12
|
||||
camera_aspect_y = 9
|
||||
|
||||
if camera_dims[1] > camera_dims[0]:
|
||||
portrait = True
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
import copy
|
||||
import datetime
|
||||
import logging
|
||||
import pytz
|
||||
import re
|
||||
import shlex
|
||||
import urllib.parse
|
||||
@ -11,11 +10,11 @@ from collections import Counter
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, Tuple
|
||||
|
||||
import pytz
|
||||
import yaml
|
||||
|
||||
from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ from typing import AnyStr, Optional
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@ import py3nvml.py3nvml as nvml
|
||||
|
||||
from frigate.util.builtin import escape_special_characters
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user