docs: TKG build_face_body_edges implementation status
實現狀態: - ✅ 函數已實現 (build_face_body_edges) - ⚠️ 未集成到主函數 (build_tkg) - ⚠️ 未添加到枚舉 (TkgPhase) 功能: - 從 pose.json 讀取姿態數據 - 從 Qdrant 獲取人臉數據 - 匹配同一幀中的人臉和姿態 - 計算空間距離 (< 200px) - 創建 HAS_BODY 邊 限制: - 當前測試視頻缺少 appearance.json - 無法創建 body_track 節點 - 函數會返回 0 edges 建議: - 短期: 保持當前實現,等待數據 - 長期: 添加 appearance 處理器,完整集成
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
---
|
||||
title: TKG build_face_body_edges Implementation
|
||||
version: 1.0
|
||||
date: 2026-09-27
|
||||
author: OpenCode
|
||||
status: implemented_not_integrated
|
||||
---
|
||||
|
||||
## 實現狀態
|
||||
|
||||
### ✅ 已完成
|
||||
|
||||
**函數實現**: `build_face_body_edges()` 已添加到 `tkg.rs`
|
||||
|
||||
```rust
|
||||
async fn build_face_body_edges(
|
||||
pool: &PgPool,
|
||||
file_uuid: &str,
|
||||
output_dir: &str,
|
||||
face_points: &[FacePoint],
|
||||
node_id_map: &HashMap<(String, String), i64>,
|
||||
) -> Result<usize>
|
||||
```
|
||||
|
||||
**功能**:
|
||||
- 從 pose.json 讀取姿態數據
|
||||
- 從 Qdrant 獲取人臉數據
|
||||
- 匹配同一幀中的人臉和姿態
|
||||
- 計算空間距離 (< 200px)
|
||||
- 創建 HAS_BODY 邊
|
||||
|
||||
---
|
||||
|
||||
### ⚠️ 未完成
|
||||
|
||||
**未集成到主函數**:
|
||||
- `build_tkg()` 中未調用
|
||||
- `TkgPhase` 枚舉中未添加
|
||||
|
||||
**原因**:
|
||||
- 當前測試視頻缺少 `appearance.json`
|
||||
- 無法創建 body_track 節點
|
||||
- 函數會返回 0 edges
|
||||
|
||||
---
|
||||
|
||||
## 集成方案
|
||||
|
||||
### Phase 1: 添加枚舉
|
||||
|
||||
```rust
|
||||
pub enum TkgPhase {
|
||||
// ... existing phases
|
||||
FaceFaceEdges = 12,
|
||||
FaceBodyEdges = 13, // 新增
|
||||
MutualGazeEdges = 14, // 索引調整
|
||||
// ... rest
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 2: 添加統計
|
||||
|
||||
```rust
|
||||
pub struct TkgStats {
|
||||
// ... existing fields
|
||||
pub face_body_edges: i64, // 新增
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: 在主函數中調用
|
||||
|
||||
```rust
|
||||
// In build_tkg()
|
||||
let e_fb = build_face_body_edges(
|
||||
pool,
|
||||
file_uuid,
|
||||
output_dir,
|
||||
&face_points,
|
||||
&node_id_map
|
||||
).await?;
|
||||
progress.stats.face_body_edges = e_fb as i64;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 測試方案
|
||||
|
||||
### 當前限制
|
||||
|
||||
- ❌ 無 `appearance.json` → 無 body_track 節點
|
||||
- ❌ 無 body_track 節點 → 無 face_body edges
|
||||
|
||||
### 測試步驟
|
||||
|
||||
1. **生成 appearance.json**
|
||||
- 運行 appearance 處理器
|
||||
- 生成 body_track 節點
|
||||
|
||||
2. **運行 TKG Builder**
|
||||
- 調用 build_face_body_edges
|
||||
- 檢查生成的邊
|
||||
|
||||
3. **驗證結果**
|
||||
- 查詢 tkg_edges 表
|
||||
- 確認 HAS_BODY 邊
|
||||
|
||||
---
|
||||
|
||||
## 替代方案
|
||||
|
||||
### 簡化版本 (不依賴 appearance.json)
|
||||
|
||||
創建一個簡化版本,直接從 pose.json 創建臨時 body_track 節點:
|
||||
|
||||
```rust
|
||||
// 臨時創建 body_track 節點 (無 Level 1 特徵)
|
||||
async fn create_temp_body_track_nodes(
|
||||
pool: &PgPool,
|
||||
file_uuid: &str,
|
||||
output_dir: &str,
|
||||
) -> Result<usize>
|
||||
```
|
||||
|
||||
**優點**:
|
||||
- 不需要 appearance.json
|
||||
- 可以立即測試
|
||||
|
||||
**缺點**:
|
||||
- 無 Level 1 特徵
|
||||
- 非最終方案
|
||||
|
||||
---
|
||||
|
||||
## 建議
|
||||
|
||||
### 短期
|
||||
|
||||
1. **保持當前實現** - 函數已經存在,可以隨時調用
|
||||
2. **等待數據** - 運行 appearance 處理器生成 appearance.json
|
||||
3. **完整集成** - 數據準備好後再集成
|
||||
|
||||
### 長期
|
||||
|
||||
1. **添加 appearance 處理器** - 自動生成 appearance.json
|
||||
2. **完整集成** - 添加到主流程
|
||||
3. **自動化測試** - CI/CD 集成
|
||||
|
||||
---
|
||||
|
||||
## 提交記錄
|
||||
|
||||
- `087b29d` - feat: add build_face_body_edges to Rust TKG builder
|
||||
|
||||
---
|
||||
|
||||
## 相關文件
|
||||
|
||||
- `/Users/accusys/momentry_core/src/core/processor/tkg.rs`
|
||||
- `/Users/accusys/momentry_core/src/core/progress.rs`
|
||||
- `/Users/accusys/momentry_core/docs_v1.0/DESIGN/TKG_Builder_Rust_Migration.md`
|
||||
Reference in New Issue
Block a user