Remove manual 2 camera layout

This commit is contained in:
Nick Mowen 2023-06-15 11:27:23 -06:00
parent f908237385
commit 63221d43d4

View File

@ -270,90 +270,10 @@ class BirdsEyeFrameManager:
def update_frame(self): def update_frame(self):
"""Update to a new frame for birdseye.""" """Update to a new frame for birdseye."""
def calculate_two_cam_layout(canvas, cameras_to_add: list[str]) -> tuple[any]:
"""Calculate the optimal layout for 2 cameras."""
first_camera = cameras_to_add[0]
first_camera_dims = self.cameras[first_camera]["dimensions"].copy()
second_camera = cameras_to_add[1]
second_camera_dims = self.cameras[second_camera]["dimensions"].copy()
# check for optimal layout
if first_camera_dims[0] + second_camera_dims[0] > canvas_width:
# place cameras vertically
top_scaled_width = int(
(canvas_height / 2) * first_camera_dims[0] / first_camera_dims[1]
)
bottom_scaled_width = int(
(canvas_height / 2) * second_camera_dims[0] / second_camera_dims[1]
)
return [
[
(
first_camera,
(0, 0, top_scaled_width, int(canvas_height / 2)),
)
],
[
(
second_camera,
(
0,
int(canvas_height / 2),
bottom_scaled_width,
int(canvas_height / 2),
),
)
],
]
else:
# place cameras horizontally
first_scaled_width = int(
canvas_height * first_camera_dims[0] / first_camera_dims[1]
)
second_scaled_width = int(
canvas_height * second_camera_dims[0] / second_camera_dims[1]
)
first_height = canvas_height
second_height = canvas_height
if first_scaled_width + second_scaled_width > canvas_width:
if first_scaled_width > second_scaled_width:
first_scaled_width = canvas_width - second_scaled_width
first_height = int(
first_scaled_width
* first_camera_dims[1]
/ first_camera_dims[0]
)
else:
second_scaled_width = canvas_width - first_scaled_width
second_height = int(
second_scaled_width
* second_camera_dims[1]
/ second_camera_dims[0]
)
return [
[
(
first_camera,
(0, 0, first_scaled_width, first_height),
),
(
second_camera,
(
first_scaled_width + 1,
0,
second_scaled_width,
second_height,
),
),
],
]
def calculate_layout( def calculate_layout(
canvas, cameras_to_add: list[str], coefficient canvas, cameras_to_add: list[str], coefficient
) -> tuple[any]: ) -> tuple[any]:
"""Calculate the optimal layout for 3+ cameras.""" """Calculate the optimal layout for 2+ cameras."""
camera_layout: list[list[any]] = [] camera_layout: list[list[any]] = []
camera_layout.append([]) camera_layout.append([])
canvas_gcd = math.gcd(canvas[0], canvas[1]) canvas_gcd = math.gcd(canvas[0], canvas[1])
@ -533,10 +453,6 @@ class BirdsEyeFrameManager:
) )
] ]
] ]
elif len(active_cameras) == 2:
self.camera_layout = calculate_two_cam_layout(
(canvas_width, canvas_height), active_cameras_to_add
)
else: else:
# calculate optimal layout # calculate optimal layout
coefficient = 2 coefficient = 2