Server Push 0.3
parent
7eb227d7b2
commit
a8276a1b25
|
|
@ -21,7 +21,7 @@ PASSWORD = os.getenv("password")
|
||||||
|
|
||||||
# Dynamically find all camera_ip_N variables in environment
|
# Dynamically find all camera_ip_N variables in environment
|
||||||
CAMERA_IPS = []
|
CAMERA_IPS = []
|
||||||
for i in range(1, 11): # Supports up to 10 cameras
|
for i in range(1, 101): # Supports up to 100 cameras
|
||||||
ip = os.getenv(f"camera_ip_{i}")
|
ip = os.getenv(f"camera_ip_{i}")
|
||||||
if ip and ip.strip():
|
if ip and ip.strip():
|
||||||
CAMERA_IPS.append(ip.strip())
|
CAMERA_IPS.append(ip.strip())
|
||||||
|
|
@ -223,13 +223,31 @@ def _update_grid_frame():
|
||||||
time.sleep(0.1); continue
|
time.sleep(0.1); continue
|
||||||
|
|
||||||
n = len(frames)
|
n = len(frames)
|
||||||
if n == 1: grid = frames[0]
|
if n == 0:
|
||||||
elif n == 2: grid = np.hstack(frames)
|
time.sleep(0.1); continue
|
||||||
else:
|
|
||||||
row1 = np.hstack(frames[:2])
|
# Calculate grid dimensions (rows/cols)
|
||||||
if n == 3: row2 = np.hstack([frames[2], np.zeros_like(frames[0])])
|
cols = int(np.ceil(np.sqrt(n)))
|
||||||
else: row2 = np.hstack(frames[2:4])
|
rows = int(np.ceil(n / cols))
|
||||||
grid = np.vstack([row1, row2])
|
|
||||||
|
# Determine cell size
|
||||||
|
# Use 320x240 for large grids to prevent the output frame from being too massive
|
||||||
|
cell_w, cell_h = 320, 240
|
||||||
|
if n <= 1: cell_w, cell_h = 640, 480
|
||||||
|
elif n <= 4: cell_w, cell_h = 480, 360
|
||||||
|
|
||||||
|
grid_rows = []
|
||||||
|
for r in range(rows):
|
||||||
|
row_items = []
|
||||||
|
for c in range(cols):
|
||||||
|
idx = r * cols + c
|
||||||
|
if idx < n:
|
||||||
|
row_items.append(cv2.resize(frames[idx], (cell_w, cell_h)))
|
||||||
|
else:
|
||||||
|
row_items.append(np.zeros((cell_h, cell_w, 3), dtype=np.uint8))
|
||||||
|
grid_rows.append(np.hstack(row_items))
|
||||||
|
|
||||||
|
grid = np.vstack(grid_rows)
|
||||||
|
|
||||||
with lock:
|
with lock:
|
||||||
state["grid_frame"] = grid
|
state["grid_frame"] = grid
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue