Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Sleep Detection Alarm System Project Overview

Smart Sleep Detection Alarm System is a Java-based computer vision application that monitors a user's face through a webcam and detects possible drowsiness based on prolonged eye closure.

When the user's eyes remain closed beyond a predefined time, the system triggers an alarm to alert the user.

Note: This project detects possible drowsiness/fatigue. It is not a medical sleep diagnosis system.

Objectives Detect the user's face using a webcam. Detect and monitor the user's eyes. Identify prolonged eye closure. Detect possible drowsiness. Automatically trigger an alarm. Provide user login and registration. Store monitoring and drowsiness history in MySQL. Provide a dashboard and history report. Create a foundation for future driver-drowsiness detection. Main Features

  1. User Authentication User registration Login Logout Password handling User-specific monitoring history
  2. Face Detection

Uses OpenCV Haar Cascade to detect the user's face in real time.

  1. Eye Detection

Detects the eye region and determines whether the eyes are open or closed.

  1. Drowsiness Detection

The system measures continuous eye-closure duration.

Example:

Eyes Open ↓ Eyes Closed ↓ Start Timer ↓ Closed for 2+ seconds ↓ Drowsiness Detected ↓ Alarm 5. Alarm System

The application generates an alarm using the Java Sound API when drowsiness is detected.

  1. Monitoring

The monitoring screen displays the user's camera and detection status.

  1. History

Stores and displays previous drowsiness detection events.

  1. MySQL Database

Stores:

User information Monitoring sessions Drowsiness events Detection time Eye-closure duration Technology Stack Category Technology Programming Language Java 17 GUI JavaFX UI Design FXML, CSS Computer Vision OpenCV Database MySQL Database Connectivity JDBC Alarm Java Sound API Build Tool Maven IDE IntelliJ IDEA Version Control Git Repository GitHub Project Structure SmartSleepDetection/ │ ├── pom.xml ├── README.md │ ├── database/ │ └── smart_sleep.sql │ └── src/ ├── main/ │ ├── java/ │ │ └── com/ │ │ └── smartsleep/ │ │ ├── Main.java │ │ │ │ │ ├── alarm/ │ │ │ ├── AlarmManager.java │ │ │ └── VoiceAlert.java │ │ │ │ │ ├── controller/ │ │ │ ├── LoginController.java │ │ │ ├── RegisterController.java │ │ │ ├── DashboardController.java │ │ │ ├── MonitoringController.java │ │ │ └── HistoryController.java │ │ │ │ │ ├── database/ │ │ │ ├── DatabaseConnection.java │ │ │ ├── UserDAO.java │ │ │ ├── MonitoringDAO.java │ │ │ └── DrowsinessDAO.java │ │ │ │ │ ├── model/ │ │ │ ├── User.java │ │ │ ├── MonitoringSession.java │ │ │ └── DrowsinessLog.java │ │ │ │ │ ├── service/ │ │ │ ├── AuthenticationService.java │ │ │ ├── DrowsinessService.java │ │ │ └── ReportService.java │ │ │ │ │ ├── util/ │ │ │ ├── Constants.java │ │ │ ├── DateTimeUtil.java │ │ │ └── PasswordUtil.java │ │ │ │ │ └── vision/ │ │ ├── CameraManager.java │ │ ├── FaceDetector.java │ │ ├── EyeDetector.java │ │ ├── BlinkDetector.java │ │ └── DrowsinessDetector.java │ │ │ └── resources/ │ ├── css/ │ │ └── style.css │ │ │ ├── fxml/ │ │ ├── login.fxml │ │ ├── register.fxml │ │ ├── dashboard.fxml │ │ ├── monitoring.fxml │ │ └── history.fxml │ │ │ └── haarcascades/ │ ├── haarcascade_frontalface_default.xml │ └── haarcascade_eye.xml │ └── test/ └── java/ System Workflow User ↓ Login / Register ↓ Dashboard ↓ Start Monitoring ↓ Webcam ↓ Face Detection ↓ Eye Detection ↓ Eye Open / Closed ↓ Measure Eye Closure Duration ↓ Threshold Exceeded? ↓ YES ↓ Drowsiness Detected ↓ Alarm ↓ Store Detection History Drowsiness Threshold

The current system uses a predefined eye-closure threshold.

Example:

Eye closure < 2 seconds ↓ Possible blink

Eye closure >= 2 seconds ↓ Possible drowsiness ↓ Alarm

The threshold can be modified in:

Constants.java Database

Database name:

smart_sleep

Possible tables:

users monitoring_sessions drowsiness_logs Users

Stores user registration information.

Monitoring Sessions

Stores monitoring start time, end time and duration.

Drowsiness Logs

Stores detected drowsiness events, detection time and eye-closure duration.

Installation Requirements

Install:

JDK 17 IntelliJ IDEA Maven MySQL MySQL Workbench Git Webcam Setup

Clone or open the project in IntelliJ IDEA.

Create the MySQL database using:

database/smart_sleep.sql

Update the database credentials in:

Constants.java

Example:

public static final String DB_URL = "jdbc:mysql://localhost:3306/smart_sleep";

public static final String DB_USER = "root";

public static final String DB_PASSWORD = "your_password"; Run the Project

Open the IntelliJ terminal:

mvn clean

Then:

mvn javafx:run Future Enhancements AI/ML-based drowsiness classification Yawning detection Head-pose detection Driver drowsiness detection Voice alerts Drowsiness score Daily and weekly reports Graphical analytics Personalized drowsiness thresholds Mobile application Cloud-based monitoring Advantages Real-time monitoring Automatic drowsiness detection Uses a normal webcam Automatic alarm Stores detection history Combines Java and Computer Vision Suitable for a BCA academic project Can be extended with AI/ML Limitations Requires a working webcam. Poor lighting may affect detection. Face angle can affect detection. Glasses may affect basic eye detection. Basic Haar Cascade detection can produce false alarms. The system does not medically diagnose sleep disorders. Project Description for Resume

Smart Sleep Detection Alarm System — Developed a Java-based computer vision application using JavaFX and OpenCV to monitor facial and eye activity through a webcam, detect prolonged eye closure and possible drowsiness, trigger automatic audio alerts, and store monitoring history using MySQL.

Author

BCA Data Science Project

Project: Smart Sleep Detection Alarm System Technology: Java + JavaFX + OpenCV + MySQL + JDBC

About

Smart Sleep Detection Alarm System is a Java-based computer vision project that uses a webcam and OpenCV to detect prolonged eye closure and possible drowsiness. When drowsiness is detected, the system automatically triggers an alarm and records the detection history.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages