重组为 backend/clients/docs 三层结构,并清理 git 污染。
将后端迁入 backend/,完善根目录 .gitignore,删除误提交的 .mypy_cache 缓存文件。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
|
||||
```
|
||||
clients/demo-client/
|
||||
start.sh # 启动入口(默认 0.0.0.0:38081)
|
||||
server.py # stdlib 静态服务器;额外暴露 /labels.json
|
||||
index.html # 单文件页面(原生 JS,零构建依赖)
|
||||
labels.yaml # 耗材类名快照(与后端 app/resources/consumable_classifier_labels.yaml 同步)
|
||||
fake_rtsp_from_file.py # 无真摄像头时:本地视频推 RTSP(ffmpeg + Docker MediaMTX)
|
||||
start.sh
|
||||
server.py
|
||||
index.html
|
||||
labels.yaml # 耗材类名快照(与 backend/app/resources/consumable_classifier_labels.yaml 同步)
|
||||
fake_rtsp_from_file.py
|
||||
```
|
||||
|
||||
**`labels.yaml`**:本目录自带副本,与后端解耦。后端类名变更时,请同步更新此文件。
|
||||
@@ -18,12 +18,11 @@ clients/demo-client/
|
||||
## 运行
|
||||
|
||||
```bash
|
||||
# 1) 在仓库根目录启动 Docker 后端
|
||||
docker compose up -d --build
|
||||
# 1) 启动 Docker 后端
|
||||
cd backend && docker compose up -d --build
|
||||
|
||||
# 2) 在本目录启动 Demo 页
|
||||
./start.sh
|
||||
# 或:python server.py -p 38081 --host 0.0.0.0
|
||||
cd ../clients/demo-client && ./start.sh
|
||||
|
||||
# 3) 浏览器访问
|
||||
open http://127.0.0.1:38081/
|
||||
@@ -33,40 +32,12 @@ open http://127.0.0.1:38081/
|
||||
|
||||
## 调试:无真实摄像头,用录好的视频模拟 RTSP
|
||||
|
||||
监控服务**只从 RTSP URL 拉流**,没有视频上传 HTTP 接口。推荐在宿主机用 **ffmpeg + MediaMTX** 推假流:
|
||||
|
||||
**单路**:
|
||||
|
||||
```bash
|
||||
python3 fake_rtsp_from_file.py /path/to/recording.mp4 --port 18554 --path demo
|
||||
```
|
||||
|
||||
**两路**:
|
||||
|
||||
```bash
|
||||
python3 fake_rtsp_from_file.py --port 18554 \
|
||||
--stream 'or-cam-01|./a.mp4|demo1' \
|
||||
--stream 'or-cam-02|./b.mp4|demo2'
|
||||
```
|
||||
|
||||
`--stream` 格式:`CAMERA_ID|文件路径|RTSP_PATH`。脚本会在 stderr 打印站点 JSON 片段,可合并进后端的 `OR_SITE_CONFIG_JSON_FILE`。
|
||||
|
||||
### API 在 Docker、假 RTSP 在宿主机
|
||||
|
||||
容器内访问宿主机 RTSP 应使用 `rtsp://host.docker.internal:<端口>/<路径>`(compose 已配置 `extra_hosts`)。详见 [`../../docs/video-backends.md`](../../docs/video-backends.md)。
|
||||
|
||||
## 一键开录
|
||||
|
||||
Demo 页勾选「一键联调」后上传视频,调用 `POST /internal/demo/orchestrate-and-start`。需后端 `.env` 中 `DEMO_ORCHESTRATOR_ENABLED=true`,且 API 容器能执行 `docker`/`ffmpeg`(通常需挂载 docker.sock)。
|
||||
|
||||
## 页面功能
|
||||
|
||||
- `GET /health` 连通性检查
|
||||
- `POST /client/surgeries/start|end`、`GET /client/surgeries/{id}/result`
|
||||
- 调试区:多路视频、假 RTSP、`camera_id` 同步
|
||||
|
||||
不含语音确认 UI(见 [`../voice-confirmation/`](../voice-confirmation/))。
|
||||
容器内 API 访问宿主机 RTSP 应使用 `host.docker.internal`。详见 [`../../docs/video-backends.md`](../../docs/video-backends.md)。
|
||||
|
||||
## CORS
|
||||
|
||||
跨域访问 API 时,后端需 `DEMO_CORS_ENABLED=true`;生产环境收窄 `DEMO_CORS_ORIGINS`。
|
||||
跨域访问 API 时,后端 `backend/.env` 需 `DEMO_CORS_ENABLED=true`;生产环境收窄 `DEMO_CORS_ORIGINS`。
|
||||
|
||||
Reference in New Issue
Block a user