This is a locally-run, Python CV-based application that detects if you're sleeping using face detection and eye aspect ratio (EAR) calculations, and wakes you up if it does via a blaring alarm. This application is ideally designed to be run in the background so you may catch yourself falling asleep and wake right back up after you've napped off.
Third year tends to get pretty tiring, and from that tiredness, I tend to doze off. A lot (I really need proper rest lmao). The work is demanding, and I can't afford to doze off on the job as easily as I want to. I have to find ways to keep myself awake just for a little longer, and that's where the idea for this app came in:.
As mentioned, this Python-based program uses computer vision and a lot of other libraries in order to detect my face, the state of my eyes, and blare out an alarm. Specifically, this program was made with the following:
- Python: Serves as the overall backend of the code, which handles ALL the logic performed within the application.
- OpenCV: Integrates the Computer Vision aspect of the application, using the Haar Cascades library for Face Detection and EAR Calculation for Eye Status
- MediaPipe: Used for processing of various media, in this case: video, and running other commands from that processed data
- TKinter: Creates the overall minimalistic look and style of the application
- PyGame and Audacity: Used for the initial amplification of audio (in Audacity), and actually playing it when certain scripts are ran.
- PyInstaller: Converts the entire Python project into an exe file for you to use.
You can actually run your own version, but since .exe file is so big, it's not here. Additionally, there are a few steps to follow if you REALLY wanna go ahead and execute it. Here's how to create it and have your own version running:
Run the following command in your terminal (make sure you're in the project directory):
```bash python -m PyInstaller --onefile --windowed --name "SleeperBeeper" --hidden-import=cv2 --hidden-import=numpy --hidden-import=mediapipe --collect-all mediapipe --add-data "Alarm.mp3;." --add-data "face_landmarker.task;." --add-data "haarcascade_frontalface_default.xml;." SleeperBeeper.py ```Note: This process may take a few minutes as PyInstaller bundles all dependencies into a single executable.
Once the build completes, navigate to the dist folder in your project directory:
Double-click SleeperBeeper.exe to launch the application.
If you don't want to build an executable, you can run the program directly:
```bash python SleeperBeeper.py ```- Camera not opening? Make sure no other application is using your webcam.
- PyInstaller not recognized? Use
python -m PyInstallerinstead of justpyinstaller. - Missing modules? Double-check that all dependencies are installed with pip.


