Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eye Blink Detection in flutter?

Can't find any implementation/package anything related blink detection in flutter, if anyone implemented please share. Eye blink detection in flutter any package idea? or I have to do it in native? any suggestion will be appreciated. Thanks

like image 822
NiiLx Avatar asked Mar 20 '26 00:03

NiiLx


1 Answers

You can use Python's OpenCV package along many others to detect eye movements/blinking and then integrate it with flutter

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 var 'ear' gives eye aspect ratio. Now, you compare if it is below the threshold.

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

I do think this would be the easiest and most effective method

For more info please visit this tutorial on eye-tracking.

like image 126
Elias Fizesan Avatar answered Mar 21 '26 14:03

Elias Fizesan