reab5555 commited on
Commit
b6b1cef
·
verified ·
1 Parent(s): 02229ea

Update face_analysis.py

Browse files
Files changed (1) hide show
  1. face_analysis.py +10 -7
face_analysis.py CHANGED
@@ -43,15 +43,18 @@ def organize_faces_by_person(embeddings_by_frame, clusters, aligned_faces_folder
43
 
44
 
45
  def draw_facial_landmarks(image, landmarks):
 
46
  mp_drawing = mp.solutions.drawing_utils
47
 
48
- # Adjust these values to make the drawing thinner and less obtrusive
49
- landmark_drawing_spec = mp_drawing.DrawingSpec(color=(0, 255, 0), thickness=1, circle_radius=1)
 
50
 
51
  if landmarks:
52
- for landmark in landmarks.landmark:
53
- x = int(landmark.x * image.shape[1])
54
- y = int(landmark.y * image.shape[0])
55
- cv2.circle(image, (x, y), landmark_drawing_spec.circle_radius, landmark_drawing_spec.color, landmark_drawing_spec.thickness)
56
-
 
57
  return image
 
43
 
44
 
45
  def draw_facial_landmarks(image, landmarks):
46
+ mp_face_mesh = mp.solutions.face_mesh
47
  mp_drawing = mp.solutions.drawing_utils
48
 
49
+ # Adjust these values to make the drawing thinner
50
+ landmark_drawing_spec = mp_drawing.DrawingSpec(color=(255, 0, 0), thickness=1, circle_radius=1)
51
+ connection_drawing_spec = mp_drawing.DrawingSpec(color=(255, 0, 0), thickness=1)
52
 
53
  if landmarks:
54
+ mp_drawing.draw_landmarks(
55
+ image=image,
56
+ landmark_list=landmarks,
57
+ connections=mp_face_mesh.FACEMESH_TESSELATION,
58
+ landmark_drawing_spec=landmark_drawing_spec,
59
+ connection_drawing_spec=connection_drawing_spec)
60
  return image