mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Cache coefficients that are used for different size layouts
This commit is contained in:
parent
08412a444d
commit
81f47222ae
@ -56,10 +56,17 @@ class Canvas:
|
||||
)
|
||||
self.width = canvas_width
|
||||
self.height = (self.width * self.aspect[1]) / self.aspect[0]
|
||||
self.coefficient_cache: dict[int, int] = {}
|
||||
|
||||
def get_aspect(self, coefficient: int) -> tuple[int, int]:
|
||||
return (self.aspect[0] * coefficient, self.aspect[1] * coefficient)
|
||||
|
||||
def get_coefficient(self, camera_count: int) -> int:
|
||||
return self.coefficient_cache.get(camera_count, 2)
|
||||
|
||||
def set_coefficient(self, camera_count: int, coefficient: int) -> None:
|
||||
self.coefficient_cache[camera_count] = coefficient
|
||||
|
||||
|
||||
class FFMpegConverter:
|
||||
def __init__(
|
||||
@ -376,7 +383,7 @@ class BirdsEyeFrameManager:
|
||||
]
|
||||
else:
|
||||
# calculate optimal layout
|
||||
coefficient = 2
|
||||
coefficient = self.canvas.get_coefficient(len(active_cameras))
|
||||
calculating = True
|
||||
|
||||
# decrease scaling coefficient until height of all cameras can fit into the birdseye canvas
|
||||
@ -398,6 +405,7 @@ class BirdsEyeFrameManager:
|
||||
return
|
||||
|
||||
calculating = False
|
||||
self.canvas.set_coefficient(len(active_cameras), coefficient)
|
||||
|
||||
self.camera_layout = layout_candidate
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user