Vous êtes sur la page 1sur 43

Adaptive lighting and Safety systems for automobiles interfacing CAN 1

Chapter 1
INTRODUCTION

1.1 Background
Improper vision and drowsy driving along with not taking appropriate precautions for
safe driving becomes the reason for numerous road accidents. People these days don’t even
show the manners to dim their head lights when they cross each other, which is actually leading
to low visibility and less clarity scenario. In a survey conducted amongst several people shows
that a number of accidents on our roads is due to lack required illumination or due to improper
vision. The standard rating of headlamps allowed to be used in automobiles is 12V 85 watts as
per government specifications but nowadays people are employing lamps with higher ratings
than the allowed rating specifications which will result in visual pollution and therefore reduced
vision especially during night.

Similarly drinking and driving is being a trend among the youngsters. Alcohol reduces
concentration. It decreases reaction time of a human body. Limbs take more time react to the
instructions of brain. It hampers vision due to dizziness. Alcohol dampens fear and incite
humans to take risks. All these factors while driving cause accidents and many times it proves
fatal. Modern drivers are not careful enough to ensure seatbelt before driving. Wearing seat
belts and helmet has been brought under law after proven studies that these two things reduce
the severity of injury during accidents. Wearing seat belts and helmets doubles the chances of
survival in a serious accident. Another major issue to be addressed in this field is the timely
medication to the victims which can make a difference between life and death. Most of the time
the victims are left on the accident spot isolated from help or remains unknown to people to
provide them with necessary help. If proper first aid is given in the first hour (known as the
golden hour) after the trauma, accident victims has a greater chance of survival and a reduction
in the severity of their injuries. It is high time to address these problems and difficulties faced
during driving.

1.2 Objective

Road accidents are undoubtedly the most frequent and, overall, the cause of the most
damage. Surveys shows that in India on an average around 400 people die a day in road

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 2

accidents and every year 1.3 million people die in road traffic crashes around the world, and
between 20 and 50 million people suffer non-fatal injuries. The reasons for this can be many
including careless of the driver, over speeding, drowsy driving, not taking appropriate safety
measures, over illumination or lack of proper lighting on roads and also due to accidents with
delayed medical help resulting in unwanted deaths. In this scenario of road accidents increasing
at an alarming rate, automobile safety and health conditions of the driver is an issue to be
addressed immediately thus providing comfortable driving experience especially during night.

The situation calls for a safety system that has the potential to practically cope with the
conditions prevailing in our country regarding road accidents and safety measures to deal with
the existing scenario. Engineering a system with the ability to address the above-mentioned
problems experienced during driving thereby reducing the chances of accidents along with
reducing the impacts of an accident once taken place.

If we are able to design a safety system for automobiles as a single module that can be
interfaced with any vehicle as an additional add on performing several functions such as
drowsiness detection and alarming system, adaptive lighting system to provide with correct
illumination to suit various real time situations, notifying obstacles on road avoiding unwanted
collisions, alcohol consumption detection system etc can have numerous practical applications
in the field of automobile safety in our country.

1.3 Scope of the project

The proposed prototype aims to develop a safety system for automobiles capable of
performing numerous functionalities. Adaptive lighting system that helps in maintaining
sufficient amount of light in front of the vehicle always apart from ordinary bright and dim
functions of headlamps. Real time drowsiness detection system to check whether the driver is
feeling sleepy with the help a camera. Detection of drowsiness will activate alarms along with
turning on hazardous lights to notify co-drivers on road that the vehicle can be a temporary
obstruction. Most of the time vehicles collide into vehicles in front of them or to some objects
on road for example, say speed breakers, U-turn deviations etc without prior notice especially
during night time. This can be due to lack of attention or not maintaining a safe distance in
front of the vehicle impacting their ability to stop quickly when needed resulting in collisions.
Unseen obstacle detection system will help to warn the driver regarding any obstacles in front
of it. Employment of alcohol sensors to detect alcohol consumption by the driver and an

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 3

accident alert messaging system to guarantee timely medical can contribute to active safety
environment.

Few luxurious automobile companies offer some of the above-mentioned functionalities


such as intelligent lighting that lights the curves of the roads as we drive. Advanced driver-
assistance system, adaptive cruise control system for road vehicles that automatically adjusts
the vehicle speed to maintain a safe distance from vehicles ahead. Everyone cannot afford to
buy these vehicles. The proposed prototype provides us with functions such as adaptive lighting
system, drowsiness detection system, unseen obstacle detection system, alcohol consumption
detection system and accident alert messaging system all combined into one single safety
system module that can be interfaced with existing vehicle architecture using CAN Interfacing
Technology used commonly in vehicles.

1.4 Outline of the project

Chapter 1 gives a brief description about the background the project focuses on followed
by the objective and scope of the project. Chapter 2 explains the literature survey and the
research gap in the project specialisation area. This is followed by the problem definition and
thereafter the objective of the project. Chapter 3 deals with the methodology we use, its
theoretical background and the work plan employed. The chapter also explains the proposed
system with suitable illustrations.

Chapters 4, 5 and 6 gives the complete system architecture, the working mechanism of
each safety system and the design and demonstration respectively. These chapters will give us
the complete details regarding the principle, construction, design and working of the prototype
with the help of figures. Results and its analysis are discussed in Chapter 7. Chapter 8
summarize the project as a whole including its future expansion and scope.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 4

Chapter 2
LITERATURE SURVEY

2.1 Introduction
The rate of occurrence of accidents are increasing tremendously all over the world. The
reasons for this can be many including carelessness of the driver, violating traffic rules, poor
quality roads, lack of necessary sign boards, indicators and reflectors. Automobile safety is an
active area of research and development. Researchers are coming out with new technologies to
tackle with the major issues identified as the potential reasons for road accidents these days.
These research works form the initial platform of study for the proposed prototype. Through
this study we will be able to identify the technologies currently in use and their limitations.

2.2 Literature survey


2.21 Adaptive Headlamps for Automobiles

Dubal, Priyanka, and J. D. Nanaware. "Design of adaptive headlights for


automobiles." International Journal on Recent and Innovation Trends in Computing and
Communication 3, no. 3 (2015): 1599-1603.

The aim is to improve visibility for driver and so achieve a significant increase in safety
and driving comfort. This calls for a flexible front light for automobiles to illuminate road
ahead in the night at corner. Adaptive front lighting system (AFS) helps improve driver’s
visibility at night time hence achieving enhance safety. AFS (adaptive front-lighting system)
used to detect information about corner in advance with help of sensor which detect the
information send it to motor to adjust headlamps to get the lighting beam which was suitable
for the corner. Through this way, it could avoid "blind spot" caused by the fixed lighting area
when coming into the corner, and improve driving safety.

2.22 Drowsiness Detection

Ueno, Hiroshi, Masayuki Kaneda, and Masataka Tsukino. "Development of drowsiness


detection system." In Proceedings of VNIS'94-1994 Vehicle Navigation and Information
Systems Conference, pp. 15-20. IEEE, 1994.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 5

Preventing drowsiness during driving requires a method for accurately detecting a


decline in driver alertness and a method for alerting and refreshing the driver. As a detection
method, the authors have developed a system that uses image processing technology to analyze
images of the driver's face taken with a video camera. Diminished alertness is detected on the
basis of the degree to which the driver's eyes are open or closed. This detection system provides
a noncontact technique for judging various levels of driver alertness and facilitates early
detection of a decline in alertness during driving.

After inputting a facial image, the maximum width of the face is then detected so that the
right and left edges of the face can be identified. The vertical position of each eye is detected
independently within an area defined by the centre line of the face width and lines running
through the outermost points of the face. On that basis, the area in which each eye is present is
determined. Once the areas of eye presence have been defined, they can be updated by tracking
the movement of the eyes. The degree of eye openness is output simultaneously with the
establishment or updating of the areas of eye presence. That value is used in judging whether
the eyes are open or closed and also in judging whether the eyes have been detected correctly
or not. If the system judges that the eyes have not been detected correctly, the routine returns
to the detection of the entire face.

2.23 Automatic Vehicle Accident Detection and Messaging system using GPS
and GSM Modems

Sri Krishna Chaitanya Varma, Poornesh, Tarun Varma, Harsha “Automatic Vehicle Accident
Detection and Messaging system using GPS and GSM Modems”, International Journal of
Scientific & Engineering Research, Volume 4, Issue 8, August-2013 ISSN 2229-5518.

This paper describes about the Automatic Vehicle Accident Detection and Messaging
System using GPS and GSM Technologies. We are using AT89C52 microcontroller in our
project. When the system is switched on, LED will be ON indicating that power is supplied to
the circuit. When the IR sensors that we are using in our project sense any obstacle, they send
interrupt to microcontroller. The GPS receives the location of the vehicle that met with an
accident and gives the information back. This information will be sent to a mobile number
through a message. This message will be received using GSM modem present in the circuit.
The message will give the information of longitude and latitude values. Using these values, the
position of the vehicle can be estimated.
B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering
Adaptive lighting and Safety systems for automobiles interfacing CAN 6

2.24 Vehicle ignition interlock systems with multiple alcohol sensors

Mobley, L.J., McMillin, B., Edwards, J.H. and Lewis, J.R., Monitech Inc, 2007. Vehicle ignition
interlock systems with multiple alcohol sensors. U.S. Patent 7,287,617.

A vehicle ignition interlock system includes a breath analyser and a controller operably
connected to the breath analyser and to an ignition system of the vehicle. The breath analyser
detects breath alcohol level of a vehicle operator and prevents vehicle ignition if a breath
alcohol level is greater than or equal to a threshold value. The controller requires the vehicle
operator to periodically take breath analyser “retests” after vehicle ignition in order to allow
vehicle operation to continue. The breath analyser includes first and second alcohol sensors.
The second alcohol sensor is a backup for the first alcohol sensor and becomes operational if
the first alcohol sensor malfunctions. The first or second alcohol sensors may be a mouth
contamination sensor that distinguishes between mouth contaminants and alcohol contained
within a deep lung breath sample. The system also includes sensors configured to detect impact
(abuse) and vehicle motion.

2.25 A Microcontroller Based Car-Safety System: Implementing Drowsiness


Detection and Vehicle Distance Detection In Parallel.

Das, P. and Pragadeesh, S., 2015. A microcontroller-based car-safety system: implementing


drowsiness detection and vehicle-vehicle distance detection in parallel. Int. J. Sci. Technol.
Res, 4(2).

Here we use an IR transmitter and a receiver. One main condition is that the IR transmitter
and receiver should be in a straight line for optimum performance. The transmitter transmits
IR rays into the eye of the driver. Depending on whether the eye is closed or open, there will
be high output for closed eye and low output for open eye. The transmitted signal is captured
by the IR receiver. This receiver is connected to the comparator. The comparator is an op amp
where the reference voltage is given to inverting input terminal and the output of receiver is
given to non-inverting terminal. When the IR transmitter passes the rays to the receiver, the
receiver is conducting due to the fact that non-inverting input voltage is less than inverting

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 7

input voltage. Now the output of comparator is GND, so output is given to microcontroller.
The whole system should be clipped on the rod of the glasses and placed closed to the eye.

2.3 Research gap


The current technologies related to our proposed system includes AFS – adaptive front
lighting system, drowsy driving detection using eye blinking sensor, Automatic Vehicle
Accident Detection and Messaging system using GPS and GSM Modems, Vehicle ignition
interlock systems with multiple alcohol sensors etc…

The AFS helps to improve driver’s visibility at night time, AFS (adaptive front-
lighting system) used to detect information about corner in advance with help of sensor which
detect the information send it to motor to adjust headlamps to get the lighting beam which was
suitable for the corner. Through this way, it can provide light in blind spots. Even though AFS
eliminates all blind spots it does not have any adaptive intensity control due to this it can’t
provide the required amount of light in required areas. Drowsy driving detection using eye
blinking sensor uses eye blinking sensors to detect sleep. This method requires the sensor to be
clipped onto the rod of a glass and placed closed to the eye as an eyewear. It is a discomfort to
the driver so a method which does not give any discomfort the driver should be used such as
image processing. In accident detection and alerting system an IR sensor is used to detect
collision, if an IR sensor is used the collision can’t be detected effectively since the IR sensor
gives positive output in high sunlight, therefore it will be considered as a collision so sensors
such as collision sensors should be employed

2.4 Problem definition


According to World Health Organisation, road accidents caused an estimated 1.25
million deaths worldwide in the year 2010. That is, one person is killed every 25 seconds.
However, less than 35% of the low and middle-income countries have the policies in place to
protect these road users. Abundant number of technologies are available in the field of
automobile safety. But not many of them are in cooperated into automobiles for practical
applications or are available for purchase in the market as extra safety modules. Such facilities
if available are only found in luxury vehicles. Not all of them are capable of buying these
automobiles.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 8

The proposed prototype addresses the above-mentioned issues. A system combining


numerous safety functions such as required amount of light for proper vision in front of the
vehicle, driver drowsiness detection system, unseen obstacle detection system, alcohol
consumption detection system and call for emergency services in case of an accident. The
complete system is made available as a single module that can be interfaced with any existing
vehicle architecture using Control Area Network(CAN) Interfacing.

2.5 Objective of the project


The prevailing situation all over the globe demands the need for advanced automobile
safety systems. Lack of proper lightings on our roads as well over illumination especially
during night time resulting in visual pollution. Another major issue of concern is driver
drowsiness resulting in accidents. Violation of traffic rules including not taking appropriate
safety measures also accounts. Though some of the issues mentioned above are addressed
today ,for example Adaptive Front Lighting System, they are offered by some of the luxury
automobile companies. Not all are able to afford them.
The literature review helps us to come across a lot of well-developed technologies that
has a huge potential in the field of automobile safety, but not many of them are available as
portable modules that can be in co-operated into any existing system. The proposed prototype
aims to develop a complete safety system for automobiles that comes a single module. It comes
several features such as adaptive lighting providing sufficient lighting, drowsiness detection,
obstacle detection, alcohol consumption detection and seat belt warning system. All these
functions are combined to form a single safety module that can be interfaced using (Control
Area Network) CAN Interfacing with any existing vehicle architecture.

2.6 Summary
A literature review is done on various innovations in the field of automobile safety
systems for accident detection, prevention and as part of safety measures. The different
technologies employed in various research work is studied in detail. The merits and demerits
of the existing projects in this area are analysed and problems requiring solutions are
identified.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 9

Chapter 3

METHODOLOGY

3.1 Introduction

A number of technologies are available in the field of automobile safety. Either only a
few among these technologies are available in the vehicles as part of the inbuild safety system
or are not available as modules in the market for purchase to be fitted into the vehicles. The
proposed prototype ‘Adaptive Lighting and Safety System for Automobiles Using CAN
Interfacing’ is a single module which can be interfaced with any existing vehicle architecture
using CAN interfacing. The module includes adaptive lighting system, drowsiness detection
system, unseen obstacle detection, alcohol consumption detection system.

Conventional methods of adaptive lighting technology use servomotors to light the


curves of the roads as we move forward. The proposed prototype uses Pulse Width Modulation
(PWM) technique to maintain sufficient amount of lux in front of the vehicle. Image processing
algorithms are used to detect driver drowsiness on a real time basis which is one of the most
efficient technology available in the field. In build alcohol consumption detection-based
vehicle ignition system rather than the conventional method used by the cops. Unseen obstacle
detection system based on ultra-sonic sound aiding in the reduction of automobile accidents
especially during night. The message alert system helps in providing medical assistance to the
accident victims as fast as possible.

3.2 Theoretical background

Adaptive lighting technology makes use of Pulse Width Modulation (PWM).


modulation (PDM), is a method of reducing the average power delivered by an electrical signal,
by effectively chopping it up into discrete parts. . The average value of voltage (and current)
fed to the load is controlled by turning the switch between supply and load on and off at a fast
rate. The longer the switch is on compared to the off periods, the higher the total power supplied
to the load.

Drowsiness detection system make use of camera for real time video streaming of the
driver frame by frame. From each frame the face is detected. From the face detected the eye

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 10

region is extracted using a facial landmark predictor. After detecting the eye region, aspect
ratio(EAR) is calculated each time to check whether the aspect ratio is greater than or less than
a threshold value to determine whether the driver is feeling drowsy or not.

For detecting alcohol, a digital alcohol sensor is used and if there is alcohol content in
the breath of the driver and it is greater than the allowed limit then the alarm will sound. Using
the alcohol sensor alcohol content in the driver’s breath is measured and compare with the set
value using Arduino if the value is greater than the set value then alarm is triggered.

Ultrasonic sensor emits ultrasonic sounds to detect the obstacles. It contains two parts, a
receiver and a transmitter, the transmitter transmits ultrasonic sounds into the environment.
These waves return back to the origin as an echo after striking on the obstacle. We can get the
total time taken by the sound waves to return to the receiver of the sensor. As speed of sound
of sound is known to us we can easily calculate the distance using the equation below.

Distance= [ Time * Speed of sound in air (340 m/s)] / 2

Project prototype in cooperates a mechanism such that each time the air bags are activated
a message will be send to any customized number and to the emergency services saying that
an accident has occurred along with the GPS location of the vehicle. This is done with the help
of an Arduino board controller, Global Positioning System(GPS) and Global System for
Mobile(GSM) module.

3.3 Work plan

The whole project is subdivided into five parts and each part is individually considered
for completion. The technology and design for each part is decided and studied for perfect
implementation. For adaptive light Arduino is decided to use as the controller, LDR as sensor,
IRFZ44n as MOSFET and a 35-watt LED is selected for the headlamp, Arduino software is
installed to program Arduino. For drowsy driving a computer is required for processing, a
camera is required for streaming the face of driver and a buzzer is required to wake the driver,
therefore a webcam with high quality streaming and raspberry pi b+ is selected as the processor,
and to run the image processing algorithm a platform is required OpenCV is selected as a
solution for this and programming is done in python. For alcohol detection and unseen obstacle
detection Arduino is decided to use as the controller and a MQ-3 gas sensor is selected as the

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 11

alcohol sensor since it has considerable range and accuracy, and for obstacle detection
ultrasonic sensor is chose.

3.4 Proposed System

The proposed system contains five subsystems and in every subsystem a microcontroller
is needed, therefore the system contains two Arduinos where one is used for adaptive lighting
and other one is used for unseen obstacle detection, alcohol detection and accident alerting
system. A raspberry pi b+ is used for image processing since it has moderate processing speed
and web cam connectivity, here a webcam with high quality video streaming is used and a
buzzer with high sound is used. For unseen obstacle detection and alcohol consumption
detection same Arduino controller is used, therefore a MQ-3 sensor which is used as the alcohol
sensor and an ultrasonic sensor are interfaced so that alcohol consumption and unseen obstacles
can be detected, when these are detected an alarm is sounded using a buzzer for this a high
sound alarm is used.

In accident alerting system the location of the accident spot is collected and it is send to
the emergency services and relatives via SMS, for collecting location a GPS module is used
and for sending SMS a GSM module is used. And all these are interfaced to the Arduino where
it is all controlled.

3.5 Summary

The control and monitoring functions in the proposed prototype mainly make use of
Arduino as the controller and Raspberry pi the processor. Various sensors are used to sense
different values as required by different control functions and their theoretical study helps in
employing them properly in the system for the respective function. Finally, all the five parts
are combined together to get the final product as a single safety module that can ne interfaced
with any system architecture using Control Area Network Interfacing, a technology employed
in automobiles to interface various systems so that they can easily communicate with each
other without any trouble.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 12

Chapter 4

SYSTEM ARCHITECTURE

The proposed prototype consists of the following modules:

4.1 Adaptive lighting system

Visual pollution is a serious cause of accidents these days especially during night.
Traditional headlamps often fail to provide the optimal illumination on road during night time.
High intensity opposite light coming from the opposite direction automobiles is causing
difficulty in clear glare free vision.

As per Indian standards there is a predefined amount of light for proper vision in various
places. Taking that into account we will fix the amount of lux and monitor it in real time with
the help of Light Dependent Resistor(LDR) and control it to a predefined value using Arduino.
Thus, maintaining the headlamps light intensity always, the same taking into consideration all
the lights falling onto the LDR sensor placed in front of the vehicle.

There are several technologies are available in market such as Adaptive Front Lighting
System(AFS). This technology involves switching between high and low beam. While the high
beam provides light distribution optimised for illuminating the road, the low beam is a kind of
compromise solution to avoid glare. Therefore, the combination high beam/low beam does not
represent the optimal state-of-the-art solution when it comes to safety during night-time driving.
A simple, obvious improvement in adverse weather conditions would be to equip the vehicle
with special auxiliary headlamps, such as fog lamps, which can be turned on or off by the driver
according to the situation. The next step would be to not implement these additional lighting
functions as individual auxiliary headlamps, but to integrate them into the main headlamps and
to make the switch between various light distributions automatic. This is the basic concept of
AFS headlamp systems.

But even most advanced AFS systems does not contains intensity control, even though
AFS is good in providing good quality light in many cases, the lack of intensity control is a
major problem since the amount of light needed in front of the vehicle varies with environment
so, with adaptive light different light on different situations can be obtained.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 13

Fig 4.1 Adaptive light architecture

4.2 Drowsiness detection system

The growing number of traffic accident fatalities in recent years has become a problem
of serious concern to society. Based on the results of accident analysis, the authors are engaged
in research and development work on active safety systems that are intended to reduce the
number of accidents causing death or injury. The key to driving safety and the prevention of
accidents before. they happen lies with the driver. For this reason, eliminating situations in
which the driver is insecure is essential to accident prevention. Accidents due to drowsiness at
the wheel have a high fatality rate because of the marked decline in the driver's abilities of
perception, recognition and vehicle control when sleepy. The prevention of such accidents is a
major focus of effort in the field of active safety research. Preventing accidents caused by
drowsiness requires a technique for detecting sleepiness in a driver and a technique for arousing
the driver from that sleepy condition. This project contains a system that uses image processing
technique to recognize the open or closed state of the driver's eyes as a way of detecting
drowsiness at the wheel. The results of various investigations are presented to show the
effectiveness of this system in detecting a state of reduced alertness in the driver.

The development of technologies for preventing drowsiness at the wheel is a major challenge
in the field of accident avoidance systems. Preventing drowsiness during driving requires a
method for accurately detecting a decline in driver alertness and a method for alerting and
refreshing the driver. As a detection method, the authors have developed a system that uses
image processing technology to analyse images of the driver's face taken with a video camera.
B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering
Adaptive lighting and Safety systems for automobiles interfacing CAN 14

Diminished alertness is detected on the basis of the degree to which the driver's eyes are open
or closed. This detection system provides a noncontact technique for judging various levels of
driver alertness and facilitates early detection of a decline in alertness during driving.

In this proposed prototype we are trying to develop a system with continuous real time
monitoring of the driver to detect any chance of sleep using face recognition and image
processing techniques. The video out of a camera is studied using image processing algorithms.
Drowsiness detection will lead to the automatic switching on of the hazardous indicators to
warn waking the driver up with the help of an alarm. This system contains three main parts
video capturing part, processing part and alerting part. A webcam is with HQ streaming is
chosen for video capturing it can be powered from a USB port and it can stream data to the
computer in a moderate speed. This streamed data is processed using a raspberry pi b+
computer. Alerting system contains a buzzer with high sound.

Fig 4.2 Drowsy driving detection system architecture

4.3 Unseen Obstacles detection system

Obstacles on the road such as speed breakers, road dividers, unexpected breakdown
vehicles or any other foreign objects can be a reason for accidents specially during night due to
poor lighting facility. In order to solve this trouble, we are making use of an ultra-sonic sensor.
This sensor emits ultra-sonic sound which hits on the objects and reflects back to sensor. With
the help of reflecting time and speed of sound, both being known quantities we can easily
calculate the distance to the obstacles on road. Thereby we can easily detect unwanted obstacles
B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering
Adaptive lighting and Safety systems for automobiles interfacing CAN 15

on road in front of our vehicle along with its distance from our vehicle. As per Indian motor
rules the safe distance between two vehicles is as per car and tire rule which means we should
be able to see the rear wheels of the vehicle in front of us. Thus, taking this distance into account
say 2 meters, we can program our ultra-sonic sensor with the help of Arduino board controller.

Fig 4.3 Object detection system architecture

4.4 Alcohol consumption detection system

An attempt is made to develop a locking system for cars so that the vehicle would not
ignite without alcohol consumption checking mechanism. The driver’s breath is analysed and
ethanol to carbon dioxide ratio is checked. If the parts of ethanol are more, it is detected as
presence of alcohol. The system will take the advantage of a pre-existing alcohol sensor and
Arduino board controller. In fact, this project aims to grant a base start for further explorations
in the future. The project aimed at the exiting efforts of accidents prevention system
developments, in hope of implementing it in the real life to increase road safety. The prototyped
system contains main three parts alcohol detection system, controller and an alerting system.

Here an MQ-3 sensor is used as the alcohol sensor, the gas sensor- MQ3 is suitable for
alcohol detecting, this sensor can be used in a breath analyser. It has a high sensitivity to alcohol
and small sensitivity to benzene. The sensitivity can be adjusted by the potentiometer sensitive
material of MQ3 gas sensor is SnO2, which with lower conductivity in clean air. When the
target alcohol gas exists, the sensors conductivity is higher along with the gas concentration
rising, use of simple electro circuit, convert change of conductivity to correspond output signal
of gas concentration. Alcohol Sensor MQ-3 gas sensor has high sensitivity to Alcohol, and has

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 16

good resistance to disturb of gasoline, smoke and vapour. It has fine sensitivity range around 2
meters. The sensor could be used to detect alcohol with different concentration. The Arduino
board is the central unit of the system, it is a programmable board based on ATmega328
microcontroller chip, and a buzzer is used for alerting.

Fig 4.4 Alcohol detection system architecture

4.5 Accident Alert Messaging System


There are many times when accidents occurring during night remains unknown to the
people for rendering help to the affected ones. A lot of people are dying unnecessarily due to
lack of timely help because they are not getting necessary medical aid soon after an accident
had taken place. As solution to the above-mentioned dilemma this project prototype in
cooperates a mechanism such that each time the air bags are activated a message will be send
to any customized number and to the emergency services saying that an accident has occurred
along with the GPS location of the vehicle. This is done with the help of an Arduino board
controller, GPS and GSM module.

The most important parts of the success of the airbag system are the crash sensors.
These small pieces of electronics are designed to tell when the vehicle has been damaged in an
accident. They respond to several different sets of stimuli, including sudden stopping, increased
pressure as pieces of the car are moved due to the force of the collision, and more.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 17

Different types of sensors measuring wheel speed, seat occupant status, brake pressure
and impact, and other vehicle status indicators are monitored by the airbag control unit located
in the front portion of the cabin. The sensors relay signals to the airbag control unit, which
analyses the data and can orchestrate safety features like seat belt lock, automatic door locks,
as well as airbag deployment.

Two types of airbag sensors used in cars are electrical and mechanical. Electrical
sensors vary in design. Some use an electromechanical "ball and tube" mechanism, which
basically consists of a small tube containing a circuit switch and ball that's held together by a
small magnet. If a collision occurs, the ball is dislodged from the magnet and rolls forward in
the tube, hitting a switch that completes the electrical circuit. Other electrical designs are
similar in principle, using a metal roller or spring-loaded weight instead of a ball, or in newer
cars, an accelerometer to trip the sensor. Mechanical sensors work independent of the electrical
system and respond similarly to the electrical sensors, with a design that actuates a firing pin
triggering a small explosion after a crash. Since a mechanical sensor does not require a power
source, it cannot be deactivated like an electrical sensor can when the battery is disconnected.

Once the control unit determines there is an accident, it sends a signal to the inflator
system this signal can be tapped and used as the trigger signal for the alerting system.

Fig 4.5 Accident alerting system architecture

Finally, all the five parts are combined together to get the final product as a single safety
module that can ne interfaced with any existing vehicle system architecture using Control Area
Network Interfacing, a technology employed in automobiles to interface various systems so
that they can easily communicate with each other without any trouble.

The complete block diagram of the system is as shown in the fig 4.6 below.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 18

Fig 4.6 System architecture

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 19

Chapter 5
WORKING MECHANISM
5.1 Adaptive lighting system
The AFS technology thus shifts between high and low beams providing optimised light
distribution and glare control respectively. The technology we use here employs Pulse Width
Modulation(PWM). Pulse width modulation (PWM), or pulse-duration modulation (PDM), is a
method of reducing the average power delivered by an electrical signal, by effectively chopping
it up into discrete parts. The average value of voltage (and current) fed to the load is controlled
by turning the switch between supply and load on and off at a fast rate. The longer the switch is
on compared to the off periods, the higher the total power supplied to the load.

An Arduino is used as the controller and LDR as light sensor. To control the intensity
of light a MOSFET(IRFZ44N) is used which is connected in series with the LED lamp. Using
PWM technique, the MOSFET is turned on and off to control the intensity of light. For this to
happen the output from the LDR is fed into the Arduino where it is compared with a reference
value, a value corresponding to the required lux which is fixed as 550 lux. After comparing, a
control signal is generated and is given to the gate of MOSFET which then by turning on and
off, the average voltage to the lamp is controlled thereby controlling the intensity of light as
indicated in Fig 1.

Fig.5.1 Adaptive light flowchart

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 20

5.2 Drowsiness detection system

A camera is used for real time video streaming of the driver frame by frame. From each
frame the face is detected. From the face detected the eye region is extracted using a facial
landmark predictor. After detecting the eye region, aspect ratio(EAR) is calculated each time
to check whether the aspect ratio is greater than or less than a threshold value fixed by the
operator, which in this case approximated to 0.28. If the measured value is less than the
threshold value for 10 consecutive frames then the driver is considered to be drowsy A buzzer
system is activated to wake the drowsy driver along with turning on hazardous lights to notify
co-drivers on road that the vehicle can be a temporary obstruction. A raspberry pi b+ computer
is used for processing the image and finally detecting sleep. The algorithm for sleep detection
is written in python and implemented in raspberry pi.

the dlib library imported in the python program contains a facial land predictor known
as shape predictor which is trained using a standard dataset. When this shape predictor is fired
the predictor will map the face into 68 salient poles as show in the fig.

Fig 5.2 Facial landmark predictor

The points 37 to 42 in the facial landmark predictor represents the left eye and the points 43 to
48 represents right eye, by extracting these points the position and state of the eye can be
determined. By using these points eye aspect ratios can be calculated using the equation,

EAR = (A + B) / (2.0 * C)

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 21

Where,

A = Euclidean distance between points P2 and P6


B = Euclidean distance between points P3 and P5
C = Euclidean distance between points P1 and P4

Fig. 5.3 Eye aspect ratios when eye is open and closed

These EAR is calculated in every frame and if EAR is less than the
reference value that is 0.28 for 10 consecutive frames, then driver is considered drowsy and
buzzer is sounded.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 22

Fig.5.4 Flowchart for eye detection

5.3 Unseen Obstacles detection system


In this system the sensor employed is an ultra-sonic sensor and Arduino is used as a
controller. Using ultrasonic sensor objects in front of the vehicle in a specified range are
detected.

Ultrasonic sensor emits ultrasonic sounds to detect the obstacles. It contains two parts, a
receiver and a transmitter, the transmitter transmits ultrasonic sounds into the environment.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 23

Sensor used here is HC-SR04.It offers excellent non-contact range detection with high
accuracy and stable readings. From 200cm to 400cm or 1’’ to 13 feet. These waves return back
to the origin as an echo after striking on the obstacle. We can get the total time taken by the
sound waves to return to the receiver of the sensor. As speed of sound of sound is known to us
we can easily calculate the distance using the equation below.

Distance= [ Time * Speed of sound in air (340 m/s)] / 2

This calculated distance is compared in Arduino with a reference value that is 3 meters,
if the calculated distance is less than this reference signal then the buzzer is sounded.

Fig 5.5 Unseen obstacles detection flowchart

5.4 Alcohol consumption detection system


Here an MQ-3 sensor is used as the alcohol sensor, the gas sensor- MQ3 is suitable for
alcohol detecting, this sensor can be used in a breath analyser. It has a high sensitivity to alcohol
and small sensitivity to benzene. The sensitivity can be adjusted by the potentiometer sensitive

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 24

material of MQ3 gas sensor is SnO2, which with lower conductivity in clean air. When the
target alcohol gas exists, the sensors conductivity is higher along with the gas concentration
rising, use of simple electro circuit, convert change of conductivity to correspond output signal
of gas concentration. Alcohol Sensor MQ-3 gas sensor has high sensitivity to Alcohol, and has
good resistance to disturb of gasoline, smoke and vapour. It has fine sensitivity range around 2
meters. The sensor could be used to detect alcohol with different concentration. The Arduino
board is the central unit of the system, it is a programmable board based on ATmega328
microcontroller chip, and a buzzer is used for alerting.

For detecting alcohol, a digital alcohol sensor is used and if there is alcohol content in
the breath of the driver and it is greater than the allowed limit then the alarm will sound. Using
the alcohol sensor alcohol content in the driver’s breath is measured and compared with the set
value using Arduino if the value is greater than the set value then the Arduino will trigger the
alarm.

Fig 5.6 Alcohol detection flowchart

5.5 Accident Alert Messaging System

When an accident happens collision sensors in the vehicle triggers a signal and when the
airbags detect this signal and deploy, in this system the output from the collision sensor is
B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering
Adaptive lighting and Safety systems for automobiles interfacing CAN 25

tapped and given to the controller, if there is an accident the collision sensor will gives a signal
and when the controller detects this signal, it will take location coordinates from the GPS
module and send as a SMS to the emergency services and Relatives.

The most important parts of the success of the airbag system are the crash sensors. These
small pieces of electronics are designed to tell when the vehicle has been damaged in an
accident. They respond to several different sets of stimuli, including sudden stopping, increased
pressure as pieces of the car are moved due to the force of the collision, and more. Different
types of sensors measuring wheel speed, seat occupant status, brake pressure and impact, and
other vehicle status indicators are monitored by the airbag control unit located in the front
portion of the cabin. The sensors relay signals to the airbag control unit, which analyses the
data and can orchestrate safety features like seat belt lock, automatic door locks, as well as
airbag deployment. And when the Arduino detects signal from control unit it takes position
from GPS module and sends to the emergency response via GSM module.

Fig 5.7 Accident alerting system flowchart

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 26

Chapter 6
DESIGN AND DEMONSTRATION

The safety systems used in vehicles are studied and the proposed system is designed. In
designing phase, the system is divided into subsystems and it is designed, after completing the
work of subsystems they are combined. In case of headlight, halogen lamps are currently used
but since they are being replaced with LED lamps, they are used as the headlamps in prototype
and PWM is chosen as the control technique. For measuring light intensity, a light sensor is
made using a LDR and it is calibrated using a lux meter, for controlling the intensity of light a
MOSFET is used by controlling its gate pulse light intensity is varied, and IRFZ44N is selected
as the MOSFET since it has higher switching speed, gate pulse is given to the MOSFET using
an Arduino.

Fig 6.1 Adaptive Lighting

For drowsy driving detection, video of driver’s face is streamed using a camera. The
dashboard is selected as the ideal place for placing the camera. A standard quality webcam is
selected for the purpose. Raspberry pi b+ is selected as the computer for image processing with
a processing speed of 700 MHz.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 27

Fig. 6.2 Raspberry pi B+

Single-board Linux computer. Dual step-down (buck) power supply for 3.3V and
1.8V.5V supply has polarity protection, 2A fuse and hot-swap protection (so you can
plug/unplug USB without resetting the board). New USB/Ethernet controller chip.4 USB
ports.40 GPIO pins. Composite (NTSC/PAL) video now integrated into 4-pole 3.5mm
'headphone' jack. MicroSD card socket.

Alcohol detection system employs an alcohol sensor. Here MQ-3 gas sensor is used as
the alcohol sensor. The Sno2 gas present in the sensor have low conductivity in normal air, but
in the presence of alcohol the conductivity of Sno2 will increase. The change in conductivity
is detected and is measured which indicates the presence of alcohol.

Fig .6.3 Alcohol consumption & unseen obstacle detection.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 28

For object detection an ultrasound sensor, HC-04 is employed which has a moderate
range of 4 meters. The ultrasonic has two parts transmitter and receiver the transmitter sends
the ultrasonic waves and receiver receives the reflected soundwave. knowing the speed of
sound and total time taken for the wave to get reflected back we can easily calculate the
distance.

Accident alerting system needs a GPS module and a GSM module, here SIM8008 module
is used since it contains both GPS and GSM module.

(a) (b)

Fig .6.4 (a) GSM module , (b) GPS module

The proposed prototype employs Raspberry Pi B+ processor and two different Arduinos
as controllers. The raspberry pi b+ is for image processing alone because takes more processing
time and data. If we perform the remaining functions along with image processing using the
same raspberry pi processor, processing and computation activities required by the other
functions will result in lagging the raspberry pi further causing trouble in the real time
drowsiness detection using image processing. Due to this difficulty raspberry pi is employed
for image processing only. An Arduino is used for adaptive lighting system since its
functionality requires the process to be fast. Combining any other function with the same
Arduino will make the process slower which is not acceptable. A separate Arduino is used for
accident alert messaging system, unseen obstacles detection and alcohol detection together.
The complete system of the proposed prototype is shown in the figure 6.5.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 29

Fig 6.3 Proposed system prototype

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 30

Chapter 7
RESULTS AND DISCUSSION
The proposed system is prototyped and tested in various conditions. In case of adaptive
lighting intensity control is seen far more effective than conventional bright and dim light level
controlling. The system is programmed to maintain the amount of lux in front of the vehicle to
550 lux. The system maintains this value under all conditions and is working perfectly fine as
defined by the user. The alcohol consumption detection system is programmed to detect 10 mg
of ethanol per litre of each breath of the person concerned. The obstacle detection system
worked perfectly by detecting objects which is at distance of 3 metres ahead. The drowsy
driving detection system is tested under various conditions such as low light, high light, person
with glasses etc and it showed satisfactory results.

The figure 7.1 shows the normal condition or non-drowsy condition, that is the eyes are
opened. In each frame the EAR is calculated and displayed. When this value is greater than
0.28 the system will recognise the driver as not drowsy. Fig 7.2 shows the drowsiness
condition. Here EAR value is less than the threshold value and therefore the driver is considered
drowsy. The EAR is displayed in the frame and each time when this value is greater tan 0.28
drowsiness notification will appear on the screen.

Fig 7.1 Normal condition Fig 7.2 Drowsy condition

Whenever an accident occurs collision sensors detects the change in momentum from the normal
condition as a result of the force imparted by the accident. As soon as an accidents had occurred a signal
is send to the airbags in a split second to activate them. This signal can be tapped to detect whether an
accident has occurred or not. Whenever this signal is detected the arduino will extract the cordinates of
the current location using GPS module and this location is send to the emergency services using a GSM

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 31

module. Fig 7.3 shows the accident alert message recived and fig.7.4 shows the GPS location received
from the system showing the location of the accident.

Fig 7.3 Message from the accident alert system Fig 7.4 Location received

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 32

Chapter 8
CONCLUSION
8.1 Conclusion
Road accidents are undoubtedly the most frequent and, overall, the cause of the most
damage. Surveys shows that in India on an average around 400 people die a day in road
accidents. The reasons for this can be many. The situation calls for a safety system that has the
potential to practically cope with the conditions prevailing in our country regarding road
accidents and safety measures to deal with the existing scenario. The proposed prototype is
capable of functioning as a single module that can be interfaced with any vehicle as an
additional add on performing several functions such as drowsiness detection, adaptive lighting
system to provide with correct illumination to suit various real time situations, notifying
obstacles on road avoiding unwanted collisions, alcohol consumption detection system and
accident alert messaging system. The module is very economical compared to many luxurious
vehicles few of the above properties as build in functions and above all the single safety module
can ne interfaced with any existing vehicle architecture. The system thus ensures numerous
practical applications in the field of automobile safety.

8.2 Future Scope

As far as automobile safety is concerned seatbelt is major safety measure. A seatbelt is a


vehicle safety device designed to secure the occupant of a vehicle against harmful movement
that may result during a collision or a sudden stop by keeping occupants positioned correctly
for maximum effectiveness of the airbag and preventing occupants being ejected from the
vehicle in a crash or if the vehicles rolls over. The automobiles do have an inbuild seatbelt
warning system. For the driver seat the warning is by default, if the seatbelts are not engaged
an alarm buzz and will continue until the seatbelts are engaged so that the circuit is complete.
People these days are finding ways to fake this seatbelt warning system, even when knowing
that these technologies are in cooperated within automobiles for their own safety. A number of
products are available in the market for this purpose. Fig 7.2 shows an example for such
products available in the market for deactivating the seatbelt warning mechanism. An ultimate
solution to this problem is in-cooperating image processing and machine learning techniques
in seat belt detection system. These techniques will actually check for the presence of a person
with wearing seatbelts. The system can only be faked by diffusing it.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 33

Fig 8.1 Seatbelt alarm disabling devices

When driving around a curve in the road, standard headlights continue to shine straight
ahead, illuminating the side of the road and leaving the road ahead of you (curve side) in the
dark. Advanced headlights, on the other hand, turn their beams according to your steering input
so that the vehicle’s actual path is lit up. When driving on the curve road, flexible headlamps
will change the lighting pattern to compensate for the curvature of the road to help enhance
night visibility. Therefore, improves driver’s visibility during night driving by automatically
turning the headlamp in the direction of travel according to curve road and the distance between
two vehicles.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 34

REFERENCES

1] G.Ravi Kumar1, P.Suresh Kumar2, “Adaptive Front Light Systems of Vehicle for Road
Safety”2016 Conference paper on International Research Journal of Engineering and
Technology (IRJET)
[2] Ines Teyeb, Olfa Jemai, Mourad Zaied, Chokri Ben Amar, ―A Drowsy Driver Detection
System Based on a New Method of Head Posture Estimation‖, springer. International
Conference on Intelligent Data Engineering and Automated Learning. IDEAL 2014:
Intelligent Data Engineering and Automated Learning – IDEAL 2014 pp 362-369, 2014.
[3] Dubal, Priyanka, and J. D. Nanaware. "Design of adaptive headlights for
automobiles." International Journal on Recent and Innovation Trends in Computing and
Communication 3, no. 3 (2015): 1599-1603.
[4] Vural, Esra, Mujdat Cetin, Aytul Ercil, Gwen Littlewort, Marian Bartlett, and Javier
Movellan. "Drowsy driver detection through facial movement analysis." In International
Workshop on Human-Computer Interaction, pp. 6-18. Springer, Berlin, Heidelberg, 2007
[5] Sri Krishna Chaitanya Varma, Poornesh, Tarun Varma, Harsha “Automatic Vehicle
Accident Detection and Messaging system using GPS and GSM Modems”, International
Journal of Scientific & Engineering Research, Volume 4, Issue 8, August-2013 ISSN 2229-
5518.

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 35

LIST OF PUBLICATIONS

1.Tibinmon PM, Sneha Susan Abraham, Akhil S Nair, Akhil S Ashok, “Adaptive Lighting and
Safety System for Automobiles using CAN Interfacing,” IEEE ISCON 2019: 2019 IEEE
International Conference on Information Systems and computer networks, GLA University,
Mathura, India, November 21-22, 2019.

(Accepted)

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 36

Participation in Project Competitions

1. Participation “Effyis” organized by “College of Engineering Kidagoor” on “5th April 2019”

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 37

Patents
1. Patent Facilitation Forn submitted to KSCSTE

Title of Invention: Adaptive Lighting and Safety System for Automobiles using CAN
Interfacing

Name of Applicants: Er. Arun Sebastian


Akhil S Ashok (MGP15EE003)
Akhil S Nair (MGP15EE004)
Sneha Susan Abraham (MGP15EE047)
Tibinmon P M (MGP15EE049)

Name of Inventors: Er. Arun Sebastian


Akhil S Ashok (MGP15EE003)
Akhil S Nair (MGP15EE004)
Sneha Susan Abraham (MGP15EE047)
Tibinmon P M (MGP15EE049)

Submission date :11/04/2019

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 38

APENDIX
1.Code for image processing
from scipy.spatial import distance as dist
from imutils.video import VideoStream
from imutils import face_utils
from threading import Thread
import numpy as np
import playsound
import argparse
import imutils
import time
import dlib
import cv2

def sound_alarm(path):

playsound.playsound(path)

def eye_aspect_ratio(eye):

A = dist.euclidean(eye[1], eye[5])
B = dist.euclidean(eye[2], eye[4])

C = dist.euclidean(eye[0], eye[3])

ear = (A + B) / (2.0 * C)

return ear

ap = argparse.ArgumentParser()
ap.add_argument("-p", "--shape-predictor", required=True,
help="path to facial landmark predictor")
ap.add_argument("-a", "--alarm", type=str, default="",
help="path alarm .WAV file")
ap.add_argument("-w", "--webcam", type=int, default=0,
help="index of webcam on system")
args = vars(ap.parse_args())

EYE_AR_THRESH = 0.28
EYE_AR_CONSEC_FRAMES = 10

COUNTER = 0
ALARM_ON = False

print("[INFO] loading facial landmark predictor...")


detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(args["shape_predictor"])

(lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"]


(rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye"]

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 39

print("[INFO] starting video stream thread...")


vs = VideoStream(src=args["webcam"]).start()
time.sleep(1.0)
while True:

frame = vs.read()
frame = imutils.resize(frame, width=450)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
rects = detector(gray, 0)
for rect in rects:

shape = predictor(gray, rect)


shape = face_utils.shape_to_np(shape)

leftEye = shape[lStart:lEnd]
rightEye = shape[rStart:rEnd]
leftEAR = eye_aspect_ratio(leftEye)
rightEAR = eye_aspect_ratio(rightEye)

ear = (leftEAR + rightEAR) / 2.0

leftEyeHull = cv2.convexHull(leftEye)
rightEyeHull = cv2.convexHull(rightEye)
cv2.drawContours(frame, [leftEyeHull], -1, (0, 255, 0), 1)
cv2.drawContours(frame, [rightEyeHull], -1, (0, 255, 0), 1)
if ear < EYE_AR_THRESH:
COUNTER += 1
if COUNTER >= EYE_AR_CONSEC_FRAMES:

if not ALARM_ON:
ALARM_ON = True
if args["alarm"] != "":t = Thread(target=sound_alarm,args=(args["alarm"],))
t.deamon = True
t.start()
cv2.putText(frame, "DROWSINESS ALERT!", (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
else:
COUNTER = 0
ALARM_ON = False

cv2.putText(frame, "EAR: {:.2f}".format(ear), (300, 30),


cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)

cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF

if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()

2.Code for Adaptive Light


void setup()
{
B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering
Adaptive lighting and Safety systems for automobiles interfacing CAN 40

pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop()
{
float a,b;
a=analogRead(A0);
Serial.println(a);
a=1020-a;
analogWrite(9,a/4);
}

3.Code for Accident alerting, Unseen obstacles detection, Alcohol consumption


detection

#include <TinyGPS.h>
#include <SoftwareSerial.h>
SoftwareSerial Gsm(7, 8);
char phone_no[] = "9495463704";

TinyGPS gps;

void setup()
{
Serial.begin(9600);
Gsm.begin(9600);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}

void loop()
{

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 41

bool newData = false;


unsigned long chars;
unsigned short sentences, failed;

for (unsigned long start = millis(); millis() - start < 1000;)


{
while (Serial.available())
{
char c = Serial.read();
Serial.print(c);
if (gps.encode(c))
newData = true;
}
}

if (newData)
{
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Gsm.print("AT+CMGF=1\r");
delay(400);
Gsm.print("AT+CMGS=\"");
Gsm.print(phone_no);
Gsm.println("\"");

delay(300);
Gsm.print("http://maps.google.com/maps?q=loc:");

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering


Adaptive lighting and Safety systems for automobiles interfacing CAN 42

// Gsm.print("Latitude = ");
Gsm.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
//Gsm.print(" Longitude = ");
Serial.print(",");
Gsm.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
delay(200);
Gsm.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(200);
Gsm.println();
delay(20000);

Serial.println(failed);

}
}
void loop()
{
float c,d;
c=analogRead(A1);
Serial.println(c);
if(c<550)
{
digitalWrite(10,1);
digitalWrite(11,0);
}
else
{
digitalWrite(10,0);
B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering
Adaptive lighting and Safety systems for automobiles interfacing CAN 43

}
d=analogRead(A2);
Serial.println(d);
if(c>550)
{
digitalWrite(10,1);
digitalWrite(11,0);
}
else
{
digitalWrite(10,0);
}

B.Tech. Electrical and Electronics Engineering. SAINTGITS College of Engineering

Vous aimerez peut-être aussi