Files
security-ai-edge/docs/表结构对比报告.md
16337 745cadc8e7 feat: TensorRT 固定 batch=4 重构
- tensorrt_engine.py 工业级 Buffer Pool
- preprocessor.py 添加 pad_to_batch4()
- postprocessor.py 支持批量输出
- settings.py 固定 batch_size=4
2026-02-02 14:49:47 +08:00

124 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 表结构对比报告
---
### 一、原始表结构SQLAlchemy ORM云边同步型
#### 1. Camera 摄像头表
| 字段 | 类型 | 说明 |
|------|------|------|
| id | Integer | 主键 |
| cloud_id | Integer | 云端ID |
| name | String(64) | 名称 |
| rtsp_url | Text | RTSP地址 |
| enabled | Boolean | 启用 |
| fps_limit | Integer | 帧率限制 |
| process_every_n_frames | Integer | 跳帧处理 |
| pending_sync | Boolean | 待同步 |
| sync_failed_at | DateTime | 失败时间 |
| sync_retry_count | Integer | 重试次数 |
#### 2. CameraStatus 运行状态表
| 字段 | 类型 | 说明 |
|------|------|------|
| is_running | Boolean | 运行状态 |
| last_frame_time | DateTime | 最后帧时间 |
| fps | Float | 当前帧率 |
| error_message | Text | 错误信息 |
#### 3. ROI 规则+行为表
| 字段 | 类型 | 说明 |
|------|------|------|
| roi_id | String(64) | 唯一标识 |
| name | String(128) | 名称 |
| roi_type | String | ROI类型 |
| points | Text | 坐标(JSON) |
| rule_type | String | 规则类型 |
| stay_time | Integer | 停留时间 |
| threshold_sec | Integer | 确认阈值 |
| confirm_sec | Integer | 确认时间 |
| return_sec | Integer | 恢复时间 |
| working_hours | Text | 工作时段 |
#### 4. Alarm 告警表
| 字段 | 类型 | 说明 |
|------|------|------|
| cloud_id | Integer | 云端ID |
| upload_status | Text | 上传状态 |
| llm_checked | Boolean | LLM审核 |
| processed | Boolean | 处理标记 |
---
### 二、当前项目表结构SQLite边缘实时型
#### 1. camera_configs 摄像头配置
| 字段 | 类型 | 说明 |
|------|------|------|
| camera_id | TEXT PK | 主键 |
| rtsp_url | TEXT | RTSP地址 |
| camera_name | TEXT | 名称 |
| status | BOOLEAN | 状态 |
| enabled | BOOLEAN | 启用 |
#### 2. roi_configs ROI+算法配置 ⭐
| 字段 | 类型 | 说明 |
|------|------|------|
| roi_id | TEXT PK | 主键 |
| camera_id | TEXT | 摄像头ID |
| coordinates | TEXT | 坐标 |
| **algorithm_type** | TEXT | **算法类型** |
| confirm_on_duty_sec | INTEGER | 在职确认 |
| confirm_leave_sec | INTEGER | 离岗确认 |
| cooldown_sec | INTEGER | 冷却时间 |
| target_class | TEXT | 目标类别 |
#### 3. alert_records 告警记录
| 字段 | 类型 | 说明 |
|------|------|------|
| alert_id | TEXT UK | 告警UUID |
| camera_id | TEXT | 摄像头 |
| alert_type | TEXT | 类型 |
| confidence | REAL | 置信度 |
| bbox | TEXT | 边界框 |
| **duration_minutes** | REAL | **离岗时长** |
| status | TEXT | 状态 |
#### 4. config_update_log 配置日志(新增)
| 字段 | 类型 | 说明 |
|------|------|------|
| config_type | TEXT | 配置类型 |
| old_value/new_value | TEXT | 变更前后 |
---
### 三、核心差异总结
| 维度 | 原始设计 | 当前设计 |
|------|---------|---------|
| 定位 | 云端主控 | 边缘实时 |
| ORM | SQLAlchemy强关联 | 无(扁平化) |
| 云边同步 | cloud_id/sync_version | 未实现 |
| ROI语义 | 规则驱动 | **算法驱动** ⭐ |
| 运维状态 | 独立CameraStatus表 | 无 |
| 配置审计 | 无 | **有** ⭐ |
| 离岗时长 | 隐含字段 | **显式字段** ⭐ |
---
### 四、当前项目优势
1. **algorithm_type 字段** - 支持多算法多ROI
2. **config_update_log** - 可审计可追溯
3. **异步写入队列** - 高性能
4. **WAL模式** - 提升写入性能
5. **7天自动清理** - 磁盘管理
---
### 五、建议补强
1. 添加 `camera_status` 表记录运行状态
2. 可扩展云边同步模块
3. **duration_minutes 已添加**