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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user