Real-Time Smart Driver Sleepiness Detection by Eye Aspect Ratio Using Computer Vision
Real-Time Smart Driver Sleepiness Detection by Eye Aspect Ratio Using Computer Vision
Simon Chong Kai Yuen1, Noor Hidayah Zakaria1, Goh Eg Su1, Rohayanti Hassan1, Shahreen Kasim2,
Tole Sutikno3,4
1
Faculty of Computing, Universiti Teknologi Malaysia, Johor Bahru, 81310, Johor, Malaysia
2
Soft Computing and Data Mining Centre, Faculty of Computer Science and Information Technology, Universiti Tun Hussein Onn
Malaysia, Parit Raja, Batu Pahat, 86400, Johor, Malaysia
3
Master Program of Electrical Engineering, Faculty of Industrial Technology, Universitas Ahmad Dahlan, Yogyakarta, Indonesia
4
Embedded Systems and Power Electronics Research Group, Yogyakarta, Indonesia
Corresponding Author:
Noor Hidayah Binti Zakaria
Faculty of Computing
Universiti Teknologi Malaysia
Johor Bahru, 81310, Johor, Malaysia
Email: noorhidayah.z@[Link]
1. INTRODUCTION
Sleepiness is one of the primary causes of road accidents, accounting for 21% [1] of car crashes in 2015.
Road accidents may be caused by several factors, such as being drunk, reckless driving, speeding, distraction, a
low lighting environment, and so on [2]. There are several methods to avoid or prevent this from happening with
the aid of technology. For example, eyelid size detection, the number of yawnings, the number of eye blinks, and
so on. Besides, yawning is one of the symptoms of sleepiness. It is possible to detect the number of yawnings and
blinks to determine if someone is feeling sleepy. A study found that aged subjects yawn less frequently than young
adults, particularly during morning and mid-afternoon hours [3].
The simplest way to determine if the driver is feeling sleepy is to detect the eyelid size by reading the
eye aspect ratio, also known as EAR, in real-time with a camera. However, different people will have different
eyelid sizes, especially among different age groups [4]. Therefore, this study is to determine the optimal eye aspect
ratio for the majority of users with a developed prototype. The prototype was developed with a microcomputer (a
Raspberry Pi) attached to a night vision camera as its input and connected to a speaker as its output. When a driver
closes their eye for approximately one second, the prototype assumes the driver is asleep and in a dangerous
situation and plays an alarm sound accordingly to seek the attention of the driver. This invention is to prevent the
driver from losing their eyesight on the road and falling asleep without awareness while driving.
OpenCV (Open-Source Computer Vision), an efficient open-source computer vision library [5], [6], and
BSD (Berkeley Software Distribution)—licensed software [6], [7], were utilized in the prototype to achieve the
research objectives. OpenCV allowed the computer to “see” and analyze the real-world environment by
mimicking the human eye [8]. The main feature of the prototype is to read the eyelid size of the driver by obtaining
and calculating the EAR. In this study, there were two experiments carried out to determine the optimal EAR
threshold for most of the users and evaluate the sensitivity of the optimal EAR threshold. The rest of the paper
will be discussed as follows: Previous works and technologies used were reviewed in Section 2.0. Section 3.0
explained the methodology of the prototype and how the experiment was being conducted. Section 4 explained
and discussed the results of the experiments.
2. PREVIOUS WORKS
The previous study [9] proposes an image detection drowsiness system to detect the state of a car
driver using the Eye Aspect Ratio (EAR) technique. The system is equipped with a Pi camera, a Raspberry Pi
4, and a GPS module to detect and analyze the state of eye closure in real-time. The system is able to recognize
whether the driver is drowsy or not with an accuracy of 90% under various conditions such as wearing
spectacles, dim light, and microsleep.
Another study [10] discusses detecting driver drowsiness based on adaptive thresholds using EAR
and MAR. The system detects the face and determines the facial landmarks by which it can compute EAR and
MAR to detect driver drowsiness based on an adaptive threshold. The system also uses head pose estimation
to check the attention of the driver’s head with respect to the road. When the system detects that the driver is
drowsy, it raises an alarm.
Chandiwala and Agarwal [11] proposed a system that can detect driver drowsiness in real time and
issue a timely warning. The method is non-invasive and uses the Eye Aspect Ratio (EAR) and Mouth Aspect
Ratio (MAR) to quantify drowsiness by locating, monitoring, and analyzing both the eyes and mouth, even in
the dark. Comparing the real-time EAR to the initial EAR of the drive and the MAR to a threshold of 20. The
system notifies the user via text and audio alerts. A smart alarm system that can be deactivated by detecting a
hand gesture is also proposed. To test the system, data is collected in real-time from the user. This system
accurately predicted nine out of ten cases in both dark and light conditions, with various facial features,
including glasses.
The other study [12] proposed that, utilizing image processing techniques, the system captures video
and identifies the driver's face in every frame. The system is able to detect facial landmarks, computes Eye
Aspect Ratio (EAR) and Eye Closure Ratio (ECR), and uses adaptive thresholding to detect driver drowsiness.
Using machine learning algorithms, the effectiveness of the proposed method has been evaluated. Using a
random forest classifier, empirical results demonstrate that the proposed model can achieve an accuracy of
84%.
Additionally, this study [13] presents a method for detecting eye blinks in a series of real-time videos
captured by a car dashboard camera. The suggested technique determines the facial landmark positions for
each video frame and then extracts the vertical distance between the eyelids from the facial landmark positions.
The algorithm that has been proposed estimates the facial landmark positions, extracts a single scalar quantity
by making use of Eye Aspect Ratio (EAR), and identifies the eye closeness in each frame. In the end, blinks
are recognized by employing the modified EAR threshold value in conjunction with a pattern of EAR values
in a relatively short period of time. Experimental evidence indicates that the greater the EAR threshold, the
worse the AUC’s accuracy and performance. Further, 0.18 was determined to be the optimum EAR threshold
in their research.
Indonesian J Elec Eng & Comp Sci, Vol. 34, No. 1, April 2024: 677-686
Indonesian J Elec Eng & Comp Sci ISSN: 2502-4752 679
(P2−P6)+(𝑃3−𝑃5)
EAR = (2)
2 (𝑃1−𝑃4)
Real-time smart driver sleepiness detection by eye aspect ratio using computer … (Simon Chong Kai Yuen)
680 ISSN: 2502-4752
(a) (b)
Figure 3. Haar Cascade face recognition of (a) process of face recognition and (b) the kernel of Haar Cascade
3. METHOD
The methodology of development is shown in Figure 4, since all the functions or features have to be
completed before we start testing. Communication or user involvement is unnecessary in this prototype
development process. The current development status and progress in each phase of the research methodology
are explained further in the following sub-sections. Also, two experiments have been carried out to determine
the optimal EAR threshold for different age categories, with and without a spectacle, and in dark and bright
lighting environments.
Indonesian J Elec Eng & Comp Sci, Vol. 34, No. 1, April 2024: 677-686
Indonesian J Elec Eng & Comp Sci ISSN: 2502-4752 681
A straightforward user interface was developed in order to facilitate the process of conducting our
experiments and ensure that we have accurate records, as shown in Figure 6. On the user interface, a number
of important and helpful pieces of information were displayed. Figure 6(a) shows that the eye is still open, and
Figure 6(b) shows sleepiness detected. These included the EAR value, the number of times the eye was closed,
the frame rate, and a warning message that appeared when the user was detected to be sleepy.
(a)
(b)
Figure 6. The user interface of (a) open eyes and
Figure 5. Workflow of the developed prototype (b) closed eyes
Real-time smart driver sleepiness detection by eye aspect ratio using computer … (Simon Chong Kai Yuen)
682 ISSN: 2502-4752
(a) (b)
Indonesian J Elec Eng & Comp Sci, Vol. 34, No. 1, April 2024: 677-686
Indonesian J Elec Eng & Comp Sci ISSN: 2502-4752 683
Figure 11 explains the performance of the 0.225 EAR threshold in the confusion matrix. The true
positive and true negative matrix had 100% precision with the selected EAR threshold in the second
experiment. Therefore, 0.225 is the optimal threshold based on this research.
(a) (b)
Figure 8. Average time taken for age 20-30 category, (a) dark environment, and (b). bright environment
(a) (b)
Figure 9. Average time taken for age 31-40 category, (a) dark environment, and (b). bright environment
(a) (b)
Figure 10. Average time taken for age 41-50 category, (a) dark environment, and (b). bright environment
Real-time smart driver sleepiness detection by eye aspect ratio using computer … (Simon Chong Kai Yuen)
684 ISSN: 2502-4752
True Class
Positive Negative
Positi
Predicted Class
ve 7 0
Negati
ve
0 7
5. CONCLUSION
The optimal EAR threshold was determined to be 0.225 after conducting two experiments: one to
identify the optimal threshold and another to assess its sensitivity. This threshold appears to be effective across
various age groups and lighting conditions. The second experiment yielded a favorable result of 100% with
0.225, indicating that the research prototype functioned logically without any detection errors or faults among
the 7 participants. The prototype performed effectively in low-light conditions due to the inclusion of two
infrared lights integrated into the camera, eliminating the need for wearing glasses. Additionally, the tested
prototype has limitations, such as the inability to detect faces when a user is wearing a mask due to the
requirement for the prototype algorithm to capture the human face before obtaining their eye information.
Wearing thick glasses can impact the accuracy of the tested prototype or lead to detection errors. Position the
prototype being tested in front of the driver in a way that does not block their vision. It is crucial because the
prototype depends on detecting both the left and right eyes. Users need to customize the prototype's height to
align with their eye level and adjust its angle horizontally for optimal performance. There are limited
prospective studies that can be conducted in the future. The accuracy of the prototype determines the ideal
mouth size for yawning. The ideal frequency of yawning for various age groups of participants. Additionally,
researching distraction is also feasible. For instance, using a phone, moving one's head, or observing the
surroundings while the vehicle is in motion. These secondary tasks while driving are also contributing factors
to car accidents on the road.
ACKNOWLEDGEMENTS
This work was supported by the UTM Fundamental Research Grant (UTMFR) from Universiti
Teknologi Malaysia under Grant vot No. PY/2022/01312. The authors are grateful to Universiti Teknologi
Malaysia, Universiti Tun Hussein Onn Malaysia, and Universitas Ahmad Dahlan (Yogyakarta, Indonesia) for
their contributions to this collaborative research. Also, thank you to the Embedded System and Power
Electronics Research Group in Yogyakarta, Indonesia.
REFERENCES
[1] N. F. Watson et al., "Confronting drowsy driving: The American Academy of Sleep Medicine Perspective," J. Clin. Sleep Med.,
vol. 11, no. 11, pp. 1335–1336, 2015, doi: 10.5664/jcsm.5200.
[2] A. Shetty, Bhoomika, Deeksha, J. Rebeiro, and Ramyashree, "Facial recognition using Haar cascade and LBP classifiers," Global
Transitions Proc., vol. 2, no. 2, pp. 330-335, 2021, doi: 10.1016/[Link].2021.08.044.
[3] I. Zilli, F. Giganti, and V. Uga, "Yawning and subjective sleepiness in the elderly," J. Sleep Res., vol. 17, no. 3, pp. 303-308, 2008,
doi: 10.1111/j.1365-2869.2008.00659.x.
[4] C. A. Flores et al., "Quantitative 3-dimensional geometry of the aging eyelids," Plast. Reconstr. Surg. - Glob. Open, vol. 7, no. 11,
2019, doi: 10.1097/gox.000000000000251.
Indonesian J Elec Eng & Comp Sci, Vol. 34, No. 1, April 2024: 677-686
Indonesian J Elec Eng & Comp Sci ISSN: 2502-4752 685
BIOGRAPHIES OF AUTHORS
Simon Chong Kai Yuen received his B. Sc. Degree of computer science from
Universiti Teknologi Malaysia, Johor, Malaysia. He waived his master degree and persuing
his Ph.D. in Univerting Teknologi Malaysia. He is doing his research in computer vision
field. He can be contacted at email: simon@[Link].
Noor Hidayah Binti Zakaria Noor Hidayah Zakaria holds the position of Senior
Lecturer in the Faculty of Computing at Universiti Teknologi Malaysia. She earned her [Link].,
[Link]., and Ph.D. degrees in Computer Science from Universiti Teknologi Malaysia (UTM)
in 2011, 2014, and 2018, respectively. Dr. Zakaria's research focuses on artificial intelligence,
natural language processing, bioinformatics, and software engineering testing. Presently, she
is serving as the Academic Coordinator at the Faculty of Computing, UTM. In addition to
her academic accomplishments, Dr. Zakaria possesses professional certifications, including
Microsoft Certified: Azure AI Fundamental and Certified Python Programmer for Data
Science. She can be contacted at email: noorhidayah.z@[Link].
Real-time smart driver sleepiness detection by eye aspect ratio using computer … (Simon Chong Kai Yuen)
686 ISSN: 2502-4752
Ts. Dr. Goh Eg Su received the B.S. degree in information technology and the
M.S. degree in technical and vocational education from Universiti Tun Hussein Onn
(UTHM), Malaysia, in 2006 and 2008, respectively. She was a Lecturer with the Kolej
Komuniti Jempol, Negeri Sembilan, Malaysia within 2009-2011 and Kolej Komuniti
Tanjung Piai, Pontian, Johore, Malaysia, within 2011-2016. She further studied within 2016-
2019 and received her Ph.D. degree in Computer Science from Universiti Teknologi Malaysia
UTM, in 2019. She was a former Scholar and a Researcher with the Media and Game
Innovation Centre of Excellence (MaGICX), UTM. She has published some articles in
national and international conferences including publication in high impact journals. Her
research interests including computer graphics and information technology (especially in
augmented reality and human-computer interaction). After the study leaves, she had been
posted as a senior lecturer with Politeknik Balik Pulau, teaching Android Application
Development and Integrative Programming and Technologies from August 2019 until Jun
2020. Currently, she is a senior lecturer with Faculty of Computing, UTM. Email:
[Link]@[Link].
Tole Sutikno is a lecturer and the head of the Master Program of Electrical
Engineering at the Faculty of Industrial Technology at Universitas Ahmad Dahlan (UAD) in
Yogyakarta, Indonesia. He received his Bachelor of Engineering from Universitas
Diponegoro in 1999, Master of Engineering from Universitas Gadjah Mada in 2004, and
Doctor of Philosophy in Electrical Engineering from Universiti Teknologi Malaysia in 2016.
All three degrees are in electrical engineering. He has been a Professor at UAD in
Yogyakarta, Indonesia, since July 2023, following his tenure as an Associate Professor in
June 2008. He is the current Editor-in-Chief of TELKOMNIKA and Head of the Embedded
Systems and Power Electronics Research Group (ESPERG). He is one of the top 2% of
researchers worldwide, according to Stanford University and Elsevier BV's list of the most
influential scientists from 2021 to the present. His research interests cover digital design,
industrial applications, industrial electronics, industrial informatics, power electronics, motor
drives, renewable energy, FPGA applications, embedded systems, artificial intelligence,
intelligent control, digital libraries, and information technology. He can be reached via email
at tole@[Link].
Indonesian J Elec Eng & Comp Sci, Vol. 34, No. 1, April 2024: 677-686