text: import config as cfg
  import dlib
  import numpy as np
  from imutils import face_utils
  from scipy.spatial import distance as dist
  
  
  
  class eye_blink_detector():
      def __init__(self):
          #load model for eye point detection
          self.predictor_eyes = dlib.shape_predictor(cfg.eye_landmarks)
  
      def eye_blink(self,gray,rect,COUNTER,TOTAL):
          (lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"]
          (rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye"]
          # determine the facial landmarks for the face region, then
          # convert the facial landmark (x, y)-coordinates to a NumPy array
          shape = self.predictor_eyes(gray, rect)
          shape = face_utils.shape_to_np(shape)
          # extract the left and right eye coordinates, then use the
          # coordinates to compute the eye aspect ratio for both eyes
          leftEye = shape[lStart:lEnd]
          rightEye = shape[rStart:rEnd]
          leftEAR = self.eye_aspect_ratio(leftEye)
          rightEAR = self.eye_aspect_ratio(rightEye)
          # average the eye aspect ratio together for both eyes
          ear = (leftEAR + rightEAR) / 2.0
          # check to see if the eye aspect ratio is below the blink
          # threshold, and if so, increment the blink frame counter
          if ear < cfg.EYE_AR_THRESH:
              COUNTER += 1
          # otherwise, the eye aspect ratio is not below the blink
          # threshold
          else:
              # if the eyes were closed for a sufficient number of
              # then increment the total number of blinks
              if COUNTER >= cfg.EYE_AR_CONSEC_FRAMES:
                  TOTAL += 1
              # reset the eye frame counter
              COUNTER = 0
          return COUNTER,TOTAL
  
      def eye_aspect_ratio(self,eye):
          # compute the euclidean distances between the two sets of
          # vertical eye landmarks (x, y)-coordinates
          A = dist.euclidean(eye[1], eye[5])
          B = dist.euclidean(eye[2], eye[4])
          # compute the euclidean distance between the horizontal
          # eye landmark (x, y)-coordinates
          C = dist.euclidean(eye[0], eye[3])
          # compute the eye aspect ratio
          ear = (A + B) / (2.0 * C)
          # return the eye aspect ratio
          return ear
  