This Python project uses your webcam to detect if your eyes are closed, and triggers an action (like a click) when they are. Think of it as a "blink to click" controller — useful for accessibility or creative controls in games, automation, etc.
- Detects your face and eyes using
dlib’s 68 facial landmarks - Calculates the Eye Aspect Ratio (EAR) to determine eye closure
- When the EAR drops below a threshold (e.g., 0.234), the script:
- Triggers a mouse click using
pyautogui - Prints "Success" in the terminal
- Triggers a mouse click using
Make sure you have the following Python packages installed:
pip install opencv-python dlib scipy pyautoguiYou also need the facial landmarks predictor file:
Download this file:
shape_predictor_68_face_landmarks.dat
Place it in the same directory as your Python script.
- Clone this repository or copy the script into your project folder
- Install the dependencies listed above
- Make sure your webcam is working
- Run the script:
python eye_click.py- Blink your eyes and it will work
You can modify the behavior of jump() to do whatever you want:
def jump():
pyautogui.mouseDown()
time.sleep(0.01)
print("Click!")
pyautogui.mouseUp()This is a basic eye closure trigger and not a medically certified drowsiness detector.
Use responsibly and tweak the EAR threshold to suit your face & lighting conditions.