A state of the art face detection system, that identifies and extracts the facial features from live webcam feed, to detect whether the driver is getting tired or not.
Research paper for the app : Click here
from imutils.video import VideoStream
import numpy as np
import argparse
import imutils
import time
import cv2
from scipy.spatial import distance as dist
from imutils import face_utils
import dlib
import playsound
import os
from threading import Thread
Requirements.txt
CMake
opencv-python
imutils
dlib
scipy
playsound
numpy==1.21.5
-
Install Python Click here
-
Install Git Click here
-
Install Anaconda Click here
-
Clone this repository
git clone https://github.com/rkf2778/Driver-Fatigue-Detection-with-OpenCV-and-Deep-Learning/tree/master
cd Driver-Fatigue-Detection-with-OpenCV-and-Deep-Learning
- Create an environment
conda create --name facedetect
conda activate facedetect
- Install the modules
pip install -r requirements.txt
If it causes error, then do the following :
-
If facing issues with dlib, do either of the following
- Install CMake :
pip install CMake
- Visit here and install Dlib
- Or else, try
conda install conda-forge::dlib
- Install CMake :
-
Then install the following manually
pip install opencv-python numpy scipy playsound
NOTE :
If you have more than one webcam, then you might need to change values for the following code inside detect_faces_video.py
file to 0 or 1
vs = cv2.VideoCapture(0) // For Inbuilt Camera
vs = cv2.VideoCapture(1) // For External Camera
Also, you can control the threshold values in detect_faces_video.py
file to control the threshold before alarm is activated
EYE_AR_THRESH = 0.26
EYE_AR_CONSEC_FRAMES = 10
MOUTH_AR_THRESH = 0.4
SHOW_POINTS_FACE = True
SHOW_CONVEX_HULL_FACE = True
SHOW_INFO = True
6 To run the app, enter the following code
python detect_faces_video.py --prototxt deploy.prototxt.txt --model res10_300x300_ssd_iter_140000.caffemodel --alarm alarm.wav
Check out this website