Drowsy Driver Detection Using Raspberry Pi and Pi cam
This code can be run on laptop webcam , but It is intended to be used on Respberry Pi with Picam Module.
numpy
dlib
imultis(to test it in pc)
OpenCv ( a tedious task to install it on rpi)
picamera
Rpi.GPIO if you need a alarm/buzzer
-
The drowsiness detector algorithm:
-
Calculating Eyes Aspect Ratios
-
Detecting Drowsiness Details
- After getting EAR
if ear < EYE_AR_THRESH: COUNTER += 1 if COUNTER >= EYE_AR_CONSEC_FRAMES: # if the alarm is not on, turn it on if not ALARM_ON: ALARM_ON = True
-
RESULT
python pi_detect_drowsiness.py --cascade haarcascade_frontalface_default.xml --shape-predictor shape_predictor_68_face_landmarks.dat --alarm 1