Git Product home page Git Product logo

drowsiness_alert_flask_app's Introduction

DROWSINESS ALERT SYSTEM

This is a drowsiness alert system in Python3 using OpenCV and Dlib libraries that plays an alarm when the user becomes drowsy. The system is implemented using the Flask microframework.

Reference: Real-Time Eye Blink Detection using Facial Landmarks, Tereza Soukupova and Jan Cech,(2016)

Dependencies :

  1. opencv
  2. scipy
  3. dlib
  4. sounddevice
  5. soundfile
  6. numpy
  7. Pre-trained Shape Predictor Dlib Model - shape_predictor_68_face_landmarks.dat (https://github.com/AKSHAYUBHAT/TensorFace/blob/master/openface/models/dlib/shape_predictor_68_face_landmarks.dat)

We detect facial features with OpenCV and Dlib Play sound in python3 using soundfile and sounddevice HTML and CSS are used to Create a Flask application.

Working :

● We utilised a pre trained frontal face detector from Dlib’s library which is based on a modification to the Histogram of Oriented Gradients in combination with Linear SVM for classification.

● The pre-trained facial landmark detector inside the dlib library is used to estimate the location of 68 (x, y)-coordinates that map to facial structures on the face. The 68 landmark output is shown in the figure below.

Alt

A shape detector is required as well, which is provided in the repo. Referring to the paper Real-Time Eye Blink Detection using Facial Landmarks, Tereza Soukupova and Jan Cech,(2016), Eye Aspect Ratio(EAR) is given by the following formula :

The EAR ratio is calculated for both the eyes in each frame. If it falls below a certain threshold value, the user’s eyes are detected as ”drowsy”. If the user’s eyes are closed for a certain number of frames, a loud alarm is played.

Alt

where, p1,...,p6 are as shown below :

Alt

The coordinates for each landmark point can be found using the part number as listed in the Facial Landmarks picture above, which is then used to compute the Eye Aspect Ratio.

The authors of the above referred paper suggest to take the average of EAR of both eyes. A threshold is set for the EAR below which the driver is said to be drowsy. If the driver is 'drowsy' for 30 consecutive frames, a loud alarm sound is played in order to wake the driver up.

Usage

To run the program, simply type the following command :

python3 app.py

The application will greet you at : http://localhost:5000/

Applications

Can be implemented on a microcontroller(after optimizing the code) and used in cars to sound an alarm if the driver is found to be drowsy.

drowsiness_alert_flask_app's People

Contributors

swathika1 avatar viola-star avatar harinimurali06 avatar

Stargazers

 avatar Madhuvanthi V avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.