RojaKatta commited on
Commit
b7315d8
·
verified ·
1 Parent(s): dd4a0c4

Delete segmentation.py

Browse files
Files changed (1) hide show
  1. segmentation.py +0 -27
segmentation.py DELETED
@@ -1,27 +0,0 @@
1
- import cv2
2
- import mediapipe as mp
3
- import numpy as np
4
-
5
-
6
- mp_face_mesh = mp.solutions.face_mesh
7
-
8
-
9
- def get_forehead_mask(img):
10
- with mp_face_mesh.FaceMesh(static_image_mode=True) as face_mesh:
11
- results = face_mesh.process(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
12
- mask = np.zeros(img.shape[:2], dtype=np.uint8)
13
-
14
-
15
- if results.multi_face_landmarks:
16
- for face_landmarks in results.multi_face_landmarks:
17
- points = []
18
- for i in [10, 338, 297, 332, 284, 251, 389, 356, 454]:
19
- lm = face_landmarks.landmark[i]
20
- x = int(lm.x * img.shape[1])
21
- y = int(lm.y * img.shape[0])
22
- points.append((x, y))
23
- points = np.array([points], dtype=np.int32)
24
- cv2.fillPoly(mask, points, 255)
25
-
26
-
27
- return mask