#Initializing dlib's HOG based facial landmark predictor. print("[INFO] loading facial landmark predictor from dlib's library.") detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor(args["shape-predictor"]) (lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left eye"] (rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right eye"] print("[INFO] loading the webcam ...") vs = VideoStream(src=0).start() time.sleep(1.0) while True: #grab the FRAME from the threaded video stream file and resize it, and onvert it into grayscale. frame = vs.fread() frame = imutils.resize(frame, width = 550) gray = cv2.cvtColor(frame, cv2.COLORBGR2GRAY) #detect faces in the grayscale frame. rects = detector(gray, 0) for rect in rects: shape = predictor(gray, rect) shape = face_utils.shape_to_np(shape) #extract the left and the right eye coordinates, then calculating Eye Aspect Ratio leftEye = shape[lStart:lEnd] rightEye = shape[rStart:rEnd] leftEAR = eye_aspect_ratio(leftEye) rightEAR = eye_aspect_ratio(rightEye)