You are on page 1of 39

PROJECT PHASE- III REPORT

INTELLIGENT TRAFFIC LIGHT SYSTEM


USING DIGITAL IMAGE PROCESSING
Submitted By:
Nitin Tomar (Roll no.: 120070102074)
Shweta (Roll no.: 120070102114)
Smita Kumari (Roll no.: 120070102117)
Vandana Manral (Roll no.: 120070102121)
B.tech ECE B, 4th year

Under the supervision of:


Mr. Amrindra Pal Mr. Anuj Sharma
Assistant Professor Assistant Professor

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING


DEHRADUN INSTITUTE OF TECHNOLOGY, DEHRADUN
(An Autonomus institute Affiliated to Uttrakhand Technical University,Dehradun)
Uttarakhand-248009
(MARCH-2016)
DECLARATION
We hereby declare that the project phase-III work entitled “INTELLIGENT TRAFFIC LIGHT
SYSTEM USING DIGITAL IMAGE PROCESSING” is authentic record of our own work
carried out at as requirement for the award of degree of bachelor in the Technology in Electronics
and Communication Engineering from Uttarakhand Technical university Dehradun under the
supervision of our project guide Mr. Amrindra Pal sir and our project coordinator Mr. Anuj
Sharma Sir. During Jan-March 2016.

Nitin Tomar
(Roll no.: 120070102074)

Shweta
(Roll no.: 120070102114)

Smita Kumari
(Roll no.: 120070102117)

Vandana Manral
(Roll no.: 120070102121)

Date: 18 March 2016

It is certified that the above statement made by the student is correct to the best of our knowledge
and belief.

Mr. Amrindra pal Mr. Anuj Sharma Dr. Sandeep Sharma


(Project Guide) (Project Coordinator) (HOD ECE & AEI)
ACKNOWLEDGEMENT
I take the opportunity to express my gratitude to all of them who in some or other way helped me
to accomplish this Project "INTELLIGENT TRAFFIC LIGHT SYSTEM USING DIGITAL
IMAGE PROCESSING”. No amount of written expression is sufficient to show my deepest sense
of gratitude to them. I am very thankful to Mr. Anuj Sharma sir and our supervisor Mr. Amrindra
Pal, and very grateful to Dehradun Institute of Technology, Dehradun for their everlasting support
and guidance on the ground of which I have acquired a new field of knowledge. The course
structure created for this curriculum has benefited with the inclusion of recent development in the
organizational and technical aspects.
INDEX
1. Profile of the problem
2. Existing system
2.1 Introduction
2.2 Existing Software
2.3 DFD for present system
2.4 What’s new in the system to be developed
3. Problem analysis
3.1 Product definition
3.2 Project plan
4. Software requirement analysis
4.1 Introduction
4.2 General Description
4.3 Specific Requirements
5. Design
5.1 System design
5.2 Design notations
5.3 Detail Design
5.4 Flowcharts
5.5 Pseudo Code
6. Testing
7. Implementation
7.1 Implementation of the project
8. Project Legacy
8.2 Current status of the project
8.2 Remaining area of concern
8.3Technical and Managerial lesson learn

9. Conclusion

10. Reference
1. Profile of the problem

The traffic light that are in widespread now a days are not sufficient enough when to change
traffic light to various road lanes for users waiting in those lanes to cross the road. How long the
signal stays geen in one lane and red in another is most often determined by simple timing that is
calculated when the crossing is designed. Even though today’s methods are robust and work well
when the traffic is load id distributed over evenly across the lanes in the intersection, the systems
are very inefficient because they are unable to handle various simple situation that arise
throughout the day. Unnecessary waiting time in the signal can be avoided by determining in
which side the green signal should be large during the traffic. Due to the massive growth in
urbanization and traffic congestion, intelligent vision based traffic light controller is needed to
reduce the traffic delay and travel time especially in developing countries as the current automatic
time based control is not realistic while sensor based traffic light controller is not reliable in
developing countries. The major cause leading to traffic jam is the high number of vehicle which
was caused by the population and the development of economy.

This problem considers as the biggest problem in traffic system. As we can see that in
metropolitan cities this can be lead to traffic jam because currently there is no available traffic
light system which work according to the traffic density. The idea of controlling the traffic light
efficiently in real time has attracted many researchers to work in this field with the goal of
creating automatic tool that can estimate the traffic congestion and based on this Variable, the
traffic sign time interval is forecasted.
2. Existing system
2.1 Introduction

Some of the researchers have focused in their work on traffic flow estimation. It is measured as
the rate at which vehicles pass a fixed point (e.g. vehicles per minute). They used spot sensors
such as loop detectors and pneumatic sensors to quantify the traffic flow However; the sensors are
very expensive and need a lot of maintenance especially in developing countries because of the
road ground de-formations. In addition, metal barriers near the road might prevent effective
detection using radar sensors. The inadequate infrastructure cannot handle the issue of traffic is
also a decisive reason.

2.2 Standard Traffic Control Systems:

2.2.1 Manual Controlling

Manual controlling the name instance it require man power to control the traffic. Depending on
the countries and states the traffic polices are allotted for a required area or city to control
traffic. The traffic polices will carry sign board, sign light and whistle to control the traffic.
They will be instructed to wear specific uniforms in order to control the traffic.

2.2.2 Automatic Controlling

Automatic traffic light is controlled by timers and electrical sensors. In traffic light each phase a
constant numerical value loaded in the timer. The lights are automatically getting ON and
OFF depending on the timer value changes. While using electrical sensors it will capture the
availability of the vehicle and signals on each phase, depending on the signal the light
automatically switch ON and OFF.

2.2.3 Drawback of manual and automatic controlling

In the manual controlling system we need more man power. As we have poor strength of traffic
police we cannot control traffic manually in all area of a city or town. So we need a better
solution to control the traffic. On the other side, automatic traffic controlling a traffic light uses
timer for every phase. Using electronic sensors is another way in order to detect vehicles, and
produce signal that to this method the time is being wasted by a green light on an empty road.
Traffic congestion also occurred while using the electronic sensors for controlling the traffic.
All these drawbacks are supposed to be eliminated by using image processing.
2.2.4 Intelligent Traffic Light Flow Control System Using Fuzzy Logic Technology

This method described a solution to road traffic problems in large cities through the design and
implementation of an intelligent system; based on fuzzy logic technology to monitor and control
traffic light system. The authors will show how the new fuzzy logic traffic control system for “+”
junction, eliminated the problems observed in the manual and conventional traffic control system
through the simulation software developed using Java programming language.
A novel methodology was described in this work for the design and implementation of the
intelligent traffic lights control system. This methodology was obtained as a hybrid of two
standard methodologies: The Structured System Analysis and Design Methodology (SSADM)
and the Fuzzy Based Design Methodology. The systems study and preliminary design was carried
out using the Structured System Analysis and Design Methodology and it replaced the first step
of the Fuzzy Based Design Methodology. The Fuzzy Logic-based methodology was chosen as the
paradigm for an alternative design methodology; applied in developing both linear and non-linear
systems for embedded control. Therefore, the physical and logical design phases of the SSADM
were replaced by the two steps of the Fuzzy Logic-based methodology to complete the crossing
of the two methodologies. A hybrid methodology was necessary because there was a need to
examine the existing systems, classify the intersections as “Y” and “+” junction with the view of
determining the major causes of traffic deadlock on road junction. There was also the need to
design the traffic control system using fuzzy rules and simulation to implement an intelligent
traffic control system that will eliminate logjam.
Based on the analysis of the present traffic control system, the following assumptions became
necessary in order to develop a feasible system:
1. The system will only work for an isolated four-way junction with traffic coming from the four
cardinal directions.
2. Traffic only moves from the North to the South and vice versa at the same time; and at this
time, the traffic from the East and West is stopped. In this case, the controller considers the
combination of all the waiting densities for the North and south as that of one side and those of
the east and west combined as another side.
3. Turns (right and left) are considered in the design
4. The traffic from the west lane always has the right of way and the west-east lane is considered
as the main traffic.
2.3 Data flow diagram for present Intelligent Traffic Light Flow
Control System Using Fuzzy Logic Technology
2.4 What’s new in the system to be developed?

We propose a system for controlling the traffic light by image processing. The system will detect
vehicles through images instead of using electronic sensors embedded in
the pavement. A camera will be installed alongside the trafficlight. It will capture image
sequences. Image processing is a better technique to control the state change of the traffic light. It
shows that it can reduce the traffic congestion and avoids the time being wasted by a green light
on an empty road. It is also more consistent in detecting vehicle presence because it uses actual
traffic images. It visualizes the reality so it functions much better than those systems that rely on
the detection of the vehicles’ metal conten
3. Problem analysis
Traffic congestion has a number of negative effects:

 Wasting time of motorists and passengers ("opportunity cost"). As a non-productive activity


for most people, congestion reduces regional economic health.
 Delays, which may result in late arrival for employment, meetings, and education, resulting
in lost business, disciplinary action or other personal losses.
 Inability to forecast travel time accurately, leading to drivers allocating more time to travel
"just in case", and less time on productive activities.
 Wasted fuel increasing air pollution and carbon dioxide emissions owing to increased idling,
acceleration and braking.
 Wear and tear on vehicles as a result of idling in traffic and frequent acceleration and
braking, leading to more frequent repairs and replacements.
 Stressed and frustrated motorists, encouraging road rage and reduced health of motorists
 Emergencies: blocked traffic may interfere with the passage of emergency vehicles traveling
to their destinations where they are urgently needed.
 Spill over effect from congested main arteries to secondary roads and side streets as
alternative routes are attempted ('rat running'), which may affect neighbourhood amenity
and real estate prices.
 Higher chance of collisions due to tight spacing and constant stopping-and-going.

3.1 Some important effects


3.1.1 Delay
The first thing many people think of when it comes to congested roadways is the delay. During
the morning commute there is additional stress because delays caused by traffic can make people
late for work. And at the end of the day, the afternoon rush hour is again a frustrating time
because the workday is done and people want to get home to relax, and traffic is preventing it.
These delays are the effects most people feel because they are universal to everyone who has to
makeover through congested roads.
3.1.2 "Just In Case" Time

A secondary effect of traffic congestion related to delays is the inability to estimate travel times.
Those who regularly travel congested areas know approximately how long it usually takes to get
through a particular area depending on the time of day or the day of the week. These experienced
city drivers have to build in time "just in case" the traffic is bad. This takes away from leisure
time and time to do other tasks throughout the day. Also, on a day when the traffic is unusually
light the built in extra time may be of no use and the person arrives too early.

3.1.3 Fuel consumption and pollution

The stopping and starting in traffic jams burns fuel at a higher rate than the smooth rate of travel
on the open highway. This increase in fuel consumption costs commuters additional money for
fuel and it also contributes to the amount of emissions released by the vehicles. These emissions
create air pollution and are related to global warming.

3.1.4 Road Rage

Road rage is a senseless reaction to traffic that is common in congested traffic areas. If someone
is not driving as fast as the person behind him thinks he should, or someone cuts in front of
someone else it can lead to an incident that is dangerous to the offender and those around him on
the road. Road rage often manifests itself as shouting matches on the road, intentional tailgating,
retaliatory traffic makeovers and mostly a lack of attention being paid to the traffic around the
people involved. It is basically a temper tantrum by frustrated drivers in traffic.

3.1.5 Emergency Vehicles

When you dial 101 and request a police officer, an ambulance or a fire truck and the emergency
vehicle is unable to respond in an appropriate amount of time because of traffic congestion it can
be a danger to you and your property. Systems are available that help alleviate the problem by
allowin g the emergency crews to automatically change the traffic lights to keep the line moving.
Comparatively urbanization is moderate in India. The urban population has grown from ten
percent in 1901 to twenty eight percent in 2001. The skewed distribution of the urban population
amongst a few cities is a matter of concern to the planners and administrators of urban
infrastructure. Nearly seventy percent of the urban population is located in Class-I cities
(population of one hundred thousand and more). Further 38 percent of the total urban population
is located in metropolitan cities (population of one million and more) numbering about thirty-
five. This heavy concentration of population in a few centres has resulted in the expansion of
cities in density as well as area. With the increase in population and economic activities the
travel demand has increased many folds. The inadequate public transport and the easy
availability of financing facilities for private vehicles have resulted in increased vehicle
ownership levels and their usage. Further, the changes in urban form and structure in terms of
land use, density of population and concentration of activities have changed the travel pattern. In
other words the traffic problems are increasing in the cities in general and the situation is
becoming complex especially in core areas of the city.

3.1.6 Limitations of Existing system


1. Heavy Traffic Jams with increasing number of vehicles on road, heavy traffic congestion has
substantially increased in major cities. This happened usually at the main junctions commonly in
the morning, before office hour and in the evening, after office hours. The main effect of this
matter is increased time wasting of the people on the road.

2. No traffic, but still need to wait at certain junctions, sometimes even if there is no traffic,
people have to wait. Because the traffic light remains red for the present time period, the road
users should wait until the light turn to green.

3.2 Product Definition


Objective of proposed system is to improve efficiency of existing automatic traffic signalling
system. As we know the population of city and number of cars is increasing day by day. With
increasing urban population and hence the number of cars, need of controlling streets, highways
and roads is vital. The system will be image processing based adaptive signal controlling. The
timing will be calculated each time change automatically depending upon the traffic load.
Proposed system will functioning based on traditional system along with automated signalling.
System will have artificial vision with the help of digital camera mounted on motor for its
rotation to face lanes and sense the traffic on the road result the number of cars in three way road
is calculated and then compared which way is highly dense, medium dense. In this project, a
system that estimates the size of traffic in highways by using image processing has been
proposed and as a and less dense on the basis of this comparison we controlled the traffic lights.
This single image of lane will be processed using image processing techniques to estimate traffic
load. Estimated traffic load on particular road will be used to calculate the required time duration
for controlling of signal lights based on in comparison with experimental results. System will be
intelligent and will calculate the time every time and operate in a cyclic clockwise signal lights
control. Maximum and minimum time limit will be maintained to prevent over waiting of vehicle
in queue of other lanes which would be found out experimentally. Controls of the signal will be
routed through the microcontroller. MATLAB programming environment will be used for
simulating and developing the proposed system. This project has been implemented by using the
Matlab software and microcontroller and aims to prevent heavy traffic in roads.

4. Software requirement analysis


4.1 Introduction

Matlab:

MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and fourth-


generation programming language. A proprietary programming language developed by Math
Works, MATLAB allows matrix manipulations, plotting of functions and data, implementation
of algorithms, creation of user interfaces, and interfacing with programs written in other
languages, including C, C++, Java, Fortran and Python.

Although MATLAB is intended primarily for numerical computing, an optional toolbox uses
the MuPAD symbolic engine, allowing access to symbolic computing capabilities. An additional
package, Simulink, adds graphical multi-domain simulation and model-based
design for dynamic and embedded systems, science, and economics.

In our system we are using image processing tool of MATLAB 2009a.

Image Processing Toolbox provides a comprehensive set of reference-standard algorithms


functions, and apps for image processing, analysis, visualization, and algorithm development.
You can perform image analysis, image segmentation, image enhancement, noise reduction,
geometric transformations, and image registration. Many toolbox functions support multicore
processors, GPUs, and C-code generation.

Image Processing Toolbox supports a diverse set of image types, including high dynamic range,
gig pixel resolution, embedded ICC profile, and tomographic. Visualization functions and apps
let you explore images and videos, examine a region of pixels, adjust colour and contrast, create
contours or histograms, and manipulate regions of interest (ROIs). The toolbox supports
workflows for processing, displaying, and navigating large images.

Eclipse:
In computer programming, Eclipse is an integrated development environment (IDE). It contains
a base workspace and an extensible plug-in system for customizing the environment. Eclipse is
written mostly in Java and its primary use is for developing Java applications, but it may also be
used to develop applications in other programming languages through the use of plugins,
including: Ada, ABAP, C, C++, COBOL, Fortran, Haskell, JavaScript, Julia,[2] Lasso, Lua, NAT
URAL, Perl, PHP,Prolog, Python, R, Ruby, Scala, Clojure, Groovy, Scheme, and Erlang. It can
also be used to develop packages for the software Mathematica. Development environments
include the Eclipse Java development tools (JDT) for Java and Scala, Eclipse CDT
for C/C++ and Eclipse PDT for PHP, among others.
The initial codebase originated from IBM VisualAge. The Eclipse software development
kit (SDK), which includes the Java development tools, is meant for Java developers. Users can
extend its abilities by installing plug-ins written for the Eclipse Platform, such as development
toolkits for other programming languages, and can write and contribute their own plug-in
modules.
Released under the terms of the Eclipse Public License, Eclipse SDK is free and open-source
software (although it is incompatible with the GNU General Public License). It was one of the
first IDEs to run under GNU Classpath and it runs without problems under IcedTea.
Proteus:
Proteus (PROcessor for TExt Easy to USe) is a fully functional, procedural programming
language created in 1998 by Simone Zanella. Proteus incorporates many functions derived from
several other languages: C, BASIC, Assembly, Clipper/dBase; it is especially versatile in dealing
with strings, having hundreds of dedicated functions; this makes it one of the richest languages
for text manipulation.
Proteus owes its name to a Greek god of the sea (Proteus), who took care of Neptune's crowd and
gave responses; he was renowned for being able to transform himself, assuming different shapes.
Transforming data from one form to another is the main usage of this language.

4.2 General description


A general description of image processing is given below:

Exploration and Discovery

Image Processing Toolbox supports images and video generated by a wide range of devices,
including webcams, digital cameras, satellite and airborne sensors, medical imaging devices,
microscopes, telescopes, and other scientific instruments. You can use functions and apps to
visualize, analyse, and process these images in many data types.

With Image Acquisition Toolbox you can acquire live images and video from frame grabbers,
GigE Vision cameras, DCAM cameras, and other devices.

Image Enhancement

Image enhancement techniques in Image Processing Toolbox enable you to increase the signal-
to-noise ratio and accentuate image features by modifying the colors or intensities of an image.

The toolbox includes specialized filtering routines and a generalized multidimensional filtering
function that handles integer image types, offers multiple boundary-padding options, and
performs convolution and correlation.

Using predefined filters and functions you can:

 Filter with morphological operators


 Deblur and sharpen
 Remove noise with linear, median, or adaptive filtering
 Perform histogram equalization
 Remap the dynamic range
 Adjust the gamma value
 Adjust contrast

Enhancing Multispectral Colour Composite Images (Example) Constructing colour composites


to highlight and segment vegetation in satellite imagery.

Morphological Operators

Morphological operators enable you to enhance contrast, remove noise, thin regions, or perform
skeletonization on regions. Morphological functions in Image Processing Toolbox include:

 Dilation and erosion


 Opening and closing

Image Deblurring

Image deblurring algorithms in Image Processing Toolbox include blind, Lucy-Richardson,


Wiener, and regularized filter deconvolution as well as conversions between point spread and
optical transfer functions. These functions help correct blurring caused by out-of-focus optics,
movement by the camera or the subject during image capture, atmospheric conditions, short
exposure time, and other factors. All deblurring functions work with multidimensional images.

Use the deconvwnr function to deblur an image using the Wiener filter. Wiener deconvolution
can be used effectively when the frequency characteristics of the image and additive noise are
known, to at least some degree. In the absence of noise, the Wiener filter reduces to the ideal
inverse filter.

This example deblurs the blurred image created in Deblurring Model, specifying the same PSF
function that was used to create the blur. This example illustrates the importance of knowing the
PSF, the function that caused the blur. When you know the exact PSF, the results of deblurring
can be quite effective.
Deblurring Images Using the Blind Deconvolution Algorithm (Example) Restoring an image
when no information about the distortion is available.

Image Transforms

Image transforms play a critical role in many image processing tasks, including image
enhancement, analysis, restoration, and compression. Image Processing Toolbox provides
several image transforms, including Hough, Radon, FFT, DCT, and fan-beam projections. You
can reconstruct images from parallel-beam and fan-beam projection data (common in
tomography applications).

Image transforms are also available in MATLAB and Wavelet Toolbox.

Reconstructing an Image from Projection Data (Example) Comparing the reconstruction of an


image using parallel (Radon) and fan-beam geometries

Image Segmentation

Image segmentation algorithms determine region boundaries in an image. You can explore many
different approaches to image segmentation, including progressive methods, automatic
thresholding, edge-based methods, and morphology-based methods such as the watershed
transform that is often used to segment connected objects.
Color-Based Segmentation with Live Image Acquisition acquire an image and perform image
analysis to find small objects, count them, and differentiate them by color

Edge Detection

Edge-detection algorithms let you identify object boundaries in an image. These algorithms
include the Sobel, Prewitt, Roberts, Canny, and Laplacian of Gaussian methods. The Canny
method can detect true weak edges without being fooled by noise.

Fig: - Detecting a Cell Using Edge Detection

Morphological Operators

Morphological operators enable you to detect edges, segment an image into regions, or perform
skeletonization on regions. Morphological functions in Image Processing Toolbox include:

 Erosion
IM2 = imerode (IM,SE) erodes the grayscale, binary, or packed binary image IM, returning the
eroded image IM2. The argument SE is a structuring element object or array of structuring
element objects returned by the strel function.

If IM is logical and the structuring element is flat, imerode performs binary erosion; otherwise it
performs grayscale erosion. If SE is an array of structuring element objects, imerode performs
multiple erosions of the input image, using each structuring element in SE in succession.

IM2 = imerode (IM, NHOOD) erodes the image IM, where NHOOD is an array of 0's and 1's
that specifies the structuring element neighbourhood. This is equivalent to the syntax imerode
(IM, strel (NHOOD)). The imerode function determines the centre element of the neighbourhood
by floor ((size(NHOOD)+1)/2)

IM2 = imerode (...,PACKOPT,M) specifies whether IM is a packed binary image and, if it is,
provides the row dimension M of the original unpacked image. PACKOPT can have either of the
following values. Default value is enclosed in braces ({})

 Dilation

IM2 = imdilate(IM, SE) dilates the grayscale, binary, or packed binary image IM, returning the
dilated image, IM2. The argument SE is a structuring element object, or array of structuring
element objects, returned by the strel function. If IM is logical and the structuring element is flat,
imdilate performs binary dilation; otherwise, it performs grayscale dilation. If SE is an array of
structuring element objects, imdilate performs multiple dilations of the input image, using each
structuring element in SE in succession. IM2 = imdilate(IM, NHOOD) dilates the image IM,
where NHOOD is a matrix of 0's and 1's that specifies the structuring element neighborhood.
This is equivalent to the syntax imdilate(IM,strel(NHOOD)). The imdilate function determines
the center element of the neighborhood by floor((size(NHOOD)+1)/2). IM2 = imdilate(IM, SE,
PACKOPT) or imdilate(IM,NHOOD,PACKOPT) specifies whether IM is a packed binary
image. PACKOPT can have either of the following values. Default value is enclosed in braces
({}).
4.3 Specific requirement
Specific Functions used for Image Processing

Function Description
Clc This MATLAB function clears all input and
output from the Command Window display,
giving you a clean screen
clear all This MATLAB function clears all objects in
the MATLAB workspace and closes the
MuPAD engine associated with the MATLAB
workspace resetting all its assumptions

Imread This MATLAB function reads a grayscale or


color image from the file specified by the
string filename
Imshow This MATLAB function displays the image I
in a Handle Graphics figure, where I is a
grayscale, RGB (truecolor), or binary image
rgb2gray This MATLAB function converts the truecolor
image RGB to the grayscale intensity image

im2bw This MATLAB function converts the grayscale


image I to a binary image
Imcomplement This MATLAB function computes the
complement of the image
Imopen This MATLAB function performs
morphological opening on the grayscale or
binary image IM with the structuring element
Imerode This MATLAB function erodes the grayscale,
binary, or packed binary image IM, returning
the eroded image
Imfill This MATLAB function displays the binary
image BW on the screen and lets you define
the region to fill by selecting points
interactively by using the mouse
Bwlabel This MATLAB function returns a matrix L, of
the same size as BW, containing labels for the
connected objects in BW
disp() This MATLAB function displays the contents
of X without printing the variable name

5. Design

5.1 System design

MICROCONTROLLER:

A microcontroller is a small computer (SoC) on a single integrated circuit containing a processor


core, memory, and programmable input/output peripherals. Program memory in the form
of Ferroelectric RAM, NOR flash or OTP ROM is also often included on chip, as well as a
typically small amount of RAM. Microcontrollers are designed for embedded applications, in
contrast to the microprocessors used in personal computers or other general purpose applications.

Microcontrollers are used in automatically controlled products and devices, such as automobile
engine control systems, implantable medical devices, remote controls, office machines,
appliances, power tools, toys and other embedded systems. By reducing the size and cost
compared to a design that uses a separate microprocessor, memory, and input/output devices,
microcontrollers make it economical to digitally control even more devices and processes. Mixed
signal microcontrollers are common, integrating analog components needed to control non-
digital electronic systems.

Some microcontrollers may use four-bit words and operate at clock rate frequencies as low as 4
kHz, for low power consumption (single-digit mill watts or microwatts). They will generally
have the ability to retain functionality while waiting for an event such as a button press or other
interrupt; power consumption while sleeping (CPU clock and most peripherals off) may be just
nanowatts, making many of them well suited for long lasting battery applications. Other
microcontrollers may serve performance-critical roles, where they may need to act more like
a digital signal processor (DSP), with higher clock speeds and power consumption.

5.2 Design notation

High-performance, Low-power AVR 16-bit Microcontroller


Advanced RISC Architecture
- 131 Instructions - Most Single Clock Cycle Execution
- 32 x 8 General Purpose Working Registers
- Up to 16 MIPS Throughput at 16MHz
- Fully Static Operation
- On-chip 2-cycle Multiplier
Non-Volatile Program and Data Memories
- 16k Bytes of In-System Self-Programmable Flash
- Optional Boot Code Section with Independent Lock Bits
- 512 Bytes EEPROM
- Programming Lock for Software Security
JTAG Interface
- Boundary-scan Capabilities According to the JTAG Standard
- Extensive On-chip Debug Support
- Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
Peripheral Features
- On-chip Analog Comparator
- Programmable Watchdog Timer with Seperate On-chip Oscillator
- Master/Slave SPI Serial Interface
- Two 8-bit Timer/Counters with Separate Prescalar, Compare
- One 16-bit TImer/Counter with Seperate Prescaler, Compare and Capture mode
- Real Time Counter with Seperate Oscillator
- Four PWM Channels
- Programmable Serial USART
- 8-channel, 10-bit ADC
- Byte-oriented Two-wire Serial Interface
Special Microcontroller Features
- Power-on Reset and Programmable Brown-out Detection
- Internal Calibrated RC Oscillator
- External and Internal Interrupt Sources
- Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and
Extended Standby
I/O and Packages
- 32 Programmable I/O Lines
- 40-pin PDIP, 44-lead TQFP, and 44-pad MLF
Operating Voltages
- 4.5-5.5V for ATmega16
Speed Grades
- 0-16MHz for ATmega16
Power Consumption at 4 Mhz, 3V, 35 °C
- Active: 1.1mA
- Idle Mode: 0.35mA
- Power-down Mode: < 1µA

5.3 Pin layout


Pin diagram of atmega16:

Fig:- pin diagram of microcontroller atmega 16

VCC Digital supply voltage.

GND Ground.

Port A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter.
Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins
can provide internal pull-up resistors (selected for each bit). The Port A output buffers have
symmetrical
drive characteristics with both high sink and source capability. When pins PA0 to PA7
are used as inputs and are externally pulled low, they will source current if the internal pull-up
resistors are activated. The Port A pins are tri-stated when a reset condition becomes active,
even if the clock is not running.

Port B (PB7..PB0) Port B is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The
Port B output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset condition becomes active,
even if the clock is not running.

Port C (PC7..PC0) Port C is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port C output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port C pins that are externally pulled low will
source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset condition becomes active,
even if the clock is not running. If the JTAG interface is enabled, the pull-up resistors on pins
PC5(TDI), PC3(TMS) and PC2(TCK) will be activated even if a reset occurs.

Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port D output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port D pins that are externally pulled low will
source current if the pull-up
resistors are activated. The Port D pins are tri-stated when a reset condition becomes active,even
if the clock is not running.

5.4 Detailed design


In this architecture camera is placed on the top of the signal to get the clear view of traffic on the
particular side of the signal so that it will capture the image and analyse the traffic in that
particular side and get the count of the number of vehicle. With this count the density of that
particular side will be determined and corresponding signal will be provided.

Moreover, for implementing this project following steps must be considered:

IMAGE PROCESSING: MICROCONTROLLER:

1) Image acquisition 1) Controlling traffic lights

2) RGB to greyscale transformation

3) Morphological operations

At first, video of highway is captured by a cameras has been installed in highway. Then, the
video comes in the form of consecutive images and each image is compared with the reference
image. After that, the number of cars in highways is specified. At the end, comparison made on
the basis of numbers of cars and traffic lights are controlled by microcontroller
5.5 Flowchart
Start

Three inputs from three (ways A,B,C)

yes no
A>C A>B
B>C

Traffic A goes green(go)Traffic B & C


goes yellow For 30sec

After 20sec comparison between B & C

yes no
B>C

Traffic C goes green(go) Traffic A goes red(stop)


Traffic B goes green(go) Traffic A goes red(stop) & &
Traffic C goes yellow(wait)For 30seca Traffic B goes yellow(wait)For 30sec

After 30sec Traffic C goes green(go), Traffic A After 30sec Traffic B goes green (go), Traffic
& B goes red(stop) A & C goes red(stop)

HALT HALT
Start

Acquire reference image from video

RGB to GRAYSCALE

Image enhancement operations

Acquire test image from video

RGB to GRAYSCALE

Image enhancement operations

Img=Subtract reference image from test image

Store pixel density of Img into some variable

Input this to microcontroller

Stop
5.5 Pseudo code
Matlab code:

clc
clear all
a=imread('C:\Users\dell\Desktop\car1.jpg');
figure,imshow(a);
i=rgb2gray(a);
b=imadjust(i);
figure,imshow(i);
figure,imshow(b);
background =imopen(b,strel('disk',15));
c = b - background;
figure,imshow(c);
d = imadjust(c);
figure,imshow(d);
level = graythresh(d);
bw = im2bw(d,level);
bw = bwareaopen(bw, 200);
figure,imshow(bw);
[bw num]=bwlabel(bw,8);
disp(num)

Microcontroller code:

#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRA=255;
DDRB=255;
DDRC=255;
while(1)
{
if(A>B&&A>C) //CASE 1
{
PORTA=0b01000000; //yellow
_delay_ms(5000);
PORTA=0b00100000; //green
PORTB=0b10000000; //red
PORTC=0b10000000; //red
_delay_ms(60000);
PORTA=0b10000000; //red
PORTB=0b10000000; //red
PORTC=0b10000000; //red
_delay_ms(5000);

if (B>C)
{
PORTB=0b01000000;
_delay_ms(5000);
PORTB=0b00100000;
PORTA=0b10000000;
PORTC=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
}
else
{
PORTC=0b01000000;
_delay_ms(5000);
PORTC=0b00100000;
PORTB=0b10000000;
PORTA=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
}
}

if(B>A&&B>C) //CASE 2
PORTB=0b01000000;
_delay_ms(5000);
PORTB=0b00100000;
PORTA=0b10000000;
PORTC=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
if (A>C)
{
PORTA=0b01000000;
_delay_ms(5000);
PORTA=0b00100000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
}
else
{
PORTC=0b01000000;
_delay_ms(5000);
PORTC=0b00100000;
PORTB=0b10000000;
PORTA=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
}

if(C>A&&C>B) //CASE 3
{
PORTC=0b01000000;
_delay_ms(5000);
PORTC=0b00100000;
PORTA=0b10000000;
PORTB=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
if (C>A)
{
PORTC=0b01000000;
_delay_ms(5000);
PORTC=0b00100000;
PORTA=0b10000000;
PORTB=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
}
else
{
PORTA=0b01000000;
_delay_ms(5000);
PORTA=0b00100000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(60000);
PORTA=0b10000000;
PORTB=0b10000000;
PORTC=0b10000000;
_delay_ms(5000);
}
}

}
}

6. Testing
7. Implementation
7.1 Implementation of the project

Fig no. 7.1.1:-Acquired Traffic Image To Be Processed

Fig no. 7.1.2:-rgb to grey converted image


Fig no. 7.1.3:-enhanced image

Fig no. 7.1.4:-morphological operation to estimate the background


Fig no. 7.1.5:-more enhanced image

Fig no. 7.1.5:-final image containing only required image


8. Project legacy
8.1 Current status of project
 Counted the number of vehicles in order to compare which side is highly densed, medium
densed and less densed.

 Study of microcontroller ATMEGA 16 is done.

8.2 Remaining area of concern


 How to interface MATLAB software with hardware

 How to reduce processing time

8.3 Technical and managerial lesson learn


 MATLAB Software(image processing toolbox

 ATMEGA 16 microcontroller
9. Conclusion

Automatic traffic density estimation and traffic control through image processing plays an
important role for traffic management in mega cities. Traffic congestion is becoming a serious
issue. There are many reasons for traffic congestion situations like inefficient transport
management, incomplete information regarding traffic etc. Traditional traffic density estimation
methods such as radars, loop sensors, ultrasonic waves etc. have some limitations like high cost,
sensitivity to external environmental conditions, lighting conditions etc. The algorithms
discussed in this paper show some advantages as well disadvantages at the same time. The
advantages that all the five image processing based methods show are low hardware cost,
scalability, dynamic background subtraction etc. Estimating traffic density at a particular time on
a particular lane shows that accuracy of vehicle detection using image processing techniques can
be increased to further extent by introducing changes in the algorithms discussed. Like in
background subtraction method dynamic background subtraction can be introduced for better
results. Similarly in Canny edge detection method solutions for occlusion problem can be
introduced for more accurate results. In the self-proposed algorithm and Dual method technique
solutions for performing the density calculation in night time conditions also. Another change
that can be done is making use of thermal cameras in place of simple cameras for image
acquisition purpose. Since thermal cameras work on change in temperature so it will help to
exclude the parked vehicles on the road to be counted in road traffic density. Another problem
that exists is night time traffic analysis. This can be solved by using infrared cameras for night
time view. The main problems faced in preprocessing are removal of noise and unwanted
background. For this adaptive dynamic background subtraction and edge detection can be useful.
In some cases morphological operations can also help to get the complete information of the
vehicle shapes. For object counting, Canny edge detector has proved to be the most efficient
according to the literature survey done as it is not susceptible to noise interference and it also
detects true weak edges .Introducing such changes can help getting better results and thus
making image processing better method for traffic density calculation than any other method.
10. Reference
[1] Prof. Uma Nagaraj, Jinendra Rathod, Prachi Patil, Sayali Thakur,Utsav Sharma, “Traffic Jam
Detection Using Image Processing”,International Journal Of Engineering Research and
Applications(IJERA), ISSN: 2248-9622, Vol. 3, Issue 2, pp.1087-1091, March-April 2013.
[2] Vikramaditya Dangi, Amol Parab, Kshitij Pawar and S.S. Rathod,“Image Processing based
Intelligent Traffic Controller”,Undergraduate Academic Research Journal (UARJ), Vol.1,
pp.117, Issue 1, 2012.
[3] Anurag Kanungo, Ayush Sharma and Chetan Singla,“Smart Traffic Lights Switching and
Traffic Density Calculationusing Video Processing”, Proceeding of 2014 RAECS UIET Punjab
University Chandigarh, 06-08 march,2014
[4] Md. Munir Hasan, Gobinda Saha, Aminul Hoque and Md.Badruddoja Majumder, “Smart
Traffic Control System with Application of Image Processing Techniques”, 3rd
INTERNATIONAL CONFERENCE ON INFORMATICS, ELECTRONICS & VISION 2014,
IEEE.
[5] Sabya Sanchi Kanoji, “Real Time Traffic Light – control and Congestion avoidance system”,
International Journal of Engineering Research and Applications(IJERA), Vol. 2,pp.925-929,
Issue 2, March-April 2012.
[6] Khekare, G.S.; Sakhare, A.V., "A smart city framework for intelligent traffic system using
VANET," Automation, Computing,Communication, Control and Compressed Sensing (iMac4s),
2013 International Multi-Conference on , vol., no., pp.302,305, 22-23 March 2013
[7] Badura, S.; Lieskovsky, A., "Intelligent Traffic System: Cooperationof MANET and Image
Processing," Integrated Intelligent Computing (ICIIC), 2010 First International Conference on ,
vol.,no., pp.119,123, 5-7 Aug. 2010
[8] Salama, A.S.; Saleh, B.K.; Eassa, M.M., "Intelligent cross road trafficmanagement system
(ICRTMS)," Computer Technology and Development (ICCTD), 2010 2nd International
Conference on , vol., no., pp.27,31, 2-4 Nov.2010
[9] Madhavi Arora, V.K. Bagga, "Real Time Traffic Light Control SystemUsing Morphological
Edge Detection and Fuzzy Logic",2nd International Conference on Electrical, Electronics and
Civil Engineering (ICEECE'2012) Singapore April 28-29, 2012

You might also like