-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnose_popup.py
More file actions
71 lines (56 loc) · 1.78 KB
/
Copy pathdiagnose_popup.py
File metadata and controls
71 lines (56 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""
Lightweight diagnostics for Slouchless popups (no vLLM, no tray UI).
Usage:
uv run --active python diagnose_popup.py
uv run --active python diagnose_popup.py --auto-close 5
Camera selection via env vars (or .env file):
SLOUCHLESS_CAMERA_DEVICE_ID=3 uv run --active python diagnose_popup.py
SLOUCHLESS_CAMERA_NAME="Logi Webcam" uv run --active python diagnose_popup.py
"""
from __future__ import annotations
import time
from typing import Annotated
import typer
from rich.console import Console
console = Console()
def main(
auto_close: Annotated[
int,
typer.Option("--auto-close", help="Auto-close after N seconds (0=never)"),
] = 8,
) -> None:
"""Slouchless popup diagnostics."""
from src.camera import Camera
from src.settings import settings
from src.popup.ffplay_feedback import (
close_feedback_window,
open_feedback_window,
send_feedback_frame,
)
cam = None
try:
cam = Camera()
console.print(f"Camera: {cam.describe()}")
open_feedback_window()
deadline = time.time() + auto_close if auto_close > 0 else None
frame_dt = 1.0 / settings.popup_preview_fps
while deadline is None or time.time() < deadline:
img = cam.capture_frame()
ok = send_feedback_frame(
img,
kind="bad",
message="diagnostic overlay",
raw_output="Yes",
thumbnail_size=settings.popup_thumbnail_size,
)
if not ok:
break
time.sleep(frame_dt)
console.print("[green]OK[/green]")
finally:
close_feedback_window()
if cam:
cam.release()
if __name__ == "__main__":
typer.run(main)