Video control application using gaze direction detection. Fokus automatically pauses your QuickTime video when you look away from the screen.
- macOS (tested on Mac with Apple Silicon M1/M2/M3)
- Python 3.11 (important: Python 3.14 is not compatible)
- Homebrew (macOS package manager)
- QuickTime Player (pre-installed on macOS)
- Working webcam
If you don't have Python 3.11, install it with Homebrew:
brew install python@3.11Verify the installation:
python3.11 --versioncd ~/Desktop
mkdir Fokus
cd FokusPlace the main_improved.py file in this folder.
# Create the virtual environment with Python 3.11
python3.11 -m venv venv
# Activate the virtual environment
source venv/bin/activateYou should see (venv) appear at the beginning of your command line.
pip install mediapipe opencv-python- Open QuickTime Player and load a video (Cmd+O)
- Pause the video
- Activate the virtual environment (if not already done):
cd ~/Desktop/Fokus source venv/bin/activate
- Launch Fokus:
python main_improved.py
- 🟢 Look at the screen → Video plays automatically
- 🔴 Turn your head (>20°) → Video pauses
- ⎋ Press Escape → Quit the application
A "Fokus - Head Control" window opens and displays:
- Your face captured by the webcam
- The rotation angle of your head in degrees
- Current status (FOCUS ✓ or DETOURNE ✗)
In the main_improved.py file, lines 93 and 101, you can modify the detection threshold:
if abs(yaw) < 20: # Change 20 to another value- Smaller value (e.g., 15) → More sensitive, detects small movements
- Larger value (e.g., 30) → Less sensitive, requires turning your head more
The code is configured for QuickTime Player. To use another player (VLC, IINA, etc.), modify the AppleScript commands in the control_quicktime() function.
- Check camera permissions in System Preferences → Privacy & Security
- Make sure no other application is using the camera
- QuickTime Player must be open with a video loaded
- Verify that QuickTime has the necessary permissions
- Test manually:
osascript -e 'tell application "QuickTime Player" to play document 1'
- You're probably using Python 3.14 which is not compatible
- Delete the venv and recreate it with Python 3.11:
deactivate rm -rf venv python3.11 -m venv venv source venv/bin/activate pip install mediapipe opencv-python
- Make sure you have good lighting
- Position yourself facing the camera
- Adjust the sensitivity threshold (see Configuration)
- Detection library: MediaPipe Face Mesh
- Detection method: Yaw angle calculation (left/right rotation) based on facial landmarks
- Video control: AppleScript to communicate with QuickTime Player
- Cooldown: 30 frames between each command to avoid spam
To update dependencies:
source venv/bin/activate
pip install --upgrade mediapipe opencv-pythonPersonal project - Free to use
Feel free to suggest improvements or report bugs!
Developed with ❤️ to stay focused 🎯