sentero-esp12

Untitled

Jun 7th, 2021 (edited)
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import face_alignment
  2. from face_alignment import *
  3. from skimage import io
  4. import cv2
  5. import os
  6.  
  7. fa = face_alignment.FaceAlignment(
  8.     face_alignment.LandmarksType._2D, flip_input=False, device='cpu')
  9.  
  10. #preds = fa.get_landmarks_from_directory('./images/1/')
  11.  
  12.  
  13. def createLandmarks(name):
  14.     input = io.imread('./images/1/' + name)
  15.     img = cv2.cvtColor(input, cv2.COLOR_BGR2RGB)
  16.     preds = fa.get_landmarks(img)
  17.     if preds == None:
  18.         return
  19.     dot = [255, 255, 255]
  20.  
  21.     for x in preds[0]:
  22.         # circle:
  23.         #cv2.circle(img, (int(x[0]), int(x[1])), 1, dot, -1)
  24.         # dot:
  25.         img[int(x[1]), int(x[0])] = dot
  26.  
  27.     cv2.imwrite('./ready/1/' + name, img)
  28.  
  29.  
  30. for file in os.listdir("./images/1/"):
  31.     if file.endswith(".jpg"):
  32.         createLandmarks(file)
Add Comment
Please, Sign In to add comment