Update face_analysis.py
Browse files- face_analysis.py +13 -5
face_analysis.py
CHANGED
@@ -46,15 +46,23 @@ 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 |
-
|
51 |
-
connection_drawing_spec = mp_drawing.DrawingSpec(color=(255, 0, 0), thickness=1)
|
52 |
|
53 |
if landmarks:
|
|
|
|
|
|
|
|
|
54 |
mp_drawing.draw_landmarks(
|
55 |
-
image=
|
56 |
landmark_list=landmarks,
|
57 |
connections=mp_face_mesh.FACEMESH_TESSELATION,
|
58 |
-
landmark_drawing_spec=
|
59 |
connection_drawing_spec=connection_drawing_spec)
|
|
|
|
|
|
|
|
|
|
|
60 |
return image
|
|
|
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 and less obtrusive
|
50 |
+
connection_drawing_spec = mp_drawing.DrawingSpec(color=(0, 0, 255), thickness=1)
|
|
|
51 |
|
52 |
if landmarks:
|
53 |
+
# Create a blank image with the same dimensions as the input image
|
54 |
+
connections_layer = np.zeros_like(image)
|
55 |
+
|
56 |
+
# Draw connections on the blank image
|
57 |
mp_drawing.draw_landmarks(
|
58 |
+
image=connections_layer,
|
59 |
landmark_list=landmarks,
|
60 |
connections=mp_face_mesh.FACEMESH_TESSELATION,
|
61 |
+
landmark_drawing_spec=None, # Set to None to avoid drawing points
|
62 |
connection_drawing_spec=connection_drawing_spec)
|
63 |
+
|
64 |
+
# Blend the connections layer with the original image
|
65 |
+
alpha = 0.2
|
66 |
+
image = cv2.addWeighted(image, 1, connections_layer, alpha, 0)
|
67 |
+
|
68 |
return image
|