import cv2
import numpy as np
import dlib
from imutils import face_utils
import time
import os
from PIL import Image
cap = cv2.VideoCapture(0)
predictor_path = 'lib/shape_predictor_81_face_landmarks.dat'
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
while True:
check, frame = cap.read()
print(check) #prints true as long as the webcam is running
print(frame) #prints matrix values of each framecd
cv2.imwrite(filename='result/saved_img.jpg', img=frame)
img_new = cv2.imread('result/saved_img.jpg')
img_gray = cv2.cvtColor(img_new, cv2.COLOR_BGR2GRAY)
mask = np.zeros_like(img_gray)
# Face 1
faces = detector(img_gray)
for face in faces:
landmarks = predictor(img_gray, face)
landmarks_points = []
for n in range(0, 81):
x = landmarks.part(n).x
y = landmarks.part(n).y
landmarks_points.append((x, y))
#cv2.circle(img_new, (x, y), 2, (0,0,255), -1)
cv2.imshow("open cam", frame)