Eye Reader PDF is a Python application that allows you to read PDF books using eye tracking. By using your webcam, the program detects eye movement and scrolls the PDF vertically based on where your eyes are looking. You can also pause scrolling by closing your eyes.
Here’s how Eye Reader PDF works in real time:
- Eye-tracking-based PDF scrolling using your webcam.
- Face and iris detection using MediaPipe Face Mesh.
- Eye closure detection to pause scrolling.
- Overlay of a small webcam view in the top-left corner of the PDF window.
- Works with multi-page PDFs, automatically stacking all pages vertically.
- Adjustable scroll speed.
- Python 3.8+
- OpenCV (cv2)
- MediaPipe (mediapipe)
- PyMuPDF (fitz)
- Pillow (PIL)
- NumPy (numpy)
Install the dependencies using pip:
pip install opencv-python mediapipe PyMuPDF Pillow numpyRun the script from the command line with a PDF file as an argument:
python eyereaderpdf.py your_book.pdfKeys:
- Escape (Esc) key: Exit the program.
-
PDF Loading
- The script opens the PDF using PyMuPDF and converts each page into an image.
- All pages are stacked vertically into one large image.
-
Eye Tracking
- The webcam feed is processed using MediaPipe Face Mesh to detect face landmarks and irises.
- The vertical position of the irises relative to a neutral position determines scrolling.
-
Pause Functionality
- If eyes are closed, scrolling is paused automatically.
-
Display
- The program shows a window of size 800×600 pixels showing the relevant portion of the PDF.
- The webcam feed is overlaid in the top-left corner for reference.
scroll_multiplier: Adjust this value to change the scroll sensitivity. Default is 250.window_wandwindow_h: Dimensions of the display window. Default is 800×600.
- Uses landmarks
468and473for iris center tracking, and145/159for eye-closure detection. - Works best in good lighting and with the face centered in the camera frame.
- Large PDFs may consume significant RAM since all pages are stacked. You can lower the resolution by using:
page.get_pixmap(matrix=fitz.Matrix(0.5, 0.5))When running, a window titled “Eye Reader PDF Mode” will appear showing:
- The current visible portion of the PDF.
- A live webcam thumbnail in the top-left corner.
- Smooth vertical scrolling following your gaze.
