fix(face-mask): guard create_face_mask against None frame

This commit is contained in:
gujishh
2026-04-12 14:19:48 +09:00
parent 8703d394d6
commit fbcea9e135
2 changed files with 111 additions and 1 deletions
+4 -1
View File
@@ -1028,10 +1028,13 @@ def apply_mouth_area(
def create_face_mask(face: Face, frame: Frame) -> np.ndarray:
"""Creates a feathered mask covering the whole face area based on landmarks."""
if frame is None or not hasattr(frame, "shape") or len(frame.shape) < 2:
return np.zeros((0, 0), dtype=np.uint8)
mask = np.zeros(frame.shape[:2], dtype=np.uint8) # Start with uint8
# Validate inputs
if face is None or not hasattr(face, 'landmark_2d_106') or frame is None:
if face is None or not hasattr(face, 'landmark_2d_106'):
# print("Warning: Invalid face or frame for create_face_mask.")
return mask # Return empty mask