将 Demo 录制收敛为三条独立链路,并重做联调台 UI。
移除 demo_orch 统一编排,改为 recording_demo 与 live/simulated 服务;客户端拆分为静态资源,以模式卡片与 chip 耗材覆盖三链路联调,并同步测试与文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,43 +1,55 @@
|
||||
# Demo Client
|
||||
# Demo Client · 联调台
|
||||
|
||||
独立浏览器联调页,用于手动触发监控 API 的部分 `/client/*` 接口:开始/结束手术、查询结果等。语音待确认、TTS 与麦克风录音请使用同级的 [`../voice-confirmation/`](../voice-confirmation/) 或其它专用客户端。
|
||||
浏览器联调页,覆盖三条录制链路。语音待确认请使用 [`../voice-confirmation/`](../voice-confirmation/)(默认 :8080)。
|
||||
|
||||
## 结构
|
||||
## 三条链路
|
||||
|
||||
```
|
||||
clients/demo-client/
|
||||
start.sh
|
||||
server.py
|
||||
index.html
|
||||
labels.yaml # 耗材类名快照(与 backend/app/resources/consumable_classifier_labels.yaml 同步)
|
||||
fake_rtsp_from_file.py
|
||||
```
|
||||
| 模式 | 操作 | API | 语音 | 结束手术 |
|
||||
|------|------|-----|------|----------|
|
||||
| **链路 1 · 真摄像头** | 填 camera_id → 开始手术 | `POST /client/surgeries/start` | 需要 | 需要 |
|
||||
| **链路 2 · 模拟实时** | 选满 N 路视频 → 开始模拟开录 | `POST /internal/demo/simulated-start` | 需要 | 需要 |
|
||||
| **链路 3 · 离线精确** | 选 MP4 → 上传并处理 | `POST /internal/demo/offline-batch` | 无 | 不需要 |
|
||||
|
||||
**`labels.yaml`**:本目录自带副本,与后端解耦。后端类名变更时,请同步更新此文件。
|
||||
链路 2/3 需 `DEMO_ORCHESTRATOR_ENABLED=true`;链路 2 还需可写 `OR_SITE_CONFIG_JSON_FILE`。页顶「刷新状态」可查看 API 与 Demo 模式是否就绪。
|
||||
|
||||
## 界面说明
|
||||
|
||||
- **模式卡片**:点选切换,只显示当前模式相关配置
|
||||
- **耗材**:标签 chip 多选;「高级」可编辑 JSON
|
||||
- **链路 2**:默认只需上传视频;RTSP 路径与 camera_id 在「高级」折叠
|
||||
- **链路 3**:独立 MP4 上传区,可选生成标注视频
|
||||
- **开发者日志**:右侧折叠,记录完整 HTTP 请求/响应
|
||||
|
||||
## 运行
|
||||
|
||||
```bash
|
||||
# 1) 启动 Docker 后端
|
||||
cd backend && docker compose up -d --build
|
||||
|
||||
# 2) 在本目录启动 Demo 页
|
||||
cd ../clients/demo-client && ./start.sh
|
||||
|
||||
# 3) 浏览器访问
|
||||
open http://127.0.0.1:38081/
|
||||
```
|
||||
|
||||
页面「服务端 Base URL」默认指向同主机 `:38080`;后端在其他机器时手动改为 `http://<GPU服务器IP>:38080`。
|
||||
「API 地址」默认 `http://127.0.0.1:38080`;从局域网访问 demo 页时会自动改用当前主机 IP。
|
||||
|
||||
## 调试:无真实摄像头,用录好的视频模拟 RTSP
|
||||
## 文件
|
||||
|
||||
```bash
|
||||
python3 fake_rtsp_from_file.py /path/to/recording.mp4 --port 18554 --path demo
|
||||
```
|
||||
clients/demo-client/
|
||||
index.html # 页面骨架
|
||||
styles.css # 样式
|
||||
app.js # 逻辑
|
||||
server.py # 静态服务 + GET /labels.json
|
||||
labels.yaml # 耗材标签(与后端同步)
|
||||
start.sh
|
||||
```
|
||||
|
||||
容器内 API 访问宿主机 RTSP 应使用 `host.docker.internal`。详见 [`../../docs/video-backends.md`](../../docs/video-backends.md)。
|
||||
## 手跑假 RTSP(链路 2 高级)
|
||||
|
||||
```bash
|
||||
python3 fake_rtsp_from_file.py /path/to/video.mp4 --port 18554 --path demo
|
||||
```
|
||||
|
||||
详见 [`../../docs/video-backends.md`](../../docs/video-backends.md)。
|
||||
|
||||
## CORS
|
||||
|
||||
跨域访问 API 时,后端 `backend/.env` 需 `DEMO_CORS_ENABLED=true`;生产环境收窄 `DEMO_CORS_ORIGINS`。
|
||||
跨域访问 API 时设置 `DEMO_CORS_ENABLED=true`。
|
||||
|
||||
Reference in New Issue
Block a user