fix: add face tracking to Swift processor path

- Add track_faces() call to Swift Face processor path
- Previously only in Python processor path
- Now all paths execute face tracking
- Test successful: 212/212 faces have trace_id
- 9 traces detected in test video (020.mp4)
This commit is contained in:
Accusys
2026-09-27 02:58:47 +08:00
parent 48eca7d836
commit 835772ba73
2 changed files with 63 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
use momentry_core::core::processor::face::process_face;
#[tokio::main]
async fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() < 3 {
eprintln!("Usage: test_rust_face_tracker <video_path> <output_path> [uuid]");
std::process::exit(1);
}
let video_path = &args[1];
let output_path = &args[2];
let uuid = args.get(3).map(|s| s.as_str());
println!("Processing video: {}", video_path);
println!("Output: {}", output_path);
println!("UUID: {:?}", uuid);
match process_face(video_path, output_path, uuid, None).await {
Ok(result) => {
println!("✅ Face processing completed");
println!(" Total frames: {}", result.frames.len());
println!(" Total faces: {}", result.total_faces);
// 統計 trace_id
let with_trace = result.frames.iter()
.flat_map(|f| &f.faces)
.filter(|face| face.trace_id.is_some())
.count();
println!(" Faces with trace_id: {}/{}", with_trace, result.total_faces);
// 顯示 trace_id 分佈
let mut traces = std::collections::HashMap::new();
for frame in &result.frames {
for face in &frame.faces {
if let Some(tid) = face.trace_id {
*traces.entry(tid).or_insert(0) += 1;
}
}
}
println!("\n Trace ID distribution:");
for (tid, count) in traces.iter() {
println!(" Trace {}: {} faces", tid, count);
}
}
Err(e) => {
eprintln!("❌ Error: {}", e);
std::process::exit(1);
}
}
}
+10
View File
@@ -247,6 +247,16 @@ pub async fn process_face(
let json_str = std::fs::read_to_string(output_path).context("Failed to read FACE output")?;
let mut result: FaceResult = serde_json::from_str(&json_str).context("Failed to parse FACE output")?;
result.compute_status();
// Execute face tracking
tracing::info!("[FACE] Starting face tracking");
use crate::core::processor::face_tracker::track_faces;
if let Err(e) = track_faces(&mut result, 0.3, 0.7, 100.0, true, None) {
tracing::warn!("[FACE] Face tracking failed: {}", e);
} else {
tracing::info!("[FACE] Face tracking completed successfully");
}
result.save_to_file(output_path)?;
tracing::info!(