1 INTRODUCTION
The first work about this theme was published this year (Santos et al, 2023). This present work arises as a new line of research related to the implementation of algorithms to better adapt to the user, potentially enabling the application to 'get to know' the user to enhance its fatigue detection (access to data from digital watches such as heart rate measurements, accelerometers, etc).
The project's goal is to address the problem of tiredness, which is a significant issue associated with human behavior. In 2022, there were 32.788 road accidents in Portugal, resulting in 462 fatalities, and fatigue was identified as the second leading cause of these accidents (PORDATA, 2022). The project's solution primarily focuses on warning individuals about potential dangers to reduce human errors.
Key objectives of the project include the development of data capture and pro-cessing systems, image decoding, user feedback, and alerts. The main development goals are to create a simple, lightweight, and easily deployable application for immediate workplace use. The application's purpose is to support individuals in their tasks and become an essential tool that intervenes only when necessary, without interfering with user performance.
2 CONCEPTION
The genesis of this project stems from the recognition of a common issue afflicting many individuals - drowsiness. Throughout their lives, numerous people encounter instances of drowsiness or even nod off while engaged in professional responsibilities. Consequently, the concept of devising a technological solution to prevent or mitigate the risks associated with drowsiness was conceived. The approach to addressing this issue centered on creating a simple, user-friendly, and lightweight application.
This application was designed to be minimally intrusive and non-distracting, allowing users to proceed with their daily routines seamlessly while ensuring the preservation of normalcy in case of emergencies. However, the application was also structured to interact and intervene if the situation demanded emergency measures.
The envisioned system aims to alert users in the event of an emergency, such as the onset of drowsiness, employing more assertive measures to mitigate or eliminate the consequences of falling asleep. The proposed solution has broad applicability, targeting long-distance or particularly vigilant drivers, operators of heavy machinery, and the automotive industry, potentially becoming a standard feature in new vehicles. Additionally, it holds relevance in the industrial sector, especially for roles with permanent shifts that demand heightened attention, where falling asleep could have severe repercussions for both productivity and individual well-being.
A tangible example could be a car production line, where compromised production capacity due to employee fatigue might lead to the production of defective car parts, tarnishing the company's reputation and posing risks to lives, including the individual operating the machinery. The proposed solution, being a low-maintenance application at the local level, is intended to seamlessly integrate into work systems with minimal disruption to users' daily lives. The goal is to meet users' needs to stay alert during their tasks without causing distraction or making them feel constantly monitored. Implementation of the solution envisions voluntary participation, with individuals opting to install the necessary software and hardware for its functionality. This universality allows for its installation in diverse situations with minimal preparatory requirements. The project distinguishes itself from existing solutions by bridging the gap between the safety features of in-vehicle systems and the ease of transmission found in vehicle-to-vehicle systems, minimizing complexities. Employing a heuristic approach, the system associate’s values with the frequency of incidents, utilizing this data to infer the likelihood of the user being in a state of sleep.
In Figure 1, the integration of each component into the model and their interconnections are visually represented, aligning to achieve a low-maintenance application at the local level as advocated in this study.
Upon scrutinizing the schematic representation of the proposed model, it be-comes evident that it comprises four main modules: the main module, collection module, send and treat module, and warning and alarm module. The main module serves as the foundation through which the other modules interact, facilitating the exchange of data and results among them. Initiating a task involves the utilization of the collection module, which employs the Aforge. Imaging library to access the camera, capturing an image that is subsequently relayed to the main module.
The collection module manages the utilization of available system cameras for image capture, and the captured data is transmitted to the sending module. The Shipping block is then employed to communicate with the Face API, retrieving milestone values for processing, which are subsequently forwarded to the treat-ment block. This module establishes REST communication with the API, converting the received data into a string variable. Upon reception in the sending mod-ule, the data is processed and compared in the treatment module to ascertain if the user exhibits signs of drowsiness, generating a "confidence" value.
The confidence value becomes the basis for the warning and alarm module, triggering a warning or, if necessary, an alarm where the alarm window is activated. This comprehensive process ensures that the system can effectively detect and respond to potential instances of user drowsiness.
Implementation and results
The application was crafted using the C# programming language within the Visual Studio environment (Microsoft, Visual Studio, 2019). Microsoft Cognitive Services, specifically the Face API (Microsoft, Azure Cognitive Services, 2019), was employed to facilitate the submission and processing of facial landmarks, thereby enabling the computation of project metrics. The application is built on the Windows platform, utilizing the Windows Presentation Foundation, which adheres to the application syntax.
This foundation serves as a cohesive programming model for constructing Windows applications (Microsoft, Windows Presentation Foundation, 2019). Operationally, the application stores specific data, such as total recording hours, start and end times of each recording session, and details of each detected "incident" (such as eye closure), in an SQL database. This database serves as a repository for all incidents and recordings, contributing to comprehensive incident tracking.
Additionally, the application leverages the AForge. Imaging library to interface with and optimize the usage of webcams installed on the system (AforgeTeam, 2019). The technological framework employed in this project revolves around Microsoft's Face API, a specialized cognitive service. This API enables data transmission and, thanks to its pre-trained artificial intelligence structure, returns a detailed list of information. This information encompasses various details, such as the person's hair color, estimated age, and, most importantly, facial landmarks. The integration of the Face API enhances the application's capabilities by providing valuable insights derived from facial analysis. We also utilise and implement Dlib (Dlib.net. s.d.).
The Dlib library is a popular choice for facial recognition and offers a set of ready-to-use tools and templates. Dlib is an open-source C++ library widely used for computer vision tasks, including face detection, object tracking, facial recognition and much more. Here are some examples of projects that can be imple-mented with Dlib:
Face Detection and Landmarks:
Implement a face detection system that localises faces in images or videos and then identifies the landmarks on the faces, such as eyes, nose and mouth.
Facial Recognition:
Create a facial recognition system that compares faces detected in an image with faces in a database to identify people.
Eye or Facial Expression Tracking:
Implement an eye-tracking system to track eye movement in a video. This can be useful in visual attention research. Develop a facial expression recognition system that identifies emotions such as happiness, sadness, anger, etc., based on changes in facial features.
Object detection:
Use Dlib to detect and track objects in videos, such as vehicles on a road or people in a crowd.
3 IMPLEMENTATION AND RESULTS
The application was developed using the C # programming language, with Visual Studio (Microsoft, Visual Studio, 2019), and using the Microsoft Cognitive Ser-vices (Microsoft, Azure Cognitive Services, 2019) Face API, to enable submission and treatment of face milestones, thereby enabling project calculations. The application is based on Windows, using the Windows Presentation Foundation, which is based on the application syntax. This foundation represents a unified programming model for building Windows applications (Microsoft, Windows Presentation Foundation, 2019). The application itself saves certain data, such as total hours, each time it starts recording and ends, as well as each “incident” it detects (such as closing its eyes) in an SQL database, to instantiate all incidents as well as all recordings made. It also uses the AForge. Imaging library to describe the webcams installed on the system and to enhance their use for capture (AforgeTeam, 2019). The technology used to accomplish this project is based on Microsoft's more specific cognitive service, the Face API. This API allows send-ing and thanks to the structure of artificial intelligence already trained and ap-plied, returns a list of data, which can specify the hair color of the person, the estimated age, etc. However, the most important is that it returns the face mile-stone
These facial landmarks, as illustrated in Figure 2, represent distinctive points outlined and transmitted by the Face API system. These points correspond to significant facial features, such as the midpoint of the lip or the pupil, pinpointed by coordinates (Microsoft, Face API - Facial Recognition Software | Microsoft Azure, 2019). On the technical front, the AForge Framework (AforgeTeam, 2019) is utilized to interface with hardware, specifically the webcam. This framework facilitates the utilization and transmission of webcam data to the Face API servers. AForge Framework is tailored for computer vision and artificial intelligence programmers, containing various libraries. The application specifically employs the AForge. Imaging library to enable image processing for submission to the Face API. SQL, a relational database language, originated from the work of Dr E. F. Codd, as detailed in his paper "A Relational Model of Data for Large Shared Data Banks" (Oracle, 2019). Initially known as SEQUEL, it later became SQL due to patent constraints. Today, SQL serves as the standard language for relational databases, and Microsoft SQL Server, a commercial solution, allows the configuration of an SQL server to store data (Microsoft, 2019). It facilitates connections from applications in any preferred language on various platforms, including Windows and Linux. C#, pronounced as C Sharp, is a high-level programming language developed by Anders Hejlsberg in 2002, based on the C language and intended as an "increment" beyond C++. The language is designed to be simple, modern, and object-oriented, with features such as type checking, vector bounda-ry checking, and garbage disposal. Visual Studio, an IDE produced by Microsoft, is integral to C# development, providing a robust environment with debugging, compiling, and interpreting capabilities. IntelliSense technology assists in error detection and code completion, making programming more efficient (Microsoft, Intelligence, 2019). Visual Studio also supports other languages, including Visual Basic, F#, C++, Javascript, and Typescript. The development of the project was centered on implementing the application flow depicted in Figure 3, leveraging the capabilities of Visual Studio and the selected programming languages and frameworks.
The COLLECTION MODULE, as delineated in Figure 3, initiates a counter to facilitate the capture of an image at five-second intervals. These captured images are then transmitted to the upload module, where they undergo conversion and subsequent transmission, as implied by its name.
Given that images are not recorded for storage but are intermittently captured for upload, no video data is retained. Captured images undergo immediate processing and are deleted from memory without being stored in any directory. Since image processing occurs on Microsoft servers, adherence to their privacy policy is imperative for users who opt to accept it (Microsoft, Azure Cognitive Services, 2019). Upon image capture, in-memory processing takes place, converting it into a bitmap image and subsequently into a byte array for API utilization.
A REST call, designated as "Submit to API" in Figure iv, is executed to transmit data in accordance with the API documentation, resulting in the retrieval of a string variable for further handling. The contact with the Face API, as indicated in the preceding flowchart (Figure iv) with the label "Upload to API," involves the insertion of the captured image into the API servers. This method initiates a REST connection to the API servers, necessitating the retrieval of parameters such as face landmarks, image exposure, and head position upon its completion. These retrieved values are consolidated into a string variable to facilitate further pro-cessing. The isolated and processed variables encompass the top and bottom co-ordinates of both the right and left eyes, the orientation of the head, and the co-ordinates of the upper and lower lip. These landmarks constitute the crucial data points utilized for fatigue detection and subsequent identification of drowsiness.
In Figure 4, the alarm-triggered puzzle interface is presented, compelling the user to solve it to deactivate the alarm. This window incorporates various text boxes and buttons designed for entering the specific sentence provided by the window.
If the user correctly inputs the sentence, the window closes, and the program re-starts to facilitate nearly immediate resumption of normal use. In the event of an incorrect completion, the puzzle persists with the alarm active, resetting the text boxes for subsequent attempts. Notably, the requested word for the puzzle re-mains unchanged throughout this process. Under typical usage conditions, users cannot voluntarily access this menu. However, in this program version, controls in the main window allow users to access this interface without triggering the alarm initially. Soak Testing, a form of test, involves prolonged software operation under normal conditions and transaction volumes. This extended duration serves to assess the program's endurance, identifying potential issues like memory leaks or previously unnoticed bugs that might arise with prolonged use (Guru99, 2019). The initial phase of this test involved maintaining the application in a dormant state for fifteen minutes to evaluate any potential memory-related problems without active user interactions.
As depicted in Figure 5, the dormant process in this mode exhibits no evidence of leaks or issues throughout its duration without any user action. There is only a swift initial surge in memory usage within the first few seconds, attributed to the initiation of the application code. Processor usage has been consistently maintained at a minimal level, with occasional spikes observed throughout its operation. The subsequent process, which has already resumed normal functioning, would have been active for an hour.
4 FUTURE IMPROVEMENTS
Potential enhancements and future developments for the proposed solution can be considered. One avenue for improvement involves the integration of addition-al sensors, such as a heart rate monitor, to augment the system's accuracy and efficacy. Expanding the system's capabilities could also entail integration with other smart technologies, such as the Internet of Things (IoT), fostering increased connectivity and data exchange. Furthermore, ongoing research and development efforts may yield novel advancements in artificial intelligence.
Incorporating these innovations into the system could elevate its overall performance. Continuous exploration of new possibilities and avenues for improvement is crucial to ensure the system's sustained effectiveness and relevance in addressing driver fatigue and enhancing road safety.
5 CONCLUSION
Driver fatigue stands out as a significant contributor to road accidents, ranking second in Portugal's accident statistics. This underscores the imperative for an effective solution to address drowsiness among drivers. The presented project introduces a system designed to mitigate this issue through the development of an application geared towards detecting and alerting drivers about potential drowsi-ness. Employing artificial intelligence-based technology, specifically the Microsoft Face API, the system analyzes the driver's facial features to assess drowsiness. The proposed solution is intentionally lightweight, user-friendly, and primarily non-intrusive, yet equipped to issue warnings and intervene when necessary to uphold driver safety. This low-maintenance application, seamlessly inte-grated into local systems, ensures minimal disruption to users' daily routines. Its adaptability extends beyond the individual user, making it suitable for implementation across various sectors, including automotive and industrial domains. In essence, the proposed solution serves as an intermediary approach, bridging the gap between the security offered by in-vehicle systems and the accessibility of mobile systems. By enhancing road safety, this solution holds the potential to save lives and contribute to accident prevention.


















