Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from imutils import face_utils
- import numpy as np
- import argparse
- import imutils
- import dlib
- import cv2
- import math
- def rass(x1,y1,x2,y2):
- return math.sqrt((x2-x1)**2+(y2-y1)**2)
- #-------------------------------------
- fac=[]
- inp=list(map(int,input().split(' ')))
- detector = dlib.get_frontal_face_detector()
- predictor = dlib.shape_predictor(r'C:\Users\magic\Documents\facial-landmarks\facial-landmarks\shape_predictor_68_face_landmarks.dat')
- for photo in inp:
- image = cv2.imread('faces/'+str(photo)+'.jpg')
- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
- rects = detector(gray, 1)
- for (i, rect) in enumerate(rects):
- shape = predictor(gray, rect)
- shape = face_utils.shape_to_np(shape)
- #------------------------------------------------
- one=rass(shape[37][0],shape[37][1],shape[41][0],shape[41][1])
- two=rass(shape[38][0],shape[38][1],shape[40][0],shape[40][1])
- three=rass(shape[43][0],shape[43][1],shape[47][0],shape[47][1])
- four=rass(shape[44][0],shape[44][1],shape[46][0],shape[46][1])
- usras=(one+two+three+four)/4
- last=rass(shape[27][0],shape[27][1],shape[8][0],shape[8][1])
- res=usras/last
- fac.append(res)
- print(inp[fac.index(max(fac))],inp[fac.index(min(fac))])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement