mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-08 05:51:40 -07:00
added transparent mask to draw_landmarks
This commit is contained in:
parent
5bd3f875fa
commit
9823421a44
4 changed files with 18 additions and 11 deletions
|
@ -247,7 +247,8 @@ def mirror_landmarks (landmarks, val):
|
|||
result[:,0] = val - result[:,0] - 1
|
||||
return result
|
||||
|
||||
def draw_landmarks (image, image_landmarks, color=(0,255,0)):
|
||||
def draw_landmarks (image, image_landmarks, color=(0,255,0), transparent_mask=False):
|
||||
image = image.copy()
|
||||
if len(image_landmarks) != 68:
|
||||
raise Exception('get_image_eye_mask works only with 68 landmarks')
|
||||
|
||||
|
@ -271,14 +272,20 @@ def draw_landmarks (image, image_landmarks, color=(0,255,0)):
|
|||
# jaw big circles
|
||||
for x, y in jaw:
|
||||
cv2.circle(image, (x, y), 2, color, lineType=cv2.LINE_AA)
|
||||
|
||||
def draw_rect_landmarks (image, rect, image_landmarks, face_size, face_type):
|
||||
image_utils.draw_rect (image, rect, (255,0,0), 2 )
|
||||
draw_landmarks(image, image_landmarks)
|
||||
|
||||
if transparent_mask:
|
||||
mask = get_image_hull_mask (image.shape, image_landmarks)
|
||||
image = image * (1-mask) + image * mask / 2
|
||||
return image
|
||||
|
||||
def draw_rect_landmarks (image, rect, image_landmarks, face_size, face_type, transparent_mask=False):
|
||||
image = draw_landmarks(image, image_landmarks, transparent_mask=transparent_mask)
|
||||
image_utils.draw_rect (image, rect, (255,0,0), 2 )
|
||||
|
||||
image_to_face_mat = get_transform_mat (image_landmarks, face_size, face_type)
|
||||
points = transform_points ( [ (0,0), (0,face_size-1), (face_size-1, face_size-1), (face_size-1,0) ], image_to_face_mat, True)
|
||||
image_utils.draw_polygon (image, points, (0,0,255), 2)
|
||||
return image
|
||||
|
||||
def calc_face_pitch(landmarks):
|
||||
if not isinstance(landmarks, np.ndarray):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue