From be16a588c290ca9c170e419795323a45c7a03237 Mon Sep 17 00:00:00 2001 From: Accusys Date: Tue, 17 Nov 2026 19:29:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8B=95=E7=94=A2=E7=94=9F=20?= =?UTF-8?q?face=5Fid=EF=BC=88face=5F{frame}=5F{idx}=EF=BC=89=E6=96=BC=20fa?= =?UTF-8?q?ce.json=20=E5=84=B2=E5=AD=98=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/processor/face.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 {