mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-07 05:22:06 -07:00
Manual preview now draws 68-pt face landmarks
It could be difficult to tell if the point cloud was 'correct' or not when manually fixing a face detection. For 68-point face landmarks, the facial landmarks are now drawn to make it easier to tell if the face is correctly detected.
This commit is contained in:
parent
46b2aa86da
commit
c8c8e8dadc
1 changed files with 16 additions and 0 deletions
|
@ -27,6 +27,15 @@ mean_face_y = np.array([
|
||||||
|
|
||||||
landmarks_2D = np.stack( [ mean_face_x, mean_face_y ], axis=1 )
|
landmarks_2D = np.stack( [ mean_face_x, mean_face_y ], axis=1 )
|
||||||
|
|
||||||
|
# 68 point landmark definitions
|
||||||
|
landmarks_68_pt = { "mouth": (48,68),
|
||||||
|
"right_eyebrow": (17,22),
|
||||||
|
"left_eyebrow": (22,27),
|
||||||
|
"right_eye": (36,42),
|
||||||
|
"left_eye": (42,48),
|
||||||
|
"nose": (27,35),
|
||||||
|
"jaw": (0,17) }
|
||||||
|
|
||||||
def get_transform_mat (image_landmarks, output_size, face_type):
|
def get_transform_mat (image_landmarks, output_size, face_type):
|
||||||
if not isinstance(image_landmarks, np.ndarray):
|
if not isinstance(image_landmarks, np.ndarray):
|
||||||
image_landmarks = np.array (image_landmarks)
|
image_landmarks = np.array (image_landmarks)
|
||||||
|
@ -169,6 +178,13 @@ def draw_landmarks (image, image_landmarks, color):
|
||||||
cv2.circle(image, (x, y), 2, color, -1)
|
cv2.circle(image, (x, y), 2, color, -1)
|
||||||
#text_color = colorsys.hsv_to_rgb ( (i%4) * (0.25), 1.0, 1.0 )
|
#text_color = colorsys.hsv_to_rgb ( (i%4) * (0.25), 1.0, 1.0 )
|
||||||
#cv2.putText(image, str(i), (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.1,text_color,1)
|
#cv2.putText(image, str(i), (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.1,text_color,1)
|
||||||
|
if len(image_landmarks) == 68:
|
||||||
|
for feat,idx_range in landmarks_68_pt.items():
|
||||||
|
for idx in range( idx_range[0], idx_range[1] - 1 ):
|
||||||
|
pt1 = tuple(image_landmarks[idx])
|
||||||
|
pt2 = tuple(image_landmarks[idx + 1])
|
||||||
|
cv2.line( image, pt1, pt2, color )
|
||||||
|
|
||||||
|
|
||||||
def draw_rect_landmarks (image, rect, image_landmarks, face_size, face_type):
|
def draw_rect_landmarks (image, rect, image_landmarks, face_size, face_type):
|
||||||
image_utils.draw_rect (image, rect, (255,0,0), 2 )
|
image_utils.draw_rect (image, rect, (255,0,0), 2 )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue