mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 10:45:21 +03:00
Remove logs
This commit is contained in:
parent
1755fdc10e
commit
ff18c5e5a3
@ -7,7 +7,6 @@ import os
|
|||||||
import queue
|
import queue
|
||||||
import signal
|
import signal
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import sys
|
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
from wsgiref.simple_server import make_server
|
from wsgiref.simple_server import make_server
|
||||||
@ -212,6 +211,7 @@ class BirdsEyeFrameManager:
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.cameras[camera] = {
|
self.cameras[camera] = {
|
||||||
|
"dimensions": (settings.detect.width, settings.detect.height),
|
||||||
"last_active_frame": 0.0,
|
"last_active_frame": 0.0,
|
||||||
"current_frame": 0.0,
|
"current_frame": 0.0,
|
||||||
"layout_frame": 0.0,
|
"layout_frame": 0.0,
|
||||||
@ -226,7 +226,6 @@ class BirdsEyeFrameManager:
|
|||||||
|
|
||||||
self.camera_layout = []
|
self.camera_layout = []
|
||||||
self.active_cameras = set()
|
self.active_cameras = set()
|
||||||
self.layout_dim = 0
|
|
||||||
self.last_output_time = 0.0
|
self.last_output_time = 0.0
|
||||||
|
|
||||||
def clear_frame(self):
|
def clear_frame(self):
|
||||||
@ -250,8 +249,6 @@ class BirdsEyeFrameManager:
|
|||||||
return
|
return
|
||||||
channel_dims = self.cameras[camera]["channel_dims"]
|
channel_dims = self.cameras[camera]["channel_dims"]
|
||||||
|
|
||||||
logger.error(f"Copy to yuv {position}")
|
|
||||||
|
|
||||||
copy_yuv_to_position(
|
copy_yuv_to_position(
|
||||||
self.frame,
|
self.frame,
|
||||||
[position[1], position[0]],
|
[position[1], position[0]],
|
||||||
@ -271,9 +268,12 @@ class BirdsEyeFrameManager:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def update_frame(self):
|
def update_frame(self):
|
||||||
|
"""Update to a new frame for birdseye."""
|
||||||
|
|
||||||
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 cameras."""
|
||||||
camera_layout: list[list[any]] = []
|
camera_layout: list[list[any]] = []
|
||||||
camera_layout.append([])
|
camera_layout.append([])
|
||||||
x = 0
|
x = 0
|
||||||
@ -281,18 +281,24 @@ class BirdsEyeFrameManager:
|
|||||||
y_i = 0
|
y_i = 0
|
||||||
max_height = 0
|
max_height = 0
|
||||||
for camera in cameras_to_add:
|
for camera in cameras_to_add:
|
||||||
detect_config = self.config.cameras[camera].detect
|
if (x + self.cameras[camera]["settings"][0] * coefficient) <= canvas[0]:
|
||||||
|
|
||||||
if (x + self.config.cameras[camera].detect.width * coefficient) <= canvas[0]:
|
|
||||||
# insert if camera can fit on current row
|
# insert if camera can fit on current row
|
||||||
camera_layout[y_i].append(
|
camera_layout[y_i].append(
|
||||||
(
|
(
|
||||||
camera,
|
camera,
|
||||||
(x, y, int(detect_config.width * coefficient), int(detect_config.height * coefficient)),
|
(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
int(self.cameras[camera]["settings"][0] * coefficient),
|
||||||
|
int(self.cameras[camera]["settings"][1] * coefficient),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
x += int(detect_config.width * coefficient)
|
x += int(self.cameras[camera]["settings"][0] * coefficient)
|
||||||
max_height = max(max_height, int(detect_config.height * coefficient))
|
max_height = max(
|
||||||
|
max_height,
|
||||||
|
int(self.cameras[camera]["settings"][1] * coefficient),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# move on to the next row and insert
|
# move on to the next row and insert
|
||||||
y += max_height
|
y += max_height
|
||||||
@ -302,12 +308,16 @@ class BirdsEyeFrameManager:
|
|||||||
camera_layout[y_i].append(
|
camera_layout[y_i].append(
|
||||||
(
|
(
|
||||||
camera,
|
camera,
|
||||||
(x, y, int(detect_config.width * coefficient), int(detect_config.height * coefficient)),
|
(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
int(self.cameras[camera]["settings"][0] * coefficient),
|
||||||
|
int(self.cameras[camera]["settings"][1] * coefficient),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
x += int(detect_config.width * coefficient)
|
x += int(self.cameras[camera]["settings"][0] * coefficient)
|
||||||
|
|
||||||
logger.error(f"Calc total height {y + max_height}")
|
|
||||||
return (camera_layout, y + max_height)
|
return (camera_layout, y + max_height)
|
||||||
|
|
||||||
# determine how many cameras are tracking objects within the last 30 seconds
|
# determine how many cameras are tracking objects within the last 30 seconds
|
||||||
@ -328,54 +338,19 @@ class BirdsEyeFrameManager:
|
|||||||
# if the layout needs to be cleared
|
# if the layout needs to be cleared
|
||||||
else:
|
else:
|
||||||
self.camera_layout = []
|
self.camera_layout = []
|
||||||
self.layout_dim = 0
|
self.active_cameras = set()
|
||||||
self.clear_frame()
|
self.clear_frame()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# calculate layout dimensions
|
|
||||||
layout_dim = math.ceil(math.sqrt(len(active_cameras)))
|
|
||||||
|
|
||||||
# check if we need to reset the layout because there are new cameras to add
|
# check if we need to reset the layout because there are new cameras to add
|
||||||
reset_layout = (
|
reset_layout = (
|
||||||
True if len(active_cameras.difference(self.active_cameras)) > 0 else False
|
True if len(active_cameras.difference(self.active_cameras)) > 0 else False
|
||||||
)
|
)
|
||||||
|
|
||||||
# reset the layout if it needs to be different
|
# reset the layout if it needs to be different
|
||||||
if layout_dim != self.layout_dim or reset_layout:
|
|
||||||
if reset_layout:
|
if reset_layout:
|
||||||
logger.debug("Added new cameras, resetting layout...")
|
logger.debug("Added new cameras, resetting layout...")
|
||||||
|
|
||||||
logger.debug(f"Changing layout size from {self.layout_dim} to {layout_dim}")
|
|
||||||
self.layout_dim = layout_dim
|
|
||||||
|
|
||||||
self.camera_layout = [None] * layout_dim * layout_dim
|
|
||||||
|
|
||||||
# calculate resolution of each position in the layout
|
|
||||||
self.layout_frame_shape = (
|
|
||||||
self.frame_shape[0] // layout_dim, # height
|
|
||||||
self.frame_shape[1] // layout_dim, # width
|
|
||||||
)
|
|
||||||
|
|
||||||
self.clear_frame()
|
self.clear_frame()
|
||||||
|
|
||||||
for cam_data in self.cameras.values():
|
|
||||||
cam_data["layout_frame"] = 0.0
|
|
||||||
|
|
||||||
self.active_cameras = set()
|
|
||||||
|
|
||||||
self.layout_offsets = []
|
|
||||||
|
|
||||||
# calculate the x and y offset for each position in the layout
|
|
||||||
for position in range(0, len(self.camera_layout)):
|
|
||||||
y_offset = self.layout_frame_shape[0] * math.floor(
|
|
||||||
position / self.layout_dim
|
|
||||||
)
|
|
||||||
x_offset = self.layout_frame_shape[1] * (position % self.layout_dim)
|
|
||||||
self.layout_offsets.append((y_offset, x_offset))
|
|
||||||
|
|
||||||
removed_cameras = self.active_cameras.difference(active_cameras)
|
|
||||||
added_cameras = active_cameras.difference(self.active_cameras)
|
|
||||||
|
|
||||||
self.active_cameras = active_cameras
|
self.active_cameras = active_cameras
|
||||||
|
|
||||||
# this also converts added_cameras from a set to a list since we need
|
# this also converts added_cameras from a set to a list since we need
|
||||||
@ -393,13 +368,12 @@ class BirdsEyeFrameManager:
|
|||||||
canvas_height = self.config.birdseye.height
|
canvas_height = self.config.birdseye.height
|
||||||
coefficient = 1.0
|
coefficient = 1.0
|
||||||
|
|
||||||
|
# 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
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.error(f"With a coefficient of {coefficient} the total height is {total_height}")
|
|
||||||
|
|
||||||
if total_height <= canvas_height:
|
if total_height <= canvas_height:
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -407,8 +381,6 @@ class BirdsEyeFrameManager:
|
|||||||
|
|
||||||
self.camera_layout = layout_candidate
|
self.camera_layout = layout_candidate
|
||||||
|
|
||||||
logger.error(f"The final layout is {self.camera_layout}")
|
|
||||||
|
|
||||||
for row in self.camera_layout:
|
for row in self.camera_layout:
|
||||||
for position in row:
|
for position in row:
|
||||||
self.copy_to_position(
|
self.copy_to_position(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user