remove: skin_tone_trace node type

- skin_tone is a person attribute (like height), not trace attribute
- Remove build_skin_tone_trace_nodes function
- Remove skin_tone_trace_nodes from TkgResult and API response
- Remove skin_tone_trace from documentation tables
This commit is contained in:
Accusys
2026-06-25 19:21:05 +08:00
parent fd2edd5736
commit 0c3f385b1f
4 changed files with 0 additions and 203 deletions

View File

@@ -72,7 +72,6 @@ Temporal Knowledge Graph (TKG) is built from multi-processor outputs to create a
| `build_yolo_object_nodes` | `object` | `yolo.json` |
| `build_hand_nodes` | `hand` | `pose.json` |
| `build_speaker_nodes` | `speaker` | `asrx.json` |
| `build_skin_tone_trace_nodes` | `skin_tone_trace` | **TODO** |
---
@@ -122,7 +121,6 @@ Temporal Knowledge Graph (TKG) is built from multi-processor outputs to create a
| `lip_track` | `lip_track_{id}` | `speaker_id`, `lip_area_range` |
| `text_region` | `text_region_{id}` | `speaker_id`, `text`, `start_time`, `end_time` |
| `appearance_trace` | `appearance_{trace_id}` | `clothing_color`, `upper_cloth`, `lower_cloth` |
| `skin_tone_trace` | `skin_tone_{trace_id}` | `fitzpatrick_type` (I-VI) - **TODO** |
| `accessory` | `accessory_{id}` | `type` (glasses/hat/etc.), `confidence` |
| `object` | `object_{class}_{id}` | `class`, `confidence`, `frame_count` |
| `speaker` | `speaker_{speaker_id}` | `speaker_id`, `segment_count`, `total_duration` |
@@ -209,113 +207,6 @@ graph TB
---
## skin_tone_trace Implementation
### Status: ✅ Implemented (2026-06-25)
See `src/core/processor/tkg.rs` lines 2579-2627 for implementation.
### Overview
Skin tone classification using Fitzpatrick scale from face skin color analysis.
### Fitzpatrick Classification
| Type | Skin H Range (HSV) | Description | Example |
|------|-------------------|-------------|---------|
| I | H < 10° | Very fair/pale | Northern European |
| II | 10° ≤ H < 20° | Fair | European |
| III | 20° ≤ H < 30° | Medium | Mediterranean |
| IV | 30° ≤ H < 40° | Olive | Asian, Hispanic |
| V | 40° ≤ H < 50° | Brown | Indian, African |
| VI | H ≥ 50° | Dark brown | African |
### Implementation
**Rust Code Location:** `src/core/processor/tkg.rs`
```rust
// Add to build_tkg()
let n_skin = build_skin_tone_trace_nodes(pool, file_uuid).await?;
// Add to TkgResult
pub skin_tone_trace_nodes: usize,
// New builder function
async fn build_skin_tone_trace_nodes(
pool: &PgPool,
file_uuid: &str,
) -> Result<usize> {
let fd_table = t("face_detections");
// Step 1: Get avg skin H per trace
let rows: Vec<(i64, f64)> = sqlx::query_as(&format!(
"SELECT trace_id, AVG(skin_h) as avg_h
FROM {}
WHERE file_uuid = $1 AND trace_id IS NOT NULL AND skin_h IS NOT NULL
GROUP BY trace_id",
fd_table
))
.bind(file_uuid)
.fetch_all(pool)
.await?;
// Step 2: Classify Fitzpatrick
let nodes_table = t("tkg_nodes");
let mut count = 0;
for (trace_id, avg_h) in &rows {
let fitz_type = classify_fitzpatrick(*avg_h);
let external_id = format!("skin_tone_{}", trace_id);
let label = format!("Skin Tone Trace {}", trace_id);
sqlx::query(&format!(
"INSERT INTO {} (node_type, external_id, file_uuid, label, properties)
VALUES ('skin_tone_trace', $1, $2, $3, $4::jsonb)
ON CONFLICT (file_uuid, node_type, external_id) DO UPDATE SET properties = EXCLUDED.properties",
nodes_table
))
.bind(&external_id)
.bind(file_uuid)
.bind(&label)
.bind(serde_json::json!({
"trace_id": trace_id,
"avg_skin_h": avg_h,
"fitzpatrick_type": fitz_type,
}))
.execute(pool)
.await?;
count += 1;
}
Ok(count)
}
fn classify_fitzpatrick(h: f64) -> &'static str {
if h < 10.0 { "I" }
else if h < 20.0 { "II" }
else if h < 30.0 { "III" }
else if h < 40.0 { "IV" }
else if h < 50.0 { "V" }
else { "VI" }
}
```
### Dependencies
- `face_detections.trace_id` must be populated (from Phase 0)
- `face.json` used for skin_h estimation (placeholder based on attributes)
- `output_dir` path must be passed to builder
### Limitations
- Current skin_h estimation is placeholder (based on face attributes)
- For accurate Fitzpatrick classification, face ROI color extraction needed
- Face.json doesn't store skin_h directly (would need video frame analysis)
---
## SQL Query Examples
### Status Queries