feat: add bbox_size field for frontend filtering
- Database: Added bbox_size column (min(width, height)) to face_filter_features - API: Updated all endpoints to include bbox_size in responses - Documentation: Added bbox_size explanation and frontend filtering examples - Maintains current Swift implementation calculation method - Enables efficient frontend filtering without backend threshold This allows the frontend to do real-time filtering using bbox_size while the backend pre-computes and stores the value.
This commit is contained in:
@@ -53,6 +53,7 @@ Face Filter API 提供臉部過濾功能,讓 Studio 前端可以:
|
||||
"face_id": "face_001",
|
||||
"file_uuid": "0489e104d7d1e11e613da01f7aa130ca",
|
||||
"frame": 671,
|
||||
"bbox_size": 336, // 新增:min(width, height)
|
||||
"eye_ratio": 0.33,
|
||||
"nose_ratio": 0.02,
|
||||
"pose_score": 0.08,
|
||||
@@ -485,6 +486,47 @@ console.log(`Saved rule: ${savedRule.rule_name} (id: ${savedRule.id})`);
|
||||
|
||||
---
|
||||
|
||||
### Bbox Size 說明
|
||||
|
||||
**欄位**: `bbox_size`
|
||||
|
||||
**計算方式**: `min(width, height)`
|
||||
|
||||
**說明**:
|
||||
- 預先計算並儲存於後端
|
||||
- 用於前端即時過濾
|
||||
- 維持當前 Swift 實作的計算方式
|
||||
|
||||
**前端過濾範例**:
|
||||
```typescript
|
||||
// 前端即時過濾
|
||||
const quickFilter = (faces, rules) => {
|
||||
return faces.filter(face => {
|
||||
// Bbox size 過濾
|
||||
if (rules.min_bbox_size && face.filter_features.bbox_size < rules.min_bbox_size) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
// 使用範例
|
||||
const filtered = quickFilter(allFaces, {
|
||||
min_bbox_size: 80 // 最小 80 像素
|
||||
});
|
||||
```
|
||||
|
||||
**建議閾值**:
|
||||
- 保守: 80 像素
|
||||
- 平衡: 64 像素(當前預設)
|
||||
- 寬鬆: 48 像素
|
||||
|
||||
**未來擴展**:
|
||||
- 可考慮增加 `max(bbox.width, bbox.height)` 選項
|
||||
- 可考慮增加 `bbox.width * bbox.height` (面積) 選項
|
||||
|
||||
---
|
||||
|
||||
## 預設配置
|
||||
|
||||
API 提供預設過濾規則,可直接使用:
|
||||
|
||||
Reference in New Issue
Block a user