flutter - 如何在颤动的人脸识别中眨眼
问题描述
我正在尝试制作一个包含人脸识别内眨眼的应用程序,但我很难找到有关眨眼的资源。是否有我可以阅读的包或资源?
解决方案
您可以在 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.
有关详细信息,请参阅此 链接。