Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. SITE_PACKAGES = '/Users/daniel/.virtualenvs/lesson_2/lib/python3.7/site-packages'
  2. MODEL_PATH = '/Users/daniel/PycharmProjects/lessons/lesson_2/data/shape_predictor_68_face_landmarks.dat'
  3. OP_SRC_NAME = 'videodevin1'
  4. OP_TABLE_NAME = 'table1'
  5. import sys
  6. sys.path.append(SITE_PACKAGES)
  7. import cv2
  8. import dlib
  9.  
  10. detector = dlib.get_frontal_face_detector()
  11. predictor = dlib.shape_predictor(MODEL_PATH)
  12.  
  13.  
  14. def onValueChange(channel, sampleIndex, val, prev):
  15.     tiffile = op(OP_SRC_NAME).save()
  16.     im = cv2.imread(tiffile, -1)
  17.  
  18.     grayFrame = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
  19.  
  20.     faces = detector(grayFrame)
  21.     t = op(OP_TABLE_NAME)
  22.     for face in faces:
  23.         landmarks = predictor(grayFrame, face)
  24.         for n in range(0, 68):
  25.             t[n, 0] = landmarks.part(n).x
  26.             t[n, 1] = landmarks.part(n).y
  27.  
  28.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement