提交 15ab2fae 编写于 作者: A Aref Ariyapour

Fix error caused by keyboard module in blink detection example

Using the keyboard module in linux requires root permission and if virtual envs are used to run the script, it will produce the following error:

ImportError(You must be root to use this library on linux.)

To solve this, use OpenCV waitKey() functionality.
上级 dd9d080c
......@@ -15,7 +15,6 @@ import face_recognition
import cv2
import time
from scipy.spatial import distance as dist
import keyboard as kb
EYES_CLOSED_SECONDS = 5
......@@ -74,8 +73,9 @@ def main():
while (asleep): #continue this loop until they wake up and acknowledge music
print("EYES CLOSED")
if (kb.is_pressed('space')):
if cv2.waitKey(1) == 32: #Wait for space key
asleep = False
print("EYES OPENED")
closed_count = 0
process = not process
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册