Skip to content
Permalink
Browse files

fix get_image_hull_mask

  • Loading branch information...
iperov committed Mar 14, 2019
1 parent 9823421 commit 1beb2f07f06fa087ef2058fc452ea0a2ff339f3e
Showing with 38 additions and 4 deletions.
  1. +38 −4 facelib/LandmarksProcessor.py
@@ -159,12 +159,46 @@ def get_image_hull_mask (image_shape, image_landmarks):

hull_mask = np.zeros(image_shape[0:2]+(1,),dtype=np.float32)

cv2.fillConvexPoly( hull_mask, cv2.convexHull( np.concatenate ( (image_landmarks[0:17], image_landmarks[48:], [image_landmarks[0]], [image_landmarks[8]], [image_landmarks[16]])) ), (1,) )
cv2.fillConvexPoly( hull_mask, cv2.convexHull( np.concatenate ( (image_landmarks[27:31], [image_landmarks[33]]) ) ), (1,) )
cv2.fillConvexPoly( hull_mask, cv2.convexHull( np.concatenate ( (image_landmarks[17:27], [image_landmarks[0]], [image_landmarks[27]], [image_landmarks[16]], [image_landmarks[33]])) ), (1,) )
cv2.fillConvexPoly( hull_mask, cv2.convexHull(
np.concatenate ( (image_landmarks[0:9],
image_landmarks[17:18]))) , (1,) )

cv2.fillConvexPoly( hull_mask, cv2.convexHull(
np.concatenate ( (image_landmarks[8:17],
image_landmarks[26:27]))) , (1,) )

cv2.fillConvexPoly( hull_mask, cv2.convexHull(
np.concatenate ( (image_landmarks[17:20],
image_landmarks[8:9]))) , (1,) )

cv2.fillConvexPoly( hull_mask, cv2.convexHull(
np.concatenate ( (image_landmarks[24:27],
image_landmarks[8:9]))) , (1,) )

cv2.fillConvexPoly( hull_mask, cv2.convexHull(
np.concatenate ( (image_landmarks[19:25],
image_landmarks[8:9],
))) , (1,) )

cv2.fillConvexPoly( hull_mask, cv2.convexHull(
np.concatenate ( (image_landmarks[17:22],
image_landmarks[27:28],
image_landmarks[31:36],
image_landmarks[8:9]
))) , (1,) )

cv2.fillConvexPoly( hull_mask, cv2.convexHull(
np.concatenate ( (image_landmarks[22:27],
image_landmarks[27:28],
image_landmarks[31:36],
image_landmarks[8:9]
))) , (1,) )

#nose
cv2.fillConvexPoly( hull_mask, cv2.convexHull(image_landmarks[27:36]), (1,) )

return hull_mask

def get_image_eye_mask (image_shape, image_landmarks):
if len(image_landmarks) != 68:
raise Exception('get_image_eye_mask works only with 68 landmarks')

0 comments on commit 1beb2f0

Please sign in to comment.
You can’t perform that action at this time.