VeuReu commited on
Commit
1725eae
·
verified ·
1 Parent(s): d4682f0

Upload 2 files

Browse files
Files changed (1) hide show
  1. character_detection.py +9 -4
character_detection.py CHANGED
@@ -55,7 +55,7 @@ class CharacterDetector:
55
  d.mkdir(parents=True, exist_ok=True)
56
 
57
  def extract_faces_embeddings(self, *, start_offset_sec: float = 3.0, extract_every_sec: float = 0.5,
58
- detector_backend: str = 'mtcnn', min_face_area: int = 400,
59
  enforce_detection: bool = False) -> List[Dict[str, Any]]:
60
  """
61
  Extrae caras del vídeo y calcula sus embeddings usando DeepFace directamente.
@@ -117,9 +117,14 @@ class CharacterDetector:
117
  except Exception:
118
  pass
119
 
120
- # Guardar el frame completo
121
- save_path = self.faces_dir / f"frame_{saved_count:04d}.jpg"
122
- cv2.imwrite(str(save_path), frame)
 
 
 
 
 
123
 
124
  embeddings_caras.append({
125
  "embeddings": embedding,
 
55
  d.mkdir(parents=True, exist_ok=True)
56
 
57
  def extract_faces_embeddings(self, *, start_offset_sec: float = 3.0, extract_every_sec: float = 0.5,
58
+ detector_backend: str = 'retinaface', min_face_area: int = 100,
59
  enforce_detection: bool = False) -> List[Dict[str, Any]]:
60
  """
61
  Extrae caras del vídeo y calcula sus embeddings usando DeepFace directamente.
 
117
  except Exception:
118
  pass
119
 
120
+ # Guardar recorte de la cara (mejor para UI y clustering visual)
121
+ x = int(facial_area.get('x', 0)); y = int(facial_area.get('y', 0))
122
+ w = int(facial_area.get('w', 0)); h = int(facial_area.get('h', 0))
123
+ x2 = max(0, x); y2 = max(0, y)
124
+ x3 = min(frame.shape[1], x + w); y3 = min(frame.shape[0], y + h)
125
+ crop = frame[y2:y3, x2:x3] if (x3 > x2 and y3 > y2) else frame
126
+ save_path = self.faces_dir / f"face_{saved_count:04d}.jpg"
127
+ cv2.imwrite(str(save_path), crop)
128
 
129
  embeddings_caras.append({
130
  "embeddings": embedding,