Skip to content

Latest commit

 

History

History
240 lines (166 loc) · 18.6 KB

README.md

File metadata and controls

240 lines (166 loc) · 18.6 KB

Contributors Forks Stargazers Issues MIT License LinkedIn

Logo

EAR Fatigue Detection

Implementation of a system to detect fatigue using EAR (Eye Aspect Ratio).
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

Fatigue is a common problem among students, especially in long and intensive learning sessions. It can affect their performance, concentration, and well-being. Therefore, it is important to monitor and prevent fatigue in the classroom. In this project, we propose a system that can detect fatigue among students using cameras and a metric called eye aspect ratio (EAR). EAR is a measure of eye openness, calculated from the positions of six facial landmarks around the eye. A low EAR indicates that the eye is closed, while a high EAR indicates that the eye is open. By tracking the EAR values over time, we can determine the duration of eye closure, which is an indicator of fatigue. We aim to set a minimum threshold for EAR and alert the teacher or the supervisor when the fatigue is detected for a prolonged period. This system can help to improve the safety and the quality of learning in the classroom.

EAR Fatigue Detection

To implement this system, we will follow the steps outlined in the web page context. First, we will extract the images from a video of a learning session. Then, we will convert the images to gray scale and apply some noise removal and quality enhancement techniques. Next, we will use edge detection methods such as Canny or Sobel to find the contours of the eyes. After that, we will apply some morphological operations to refine the contours and segment the eyes. Then, we will use a facial landmark detector to locate the six points of interest (p1, …, p6) around each eye. The EAR is calculated from the formula:

$$ EAR = \frac{||p2 - p6|| + ||p3 - p5||}{2 ||p1 - p4||} $$

where ∣∣⋅∣∣ denotes the Euclidean distance between two points. At each time instant t (e.g., t = 10s), we will compute the EAR and save it in a CSV file3. Finally, we will analyze the EAR data to detect the periods of prolonged fatigue. We will define some fatigue thresholds based on the EAR values and set up an alert mechanism to signal the moments when the fatigue is detected for a long time. This alert can be a visual or auditory notification for the teacher or the supervisor, so that they can take appropriate actions to ensure the safety and well-being of the students.

EAR Fatigue Detection

Video Demonstration

https://youtu.be/qOPrmq3pk9E

Result Chart

Result Chart

(back to top)

Built With

  • Python
  • Dlib
  • OpenCV

(back to top)

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

You need to have ffmpeg installed on your system, you can download it from the official website: https://www.ffmpeg.org/download.html

  • For linux:
apt-get -y update && apt-get -y install ffmpeg
pip3 install --upgrade pip setuptools
pip3 install ffmpeg-python
  • for Windows
  • Install FFMPEG from here. Make sure to add it to system path. You can refer to this awesome tutorial for downloading and installing ffmpeg on windows youtube-tutorial.

Installation

1. Clone the repo

git clone https://github.com/Aeidle/EAR-Fatigue-Detection.git

2. Create a virtual environnement.

# In windows
python -m venv venv
venv\Scripts\activate
# In linux
python -m venv venv
source venv/bin/activate

Or even better use anaconda

conda create --name venv python=3.9
conda activate venv

3. Install the dependencies using pip :

pip  install dlib_installation/dlib-19.22.99-cp39-cp39-win_amd64.whl
pip install -r requirements.txt

(back to top)

Usage

To run the application, you can simply execute the main file:

  • using jupyter notebook (from video file)

just open main.ipynb and execute all the cells. make sure to use the correct path for your video cap = cv2.VideoCapture("videos/video3.MOV").

  • using python and CLI (from live camera)
python app.py

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Adil Alami - @MeAeidle - aeidle.me@gmail.com

Project Link: https://github.com/Aeidle/Fatigue-Detection

LinkedIn: https://www.linkedin.com/in/adil-alami/

(back to top)

Acknowledgments

(back to top)