Model 1 : Pseudo Code - reyanshsolis/safety_driving_assist GitHub Wiki
MODEL 1 :
Pseudo Code :
Attention Score determining Algorithm (assuming 30fps):
Assign Initial Positive Attention Max. Score : 80000
Define Warning Level : 8000
Define AutoBrake Level : 4000
checkWarning :
if Attention Score < 8000
Display WARNING
if Attention Score < 4000
Take Control and Slow Down Vehicle
Eyes Aspect Ratio is Configured in first 100 frames according to Driver's Eyes
agvEAR is set as the average of EAR over the initial 100 frames.
If Yawn and Blink is not detected in a Frame
Attention Score += 60
If Blink is Detected
Attention Score -= 20 x Frame Counter
If Yawn is Detected in a frame
Attention Score -= 2 x Frame Counter for Yawn
checkWarning()
_______________________________________________________
_______________________________________________________
Code Flow ->
read frame from camera
convert into grayscale
identify face landmark using dlib
avgEAR is configured according to Drivers's eyes
yawn detection:
distance between lips > yawning threshold
Frame Counter (with Yawn Detected) ++
if Yawning in Continuos Number of Frames > Threshold
Attention Score -=2x Frame Counter
checkWarning // check warning status after each score update
If Yawn and Blink is not detected in a Frame
Attention Score += 60 (if Attention Score < Fixed Maximum Score)
checkWarning // check warning status after each score update
Eye Blinking detection:
Using PERCLOS
Eyes aspect ratio < Average aspect ratio (parameter)
Blink is detected
if Bink is detected continuously for Threshold no. of frames
Drowsiness Detected
Attention Score -=20 x Frame Counter
checkWarning // check warning status after each score update