Skip to content

Repository files navigation

Sleeper-Beeper

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.
image image image
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:.
image
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:

Step 1: Clone the Repository

```bash git clone https://github.com/SuillyCoder/SleeperBeeper.git cd SleeperBeeper ```

Step 2: Install Required Dependencies

```bash pip install opencv-python mediapipe pygame-ce scipy pyinstaller --break-system-packages ```

Step 3: Build the Executable

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.

Step 4: Locate Your Executable

Once the build completes, navigate to the dist folder in your project directory:

image

Step 5: Run SleeperBeeper! 🎉

Double-click SleeperBeeper.exe to launch the application.

image

🐍 Alternative: Run Directly with Python

If you don't want to build an executable, you can run the program directly:

```bash python SleeperBeeper.py ```

⚠️ Troubleshooting

  • Camera not opening? Make sure no other application is using your webcam.
  • PyInstaller not recognized? Use python -m PyInstaller instead of just pyinstaller.
  • Missing modules? Double-check that all dependencies are installed with pip.

About

This is an application that detects if you're sleeping and wakes you up. This project is Python-based: using OpenCV and TKinter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages