Skip to content

A computer vision system made with the help of opencv that can automatically detect driver drowsiness in a real-time video stream and then play an alarm if the driver appears to be drowsy.

License

Notifications You must be signed in to change notification settings

DCU-Solar-Racing/Fatigue-Detection-System

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fatigue(Drowsiness) Detection using OpenCV

Applications

This can be used by riders who tends to drive the vehicle for a longer period of time that may lead to accidents

Code Requirements

The example code is in Python (version 2.7 or higher will work).

Dependencies

 1)import cv2
 2)import immutils
 3)import dlib
 4)import scipy
 5)import playsound
 6)import queue
 7)import time
 8)import sys

Description

A computer vision system made with the help of opencv that can automatically detect driver drowsiness in a real-time video stream and then play an alarm if the driver appears to be drowsy.

Algorithm

● 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. However, we utilised the 70 landmark  model.

● We then calculate the aspect ratio to check whether eyes are opened or closed.

● The eye is open if Eye Aspect ratio is greater than threshold. (Around 0.3)

● A blink is supposed to last 200-300 milliseconds.

● A drowsy blink would last for  800-900 ms.

Execute the code

To run the code, follow these steps:

1. Create a Virtual Environment

First, create a virtual environment to isolate your dependencies:

python3 -m venv venv

2. Activate the Virtual Environment

Next, activate the virtual environment. For Linux or macOS, use:

source venv/bin/activate

Note: On Windows, the command is slightly different

.\venv\Scripts\activate

or

Git Bash

source venv/Scripts/activate

3. Install the requirements

pip install -r requirements.txt

4. Run the code

python3 blinkDetect.py

About

A computer vision system made with the help of opencv that can automatically detect driver drowsiness in a real-time video stream and then play an alarm if the driver appears to be drowsy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%