PROJECT 1
PROJECT 1
Road crashes are the most common forms of accidents and deaths worldwide, and the significant reasons for these accidents are usually drunken, drowsiness and reckless behavior of the driver. This project proposes an idea to detect drowsiness using machine learning algorithms, hence alarming the driver in real-time to prevent a collision. The model uses the Haar Cascade algorithm, along with the OpenCV library to monitor the real-time video of the driver and to detect the eyes of the driver. By continuously monitoring the presence of eyes, the system can determine if the driver's eyes are open or closed. If the driver's eyes are closed for an extended period, indicating drowsiness or sleep, the system triggers an alert to prevent potential accidents.
The prevalence of driver drowsiness and its associated risks pose significant challenges to road safety. Fatigue-related accidents can have severe consequences, leading to injuries, loss of life, and property damage. To address this issue, the driver drowsiness detection project has been developed using Python and the OpenCV library. By leveraging computer vision techniques, this project aims to detect signs of drowsiness in drivers and prevent accidents caused by driver fatigue. The driver drowsiness detection project is designed to prevent accidents caused by drivers becoming drowsy while driving. The system detects the presence of a driver's face and eyes in real-time using Haar cascades, which are pre-trained classifiers. By monitoring the driver's eye activity, the system can identify signs of drowsiness.
Driver drowsiness is often characterized by symptoms such as heavy eyelids, frequent yawning, and impaired attention. These indicators can significantly impair a driver's ability to react quickly and make sound decisions while on the road. Therefore, implementing a system that can monitor these signs in real-time can play a crucial role in mitigating the risks associated with drowsy driving.
During the past few years, there has been a growing focus on observing the behavior of drivers, as well as road and traffic conditions, to avoid accidents and safeguard passengers' lives. To achieve this, various techniques have emerged, including vehicle cameras, sensors, and Advanced Driver Assistance Systems (ADAS). Among these, utilizing sensors built into mobile smartphones has been an effective approach, particularly in developing countries like India, for monitoring driving behavior.
Furthermore, deep learning approaches have also been applied in drowsiness detection systems. Abouelenien et al. (2019) used a convolutional neural network (CNN) to extract features from the driver's face and eyes for drowsiness classification. Their results showed high accuracy in detecting drowsiness based on facial and eye expressions.
Several studies have also investigated the integration of additional sensors, such as infrared cameras or electroencephalography (EEG), to enhance drowsiness detection accuracy. These sensors capture physiological signals associated with drowsiness, such as brainwave patterns. Verma et al. (2020) combined facial feature analysis with EEG signals to improve drowsiness detection accuracy, achieving better performance compared to using facial features alone.
EXISTING SYSTEM
NO EYE DETECTION - most critical sign of drowsiness Yawning and nodding are not always practical. Varies from person to person - some may not yawn when they are sleepy sometimes.
Physiological sensors: In some research systems, sensors measuring EEG (brain activity) or EOG (eye movement) might be used.
The biosensors like head bands, head phones and hand bands needs to be attached to the human body, but these are less common due to intrusiveness.
Needs to be attached to the human body
⁃ If driver forgets to wear it?
- May hesitate to wear
PROPOSED SYSTEM
The proposed system will continuously monitor the movement of the driver's eye with a live camera and all the monitored signals are pre-processed. The project employs Haar cascade classifiers for face and eye detection. It continuously captures frames from a camera feed, analyzes them using grayscale conversion, and applies the cascades to identify faces and eyes. A time interval is set to monitor eye activity, and if a certain ratio of closed eyes is exceeded, an alert is triggered to warn the driver of potential drowsiness.
REQUIREMENTS
HARDWARE REQUIREMENTS : The hardware requirement specifies each interface of the software elements and the hardware elements of the system. These hardware requirements include configuration characteristics.
•System : Pentium IV 2.4 GHz.
•Hard Disk : 100 GB.
•Monitor : 15 VGA Color.
•Camera : A Webcam.
•RAM : 1 GB.
SOFTWARE REQUIREMENTS: The software requirements specify the use of all required software products like data management system. The required software product specifies the numbers and version. Each interface specifies the purpose of the interfacing software as related to this software product.
•Operating system : Windows XP/7/10
•Coding Language : Python 3.7
•Libraries : OpenCV, NumPy, Time
ALGORITHMS
Haar Cascade Classifier Algorithm: The Haar Cascade Classifier is a machine learning object detection algorithm used to identify objects in images or video streams, particularly effective for detecting faces and facial features. It was developed by Paul Viola and Michael Jones and is based on the concept of Haar features. Here's a more detailed explanation:
•It works by using simple rectangular patterns called Haar features to detect variations in intensity. These features are computed rapidly using pre-computed tables called integral images. The classifier is trained using Adaboost, which selects the most relevant features to build a strong classifier. Multiple classifiers are arranged in a cascade, where simple classifiers quickly reject non-object regions, and more complex classifiers confirm detections in promising areas. This approach speeds up the detection process by focusing on potential object locations. Overall, the Haar Cascade Classifier is a powerful tool for object detection, with applications in face recognition and other areas."
OpenCV Haar Cascades
1.Haar Cascade Classifier: This algorithm is used for both face and eye detection. Haar Cascades are machine learning object detection algorithms used to identify objects in an image or video stream. They are particularly effective for face and facial feature detection.
·Face Detection: The haarcascade_frontalface_default.xml is a pre-trained Haar Cascade classifier specifically tuned for detecting faces in images. It scans the image for patterns/features that match a face.
·Eye Detection: The haarcascade_eye_tree_eyeglasses.xml is another pre-trained Haar Cascade classifier, optimized for detecting eyes, including scenarios where the subject might be wearing glasses.
2.Grayscale Conversion: While not an algorithm for detection, converting the image to grayscale is a crucial preprocessing step in many computer vision tasks, including those using Haar Cascades. Grayscale images simplify the algorithm since they reduce the complexity involved in processing compared to full-color images.
METHODOLOGY
•The system will take video frames directly from the webcam.
• Grayscale conversion optimizes processing performance for each frame. The face cascade is then used to identify the faces in the shot.
• We can distinguish between left and right eye features on the face.
• If no face is detected, a message is printed.
• Rectangles are drawn around each detected face on the frame. The grayscale frame's region of interest (ROI) is retrieved in order to locate the eyes within it.
• If a given time interval (15 seconds in this case) has passed, the algorithm compares the number of frames with eyes closed to the total frames. If the ratio exceeds a threshold (0.2 in this case), an alert is generated.
• The code updates the counters for frames with and without eyes based on eye detection findings.
• If eyes are identified within the ROI, rectangles are drawn on the frame.
• Display the frame including all rectangles and detected results.
•We use SciPy's Euclidean function, for calculating "Eyes Aspect Ratio" E.A.R.
SYSTEM IMPLEMENTATION
1.Image Capturing: This step involves capturing images or frames from a camera mounted inside the vehicle. These images are then used for further processing.
2.Preprocessing: Preprocessing is done to enhance the quality of the images and make them suitable for feature extraction. This may include resizing, converting to grayscale, and noise reduction.
3.Dividing into Frames: The captured video stream is divided into individual frames. Each frame represents a single image that will be processed for drowsiness detection.
4.Feature Extraction: Feature extraction involves identifying relevant features from the images that can help in determining the driver's state. Features could include facial landmarks, eye closure patterns, head movements, etc.
5.Face Detection: Face detection is performed to locate and extract the region of interest (ROI) containing the driver's face. This can be done using techniques like the Haar Cascade classifier or deep learning-based approaches.
6.Alert Mechanism: An alert mechanism is triggered when signs of drowsiness are detected. This could include visual, auditory, or haptic alerts to alert the driver and prevent accidents.
RESULTS
CONCLUSION
In conclusion, driver drowsiness detection by Python and OpenCV libraries becomes a necessary measure of improving road security and a way of preventing accidents from occurring due to driver drowsiness. This project is highly productive in maintaining drivers' eyes and facial activity in real-time by mere detection of fatigue through computing and it alerts immediately when it detects signs of fatigue rather too late. This is a preventive measure and very likely a lifesaver and it may reduce the dangers of driving when drunk.
The effectiveness of eye openness evaluation is made possible by utilizing EAR calculation along with Haar cascade classifiers used for recognizing faces and eyes. For the drivers on the road, the interface of the system enables them to handle driver awareness by just checking their levels of awareness and taking the relevant precautions to ensure they always keep driving in an aware manner.
The system's ultimate purpose is to assess whether or not the driver is drowsy. A system is designed such that when the driver's eye movements appear to be drowsy, an alarm sounds to alert and notify the driver of their surroundings, lower the car speed, and turn on the parking light. These will decrease the probability of accidents and guarantee the safety of the driver and the vehicle.