feat(v2): compose realtime monitor pipeline

This commit is contained in:
ila
2026-07-22 21:20:13 +08:00
parent d183170554
commit 8e093acb9b
4 changed files with 300 additions and 5 deletions
+1
View File
@@ -58,6 +58,7 @@ V2 对应模块的当前落实与 T-304 目标如下:
| ONNX Pose | `v2/internal/pose` | 114 letterbox、RGB/CHW、NMS、关键点及坐标还原 | 人员 ID、摔倒结论 |
| 事件引擎 | `v2/internal/fall` | 复现 V1 的跟踪、证据、四态状态机和 `FallEvent` | 视频解码、声音、文件 |
| 画面与证据 | `v2/internal/render`、`v2/internal/alert` | 叠加人员骨架/状态,红色仅表示 CONFIRMED;按事件 ID 保存一次 PNG 和 JSONL | 读取 RTSP、重跑事件规则、直接操作 Walk 控件 |
| 实时装配 | `v2/internal/monitor` | 在后台串联帧→Pose→事件→渲染→证据;画面只保留最新完成帧,确认事件经独立队列送 UI | 直接操作 Walk 控件、保存凭证 |
| Windows UI | `v2/internal/ui` | Walk 顶部“监控/设置”Tab、渲染最新帧和已计算状态 | 直接读 RTSP、执行 ONNX 或事件规则 |
| 应用装配 | `v2/cmd/silver-pose`(T-304) | 管理 worker 生命周期、取消、最新帧投递和依赖注入 | 重写领域规则 |
@@ -208,7 +208,7 @@ git commit -m "feat(v2): add annotated evidence and alert dispatch"
- Create: `v2/internal/monitor/monitor_test.go`
- Modify: `v2/internal/spike/ort.go` only if an interface adapter is needed
- [ ] **Step 1: Write failing orchestration tests using fakes**
- [x] **Step 1: Write failing orchestration tests using fakes**
```go
func TestMonitorPublishesLatestCompletedFrameAndOneAlert(t *testing.T) {
@@ -227,12 +227,12 @@ func TestMonitorDoesNotCreateFallEvidenceOnSourceFailure(t *testing.T) {
}
```
- [ ] **Step 2: Verify the monitor tests fail**
- [x] **Step 2: Verify the monitor tests fail**
Run: `Set-Location v2; go test ./internal/monitor -v`
Expected: FAIL because `internal/monitor` does not exist.
- [ ] **Step 3: Implement the composition boundary**
- [x] **Step 3: Implement the composition boundary**
```go
type PoseRuntime interface { Run([]float32) ([]float32, error); Close() }
@@ -244,12 +244,12 @@ func (m *Monitor) Run(ctx context.Context) { /* source frame -> pose -> fall ->
Create/open one ONNX Runtime instance before consuming frames and close it only when monitoring stops. Treat Pose/preprocess errors as non-fall status updates and continue/reconnect according to source state; do not terminate the Walk message loop. Only completed rendered frames enter the one-slot `Updates` channel, so a slow UI never queues stale video frames.
- [ ] **Step 4: Run monitor, fall and full Go tests**
- [x] **Step 4: Run monitor, fall and full Go tests**
Run: `Set-Location v2; $env:CGO_ENABLED='1'; go test ./internal/monitor ./internal/fall ./...`
Expected: PASS.
- [ ] **Step 5: Commit the monitor slice**
- [x] **Step 5: Commit the monitor slice**
```powershell
git add v2/internal/monitor v2/internal/spike/ort.go