flutterface-recognitionblink

how to do eye blinking inside face recognition in flutter


I am trying to make an app that contain eye blinking inside face recognition, but difficult to me to find resources about eye blinking. are there package or resources that I can read about it?


Solution

  • You can use opencv in Python along with few other libs to detect the eye blinks.

    Once you consume the video feed,

    EYE_AR_THRESH = 0.3   
    
    for rect in rects:
        # determine the facial landmarks for the face region, then
        # convert the facial landmark (x, y)-coordinates to a NumPy
        # array
        shape = predictor(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]
        # EAR = eye aspect ratio
        leftEAR = eye_aspect_ratio(leftEye)                     # important line
        rightEAR = eye_aspect_ratio(rightEye)                   # important line
        # average the eye aspect ratio together for both eyes
        ear = (leftEAR + rightEAR) / 2.0
    

    The variable 'ear' gives eye aspect ratio. Now, you compare if it is below threshold. e.g.

    if ear < EYE_AR_THRESH:
        # eye is blinked. continue with your business logic.
    

    For more details, please refer this link.