Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import face_alignment
- from face_alignment import *
- from skimage import io
- import cv2
- import os
- fa = face_alignment.FaceAlignment(
- face_alignment.LandmarksType._2D, flip_input=False, device='cpu')
- #preds = fa.get_landmarks_from_directory('./images/1/')
- def createLandmarks(name):
- input = io.imread('./images/1/' + name)
- img = cv2.cvtColor(input, cv2.COLOR_BGR2RGB)
- preds = fa.get_landmarks(img)
- if preds == None:
- return
- dot = [255, 255, 255]
- for x in preds[0]:
- # circle:
- #cv2.circle(img, (int(x[0]), int(x[1])), 1, dot, -1)
- # dot:
- img[int(x[1]), int(x[0])] = dot
- cv2.imwrite('./ready/1/' + name, img)
- for file in os.listdir("./images/1/"):
- if file.endswith(".jpg"):
- createLandmarks(file)
Add Comment
Please, Sign In to add comment