mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Optimize layout for low amount of cameras
This commit is contained in:
parent
3ab7b21490
commit
c0c3ff212c
@ -373,12 +373,64 @@ class BirdsEyeFrameManager:
|
|||||||
|
|
||||||
canvas_width = self.config.birdseye.width
|
canvas_width = self.config.birdseye.width
|
||||||
canvas_height = self.config.birdseye.height
|
canvas_height = self.config.birdseye.height
|
||||||
|
|
||||||
|
if len(active_cameras) == 1:
|
||||||
|
# show single camera as fullscreen
|
||||||
|
camera = active_cameras_to_add[0]
|
||||||
|
camera_dims = self.cameras[camera]["dimensions"].copy()
|
||||||
|
scaled_width = int(canvas_height * camera_dims[0] / camera_dims[1])
|
||||||
|
coefficient = (
|
||||||
|
1 if scaled_width <= canvas_width else canvas_width / scaled_width
|
||||||
|
)
|
||||||
|
self.camera_layout = [
|
||||||
|
[
|
||||||
|
(
|
||||||
|
camera,
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
int(scaled_width * coefficient),
|
||||||
|
int(canvas_height * coefficient),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
elif len(active_cameras) == 2:
|
||||||
|
# split canvas in half for 2 cameras
|
||||||
|
top_camera = active_cameras_to_add[0]
|
||||||
|
top_camera_dims = self.cameras[top_camera]["dimensions"].copy()
|
||||||
|
bottom_camera = active_cameras_to_add[1]
|
||||||
|
bottom_camera_dims = self.cameras[bottom_camera]["dimensions"].copy()
|
||||||
|
top_scaled_width = int(
|
||||||
|
(canvas_height / 2) * top_camera_dims[0] / top_camera_dims[1]
|
||||||
|
)
|
||||||
|
bottom_scaled_width = int(
|
||||||
|
(canvas_height / 2) * bottom_camera_dims[0] / bottom_camera_dims[1]
|
||||||
|
)
|
||||||
|
self.camera_layout = [
|
||||||
|
[(top_camera, (0, 0, top_scaled_width, int(canvas_height / 2)))],
|
||||||
|
[
|
||||||
|
(
|
||||||
|
bottom_camera,
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
int(canvas_height / 2),
|
||||||
|
bottom_scaled_width,
|
||||||
|
int(canvas_height / 2),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
# calculate optimal layout
|
||||||
coefficient = 1.0
|
coefficient = 1.0
|
||||||
|
|
||||||
# decrease scaling coefficient until height of all cameras can fit into the birdseye canvas
|
# decrease scaling coefficient until height of all cameras can fit into the birdseye canvas
|
||||||
while True:
|
while True:
|
||||||
layout_candidate, total_height = calculate_layout(
|
layout_candidate, total_height = calculate_layout(
|
||||||
(canvas_width, canvas_height), active_cameras_to_add, coefficient
|
(canvas_width, canvas_height),
|
||||||
|
active_cameras_to_add,
|
||||||
|
coefficient,
|
||||||
)
|
)
|
||||||
|
|
||||||
if total_height <= canvas_height:
|
if total_height <= canvas_height:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user