diff --git a/src/core/processor/face.rs b/src/core/processor/face.rs index 05d1d5cf..a94febbb 100644 --- a/src/core/processor/face.rs +++ b/src/core/processor/face.rs @@ -116,6 +116,19 @@ impl FaceResult { self.metadata = Some(metadata); } + /// Generate face_id for faces that don't have one. + /// Format: face_{frame}_{index_within_frame} + pub fn ensure_face_ids(&mut self) { + for frame in &mut self.frames { + let frame_num = frame.frame; + for (idx, face) in frame.faces.iter_mut().enumerate() { + if face.face_id.is_none() { + face.face_id = Some(format!("face_{}_{}", frame_num, idx)); + } + } + } + } + pub fn save_to_file(&self, path: &str) -> Result<()> { self.save_to_file_with_source(path, None, None) } @@ -281,6 +294,7 @@ pub async fn process_face( result.compute_status(); result.add_metadata("face", "swift_face", uuid); + result.ensure_face_ids(); result.save_to_file(output_path)?; tracing::info!( @@ -431,6 +445,7 @@ pub async fn process_face( tracing::info!("[FACE] Face tracking completed successfully"); } + result.ensure_face_ids(); result.save_to_file(output_path)?; tracing::info!( @@ -486,6 +501,7 @@ pub async fn process_face( tracing::info!("[FACE] Face tracking completed successfully"); } + result.ensure_face_ids(); result.save_to_file(output_path)?; tracing::info!( @@ -604,6 +620,7 @@ async fn run_face_with_config( serde_json::from_str(&json_str).context("Failed to parse Swift FACE output")?; result.compute_status(); result.add_metadata("face", "swift_face", uuid); + result.ensure_face_ids(); result.save_to_file(output_path)?; if let Some(uid) = uuid { @@ -647,6 +664,7 @@ async fn run_face_with_config( .context("Failed to parse Python FACE output")?; result.compute_status(); result.add_metadata("face", "python_face_processor", uuid); + result.ensure_face_ids(); result.save_to_file(output_path)?; if let Some(uid) = uuid {