MagicWinnie

Untitled

Mar 11th, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. from imutils import face_utils
  2. import numpy as np
  3. import argparse
  4. import imutils
  5. import dlib
  6. import cv2
  7. import time
  8. from imutils.video import VideoStream
  9. detector = dlib.get_frontal_face_detector()
  10. predictor = dlib.shape_predictor('shape_predictor_68_face_landmarks.dat')
  11. vs = cv2.VideoCapture('Video Downloader Pro-1.mp4')
  12. time.sleep(2.0)
  13. while True:
  14.         ret, frame = vs.read()
  15.         #frame = imutils.resize(frame, width=400)
  16.         gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  17.         rects = detector(gray, 0)
  18.         for rect in rects:
  19.                 shape = predictor(gray, rect)
  20.                 shape = face_utils.shape_to_np(shape)
  21.                 for (x, y) in shape:
  22.                         cv2.circle(frame, (x, y), 1, (0, 0, 255), -1)
  23.         cv2.imshow("Frame", frame)
  24.         key = cv2.waitKey(1) & 0xFF
  25.         if key == ord("q"):
  26.                 break
  27. cv2.destroyAllWindows()
  28. vs.stop()
Advertisement
Add Comment
Please, Sign In to add comment