This can be used by riders who tend to drive for a longer period of time that may lead to accidents. This code can detect your eyes and alert when the user is drowsy. There's a minimum amount of time for which one can keep his/her eyes shut. If that time is exceeded an alert will start.
Each eye is represented by 6 (x, y)-coordinates, starting at the left-corner of the eye (as if you were looking at the person), and then working clockwise around the eye:
Above image shows a visualization of eye landmarks when then the eye is open.
Above image shows eye landmarks when the eye is closed.
It checks 40 consecutive frames and if the Eye Aspect ratio is lesst than 0.25, Alert is generated.
To find the Eye Aspect Ratio(EAR), we have a relationship between EAR and the 6 coordinates mentioned above. It is given be:-
Below image shows a plot between Eye Aspect Ratio and Time:-