gx
a576b4ec51
controller: border defaults → 1px (idle и motion)
...
User feedback: 4px motion border слишком жирная, к тому же много false motion
от Frigate (зоны/чувствительность будут tune'иться позже). Уменьшаем default
до 1px чтобы borders не мешали visually. Width конфигурируется (1..16).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-20 20:54:09 +01:00
gx
e877a254ce
controller: fix MQTT topic для motion — frigate/<cam>/motion/state (не /motion)
...
Frigate publishes на /motion/state ("ON"/"OFF") — а bare /motion это SET-topic
для control. Subscribe pattern был неправильный → bridge не получал motion events
→ red border не загорался при motion.
Live verified после fix: real motion от parking/gate_lpr/back_yard cameras
триггерит upsert cell_<N>_border с motion theme (red #FF0000, 4px, opacity 1.0).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-20 20:50:20 +01:00
gx
26e9f30990
controller: FrigateBridge cell borders с idle/motion state machine
...
Permanent 1-2px рамка вокруг каждой cell для visual разделения.
При motion ON → рамка светится красным (config'и BorderTheme).
Logic:
_ensure_borders() Lazy init 4 borders (id="cell_N_border") при первом event
с idle стилем (#808080 width=2 opacity=0.4)
_set_border_state(motion=bool) Upsert тот же overlay с motion (#FF0000 width=4 opacity=1.0)
или idle styling
_cell_states set'у активных cams per cell ("inst:cell" → set(cam_names))
— border ON если хоть один cam имеет motion, OFF только когда
все cams cleared
BorderTheme:
idle_color/width/opacity subtle разделитель
motion_color/width/opacity alarm подсветка
configurable через cfg.frigate.border_theme
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-20 20:43:34 +01:00
gx
96e6048b64
controller: Phase 4b end-to-end working — wire format fix + FrigateBridge auto-overlay
...
Fixed pipeline (live verified с ffmpeg-vf-cuda-grid:phase4b-icon):
zmq_client.send_command — wrap args в single-quotes
FFmpeg's zmq filter parses через av_get_token (libavfilter/f_zmq.c) — берёт
ОДИН token как arg. Без quotes filter получает только id, parse fail.
dispatch._serialize_overlay_to_zmq — translation pydantic → filter wire:
color "#RRGGBB" → r=N g=N b=N
opacity 0..1.0 → opacity 0..255
border_only + width → thickness (0=filled, иначе width)
dim_factor 0..1.0 → amount 0..255
text/icon_name → URL-encoded (%20 для space)
frigate_bridge — Phase 4b auto-rendering:
motion ON → add RectOverlay (orange border весь cell)
motion OFF → remove
event new/update → add RectOverlay (bbox) + TextOverlay (label + score%)
event end → remove оба
Bbox px → normalized через configurable camera_width/height (default 1920x1080).
Опциональные flags motion_indicator/bbox_overlay в mapping.
Constructor принимает dispatcher для dispatch.handle("overlay.add"/"overlay.remove").
mqtt_loop._handle_message — await frigate_bridge.handle_message (теперь async).
__main__.py — передаёт dispatcher в FrigateBridge constructor.
Verified end-to-end через test pipeline:
pydantic Overlay → _serialize_overlay_to_zmq → send_command quoted →
ZMQ → filter parse_overlay_args → CUDA kernel render
4× add_overlay (rect border, text, dim, rect filled) — все 4 visible в output frame.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-20 19:19:47 +01:00
gx
c396a47f4a
controller: switch wire format JSON → key=val URL-encoded (matches filter)
...
Filter использует sscanf("%s") который stops on whitespace — нужно
URL-encode string values (text="hello world" → text=hello%20world).
Filter inline decode'ит %xx.
Также:
tools/smoke_test_overlays.sh — integration test script (manual run
утром когда GPU свободна; сейчас прод-сервисы заняли всю VRAM)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-19 22:43:35 +01:00
gx
a1090a5f4c
controller: Phase 4a — overlay infrastructure (data models + API + Frigate bridge skeleton)
...
Phase 4a deliverable (no filter rendering yet — это Phase 4b).
End-to-end pipeline: HA/HTTP/MQTT → controller → ZMQ → FFmpeg (logged).
Modules:
- overlays.py — 7 discriminated union types через pydantic:
rect, text, icon, image, dim, graph, chat. Normalized coords (0.0-1.0),
optional cell binding, z_order, opacity, visible.
- state.py — overlay storage per instance (CRUD: add/remove/update/get/clear)
- dispatch.py — overlay.add/remove/clear actions:
- parses JSON payload в Overlay через TypeAdapter
- serializes to ZMQ string: "<id> <type> <full-json>"
- sends via FFmpeg process_command (filter will парсить в Phase 4b)
- updates state + publishes events (overlay_added, overlay_removed, overlays_cleared)
- http_api.py — REST endpoints:
- POST /overlay/{inst}/add (body = Overlay JSON, returns id)
- GET /overlay/{inst} — list all
- DELETE /overlay/{inst}/{id} — single
- DELETE /overlay/{inst} — clear all
- PATCH /overlay/{inst}/{id} — update
- mqtt_loop.py — already subscribes cuda_grid/cmd/<inst>/+/+; teper handles
overlay/add (JSON payload), overlay/remove (id), overlay/clear
- frigate_bridge.py — FrigateBridge skeleton:
- subscribe frigate/+/motion + frigate/events
- mapping camera_name → target_instance + cell index
- Phase 4a: log received events (rendering в Phase 4b)
- config.py — frigate: optional section
- examples/controller.yaml — frigate mappings для 4 наших камер
State management:
- ControllerState.add/remove/update/get/clear_overlay (asyncio.Lock guarded)
- InstanceState.overlays: dict[str, Overlay]
- IDs generated via uuid4()[:8]
Phase 4a limitations:
- Filter side ничего не рендерит (just logs ZMQ commands)
- Frigate bridge принимает events но не auto-generates overlays
- HA Discovery не имеет overlay-specific entities (overlays через REST API)
Phase 4b: filter-side AVFrame side data + CUDA kernels (rect first, NPP-based,
потом text via freetype atlas, потом icon sprite blit).
2026-05-19 22:03:20 +01:00
gx
37232ae1b9
controller: Phase 3 — Python sidecar skeleton (MQTT + ZMQ + HTTP + HA Discovery)
...
cuda-grid-controller (Python 3.11+) — control plane между HA/MQTT/HTTP
и FFmpeg's vf_cuda_grid filter через ZMQ.
Modules (~700 LOC Python):
- config.py — Pydantic schema (broker, instances[], ha_discovery, http, log) + YAML loader
- layouts.py — registry известных layouts (sync с vf_cuda_grid.c Phase 2)
- ha_discovery.py — HA MQTT Discovery payloads (select.layout, sensor.current_layout,
binary_sensor.online per instance + global device entry)
- zmq_client.py — async ZMQ REQ socket к FFmpeg zmq filter
(target command args → reply parsing)
- state.py — in-memory ControllerState (active_layout per instance, asyncio.Lock)
- mqtt_loop.py — aiomqtt async loop: subscribe cuda_grid/cmd/<inst>/+/+,
publish cuda_grid/state/* (retained) + cuda_grid/event/*, LWT, HA status reconnect
- dispatch.py — CommandDispatcher: layout.set action → ZMQ send_command + state update + events
- http_api.py — FastAPI: /health, /layouts, /state, POST /layout/{inst}/set
- __main__.py — typer CLI, asyncio.gather(mqtt_loop, uvicorn.server)
Examples + Dockerfile:
- examples/controller.yaml — 2 instances (livingroom_tv, public_stream)
- Dockerfile — python:3.11-slim, ENTRYPOINT cuda-grid-controller
- README — overview, usage, FFmpeg side filter graph
End-to-end flow ready:
HA dashboard → MQTT → controller → ZMQ → FFmpeg process_command → layout switch
↓
state публикуется обратно в MQTT → HA UI обновляется
Phase 3 deliverable per gx/vf-cuda-grid#1 . Phase 4 = overlays (rect/text/icon).
2026-05-19 21:52:11 +01:00
gx
06be41d245
readme: project overview + architecture diagram + phase table
2026-05-19 20:37:41 +01:00
gx
8a6afa53b3
initial: README + design document (architect-reviewed)
...
Design document (1124 строки) от ai-systems-architect — покрывает:
- High-level architecture (filter + sidecar + protocols)
- Component design + CUDA composition algorithm
- Layout DSL + dynamic creation
- Overlay system (7 types — rect/text/icon/image/dim/graph/chat)
- Control plane (ZMQ/MQTT/HTTP/HA Discovery, commands IN + events OUT)
- Audio orchestration (domofon ducking use case)
- Multi-instance behaviour (shared inputs, per-screen layout)
- Library choice — Python (FastAPI + asyncio)
- 6 phases implementation plan
- Migration path для cctv-processor (closes gx/cctv#22 Phase 4)
- Overlap analysis с gx/cctv#24 (superseded by cuda-grid-controller)
README — short описание + use cases + architecture diagram + phase table.
Implementation начнётся после ratification design'а и Phase 1 issue.
2026-05-19 20:36:47 +01:00
gx
bf51325ca0
Initial commit
2026-05-19 20:35:31 +01:00