在眨眼中如何识别人脸内部的眨眼

时间:2020-04-16 14:30:34

标签: flutter face-recognition blink

我正在尝试制作一个包含眨眼功能的应用程序,但是我很难找到有关眨眼的资源。是否有我可以阅读的软件包或资源?

1 个答案:

答案 0 :(得分:1)

您可以在Python中使用opencv以及其他几个库来检测眨眼。

使用视频供稿

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

变量“ ear”给出了眼睛的纵横比。现在,您比较它是否低于阈值。例如

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

有关更多详细信息,请参阅this链接。