0% found this document useful (0 votes)
9 views40 pages

Automated Vehicle Counting and Classification System

The document presents a final project report on an Automated Vehicle Counting and Classification System developed by Mohd Nazif Hawari Mohmood Nor for his Bachelor's degree at Universiti Teknologi PETRONAS. The project aims to create a non-intrusive traffic census system using image processing to accurately count and classify vehicles, overcoming the limitations of traditional magnetic loop detectors. The report details the methodology, results, and significance of the project, emphasizing its potential for improving traffic management and infrastructure planning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views40 pages

Automated Vehicle Counting and Classification System

The document presents a final project report on an Automated Vehicle Counting and Classification System developed by Mohd Nazif Hawari Mohmood Nor for his Bachelor's degree at Universiti Teknologi PETRONAS. The project aims to create a non-intrusive traffic census system using image processing to accurately count and classify vehicles, overcoming the limitations of traditional magnetic loop detectors. The report details the methodology, results, and significance of the project, emphasizing its potential for improving traffic management and infrastructure planning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

AUTOMATED VEHICLE COUNTING AND CLASSIFICATION SYSTEM

FOR TRAFFIC CENSUS

By

MOHD NAZIF HAWARI MOHMOOD NOR

FINAL PROJECT REPORT

Submitted to the Department of Electrical & Electronic Engineering


in Partial Fulfillment of the Requirements
for the Degree
Bachelor of Engineering (Hons)
(Electrical & Electronic Engineering)

Universiti Teknologi PETRONAS


Bandar Seri Iskandar
31750 Tronoh
Perak Darul Ridzuan

 Copyright 2012
by
Mohd Nazif Hawari Mohmood Nor, 2012
CERTIFICATION OF APPROVAL

AUTOMATED VEHICLE COUNTING AND CLASSIFICATION SYSTEM


FOR TRAFFIC CENSUS

by

Mohd Nazif Hawari Mohmood Nor

A project dissertation submitted to the


Department of Electrical & Electronic Engineering
Universiti Teknologi PETRONAS
in partial fulfilment of the requirement for the
Bachelor of Engineering (Hons)
(Electrical & Electronic Engineering)

Approved:

__________________________

Dr Fawnizu Azmadi Hussin


Project Supervisor

UNIVERSITI TEKNOLOGI PETRONAS

TRONOH, PERAK

September 2012

i
CERTIFICATION OF ORIGINALITY
This is to certify that I am responsible for the work submitted in this project, that the

original work is my own except as specified in the references and acknowledgements,

and that the original work contained herein have not been undertaken or done by

unspecified sources or persons.

__________________________

Mohd Nazif Hawari Mohmood Nor

ii
ABSTRACT

Traffic census is important for the purpose of upgrading and widening the road. The
information gained from the traffic census can be used in the budget planning for road
maintenance. Traffic census can be done automatically or by counting and classifying
the vehicles manually using human labor. Most of the automatic traffic census system
used nowadays focus on counting the vehicles by using devices called magnetic loop
detector. This device is costly and once installed, it cannot be removed. To overcome
this problem, an automated traffic census system based on image processing is
introduced which can be used to count and to classify the classes of the vehicle.
Computer vision technology is used to achieve this objective. For the vehicle
detection, background subtraction and approximate median algorithm are used. The
system uses the length of the vehicle for the purpose of classification. The chosen
algorithm for vehicle detection is called approximate median as it is more accurate
compared to background subtraction method. On the other hand, although the results
gained by using approximate median method is more accurate than a simple
background subtraction method, it has its drawback too which is more complex
calculation hence taking more time to execute the algorithm. Some optimizations
have been done on the approximate median algorithm and the result is very promising
as it has shortened the execution time while the accuracy of the detection remains the
same. In conclusion, this project is a success since it can count and classify the
vehicles, but further works need to be done to achieve better accuracy.

iii
ACKNOWLEDGEMENTS

First and foremost, I would like to dedicate my special thanks to my Final Year
Project supervisor, Dr. Fawnizu Azmadi Hussin for his kindness and continuous
support throughout 28-weeks during the time line given to accomplish my project. I
also would like to thanks him for giving me the opportunity to complete my project
under his supervision and for believing in me.

I also would like to express my gratitude towards my fellow colleagues, Ilias, Firdaus,
and Zakwan for giving me supports and guidance either directly or indirectly
throughout the completion of this project. Without them, I might be lost in searching
for solution in completing the project.

Not forgetting, Mr. Roszali for his advice and references in helping me throughout
the learning process of using MATLAB Programming Toolbox. This project would
not have been possible without the support and guidance shown by him.

To Universiti Teknologi PETRONAS and its lecturer, it has been such a privilege to
be able to pursue my degree in Electrical and Electronic Engineering here. I am really
grateful for having a chance to be one of the students here.

Finally, I would like to express my heartfelt gratitude to my family, friends and


lecturers for their support, constructive critics and positive suggestions.

iv
TABLE OF CONTENTS

LIST OF TABLES ...................................................................................................... vii

LIST OF FIGURES ................................................................................................... viii

LIST OF ABBREVIATIONS ...................................................................................... ix

CHAPTER 1 INTRODUCTION .................................................................................. 1

1.1 Background of Study ........................................................................ 1

1.2 Problem Statement ........................................................................... 1

1.2.1 Problem Identification ............................................................. 1

1.2.2 Significance of Project ............................................................. 2

1.3 Objective and Scope of the project .................................................. 2

1.3.1 Main Objective ........................................................................ 2

1.3.2 Scope of Project ....................................................................... 2

1.4 Relevancy of Project ........................................................................ 2

1.5 Feasibility of Project ........................................................................ 3

CHAPTER 2 LITERATURE REVIEW ....................................................................... 4

2.1 Importance of Traffic Census ........................................................... 4

2.2 Vehicle Counting Overview ............................................................. 4

2.3 Lane Masking ................................................................................... 5

2.4 Moving Object Detection ................................................................. 6

2.4.1 Background Subtraction .......................................................... 6

2.4.2 Approximate Median ............................................................... 7

2.5 Vehicle Counting.............................................................................. 8

2.5.1 Draw Bounding Box ................................................................ 8

2.5.2 Plotting the Centroid ................................................................ 9

2.5.3 Virtual Detector ....................................................................... 9

v
2.6 Vehicle Classification ...................................................................... 9

CHAPTER 3 METHODOLOGY ............................................................................... 11

3.1 Research Methodology ................................................................... 11

3.2 Flow Chart ...................................................................................... 12

3.3 Gantt Chart ..................................................................................... 13

3.4 Tool Required ................................................................................. 16

CHAPTER 4 RESULTS AND DISCUSSION ........................................................... 17

4.1 Results ............................................................................................ 17

4.1.1 Lane Masking Results............................................................ 17

4.1.2 Background Subtraction Results............................................ 19

4.1.3 Pixel neighbouring, bridging and thickening ......................... 20

4.1.4 Approximate Median ............................................................. 22

4.1.5 Draw Bounding Box .............................................................. 22

4.1.6 Plotting the Centroid .............................................................. 23

4.1.7 Counting the Vehicles............................................................ 24

4.1.8 Classifying the vehicle ........................................................... 25

4.2 Discussion ...................................................................................... 26

CHAPTER 5 CONCLUSION AND RECOMMMENDATION ................................ 28

5.1 Conclusion ...................................................................................... 28

5.2 Recommendation ............................................................................ 28

REFERENCES............................................................................................................ 29

vi
LIST OF TABLES

Table 1: Gantt Chart FYP I ......................................................................................... 13

Table 2: Milestones FYP I .......................................................................................... 14

Table 3: Gantt Chart FYP II ........................................................................................ 15

Table 4: Milestones FYP II ......................................................................................... 15

Table 5: Counting and classification results ............................................................... 26

Table 6: Codes optimization ....................................................................................... 26

vii
LIST OF FIGURES

Figure 1: Before masking .............................................................................................. 5

Figure 2: After masking ................................................................................................ 5

Figure 3: Background subtraction ................................................................................. 7

Figure 4: Vehicle classification based on length......................................................... 10

Figure 5: Methodology................................................................................................ 12

Figure 6: Original image before masking ................................................................... 17

Figure 7: Frame masking result................................................................................... 18

Figure 8: Execution time without frame masking ....................................................... 18

Figure 9: Execution time with frame masking ............................................................ 19

Figure 10: Original frame............................................................................................ 20

Figure 11: Output image after subtraction (RGB) ...................................................... 20

Figure 12: Output image in grayscale ......................................................................... 21

Figure 13: Output image in black and white ............................................................... 21

Figure 14: Output image in black and white after image filtering .............................. 21

Figure 15: Output image of approximate median method .......................................... 22

Figure 16: Draw bounding box around each BLOB ................................................... 23

Figure 17: Plotting the centroid on the BLOB ............................................................ 24

Figure 18: Plotting the centroid on the original image ............................................... 24

Figure 19: Detector detect as a hit............................................................................... 25

Figure 20: Detector detect as a miss ........................................................................... 25

Figure 21: Original frame............................................................................................ 27

Figure 22: BLOBs produce based on Figure 21 ......................................................... 27

viii
LIST OF ABBREVIATIONS

BLOB binary large object


UTP Universiti Teknologi PETRONAS

ix
CHAPTER 1
INTRODUCTION

1.1 Background of Study

Traffic census also known as traffic survey is conducted to determine the number,
movements and classification of roadway vehicle at given location. There are many
ways to do traffic census either by manual counting or automatic counting. The
objective of this project is to develop a system that is able to count and classify the
types of vehicles automatically. The system will be designed using MATLAB with a
few goals, which are to determine the number of vehicles on the road and classify the
vehicles either light or heavy vehicle. Classification of heavy vehicles is important for
the purposes of transportation planning and traffic operations. Traffic census is
important for the sake of future road development in term of upgrading the road,
widening the existing road and infrastructure development. The proposed automated
vehicle counting will be introduced by using image processing that will identify the
moving object on the video or on the camera and classify the object. The accuracy of
the results will be determined by counting the vehicles manually and compare the
results produce by the system.

1.2 Problem Statement

1.2.1 Problem Identification

Automatic traffic counting exist nowadays mostly focuses on to determine the number
of vehicle that use the road not the class of vehicle. This project aims to count and
classify each type of vehicle and classify it automatically without the need of human
to classify it, like manual counting method.

1
1.2.2 Significance of Project

Traffic census is important for the sake of future road development in term of
upgrading the road, widening the existing road and for infrastructure development.
The data collected are useful to identify point of congestion on various roads and will
help the developer to upgrade the existed road in term of the number of vehicle use
the road. Vehicle classification is important to compute the percentages of vehicle
classes that use state-aid streets and highway.

1.3 Objective and Scope of the project

1.3.1 Main Objective

To develop traffic census system based on image processing that can count vehicle
and classify the class of vehicle accordingly.

To provide another alternative for traffic census that is non-intrusive compared to


magnetic loop detector, the widely use device for traffic census that need to be
planted on the road.

1.3.2 Scope of Project

This project will start by doing some literature review on motion detection based on
image processing and methodology of image processing using MATLAB tools.
Further testing and improvement will be carried out to gain the desired accuracy of
result.

1.4 Relevancy of Project

Since the existing devices for counting vehicles are mostly based on loops detectors,
which are costly and unreliable, this project will become appreciable. The cost of
installing the equipment that is camera, to be used with the project is cheaper
compared to the cost of installing magnetic loops detector. Furthermore, this project is
able to classify the type of vehicle that uses the road, which is not available for loops
detector.

2
1.5 Feasibility of Project

The project will be done in two semesters that includes three area of study which are
research, development of application and also beta-testing and improvement of the
full prototype. The project will use MATLAB as a tool to apply image processing
algorithm for detecting, counting and classifying the vehicle.

3
CHAPTER 2
LITERATURE REVIEW

2.1 Importance of Traffic Census

Manual counts are used to determine the vehicle classification, turning movements,
directions of travel, pedestrian movements or vehicle occupancy. Automatic counts
are used to determine vehicle hourly patterns, daily or seasonal variations and growth
trends, or annual traffic estimates [10].

The objective of traffic census is to determine the number of vehicle that uses the
roadway. The data gain from the survey will be used for traffic monitoring,
management and planning traffic infrastructure.

2.2 Vehicle Counting Overview

There is a lot of traffic counting method available and it is important to differentiate


between intrusive and non-intrusive method [8]. The major intrusive methods are
bending plate, pneumatic road tube, piezo-electric sensor, and inductive loop detector.
Manual observation, passive and active infra-red, passive magnetic, and radar are
example of major non-intrusive method. Inductive loops detectors are one of the most
popular intrusive methods used to count vehicles.

However, there are disadvantages of using loops detector which are costs and
reliability [6]. Loops detector has high cost and safety risk associated with their
installation and maintenance [6]. These sensors are required to be drill on the road and
once it is installed, they cannot be relocated [7]. Another disadvantage of using loop
detectors is the equipment can only be used for real time [4]. The user cannot simply
put other kind of input such as video file to the equipment to count the number of
vehicle [4]. A vision based traffic counting has several advantages compared to
conventional traffic counting using magnetic loops detector. Traffic counting based
on image processing can give spatial information about a scene and can be recorded
easily for further analysis [2]. The devices also can be easily installed, maintained and

4
minimize the safety risk to the user compared to the installation and maintenance of
magnetic loops detectors [2].

2.3 Lane Masking

As explained in [2], this technique is used to separate parts of the image that will be
used in the computation. Parts of the image needed are multiplied by 1 and a part of
the image that is not needed is multiplied by 0. The result is the images that only
contain the parts needed for computation. This technique can reduce the computation
time and reduce the noise generated by the background.

An example of lane masking technique is shown in the figures below. Notice that a
part of the image that is not needed in the computation is eliminated by applying the
technique.

Figure 1: Before masking

Figure 2: After masking

5
2.4 Moving Object Detection

In detecting moving object, there are some algorithms available that vary based on its
complexity and quality presented. Among them are background subtraction and
approximate median method. Additional technique such as neighboring, thickening
and pixel bridging are necessary in getting a smoother result.

2.4.1 Background Subtraction

Background subtraction is a method where each video frame is compared against


reference frame or background image. Moving objects are detected when pixels in
current frame is deviate significantly with the reference frame [10]. There are a lot of
challenges in developing a good background subtraction algorithm. First of all, it must
be robust against changes in illumination such as gradual and sudden changes; for
example cloud. Second, the algorithm must avoid detecting non-stationary
background objects such as moving leaves, weather change, and shadow cast by
moving objects. This is where the lane masking technique is useful, by eliminating
that part in the image; the chance for the algorithm to detect such noise is
minimalized. Lastly, the internal background model should react quickly to changes
in background, such as starting and stopping vehicle [9].

The most basic method for background subtraction is as shown below:

Where

i = current frame, Th = value of threshold

In this method, the background image is just the previous frame. After the subtraction,
if the value left are bigger than threshold values, then a foreground image are
detected. Figure below shows an example of applying background subtraction to the
consecutive frame.

6
Figure 3: Background subtraction

The white colors that appear on the right side of the picture indicate foreground image
had been detected. This means there are existences of moving object within the
image. After the subtraction, the resulting image must undergo some other process to
gain a better output which is median filtering and hole elimination.

2.4.2 Approximate Median

As explained in [10], approximate median works by comparing the pixel value in the
current frame to the corresponding background pixel. If the pixel value in the current
frame has a bigger value compared to the corresponding pixel in the background
7
pixel, that background pixel are then incremented by 1. Otherwise, if the pixel value
in the current frame is smaller than the corresponding pixel in the background image,
that background pixel are then decremented by 1. The new updated background
images are then will be used in the background subtraction for the next frame.

To detect the object movements, frame differencing method are used which is the
same method as explained in the background subtraction section. The only difference
is that the images for background frame are taken from the updated background frame
during the approximate median process.

The formula for approximate median method is shown as below:

To detect the object movement, the formula shown as below is used:

Where,

(Height of the image)

(Width of the image)

2.5 Vehicle Counting

To count the vehicle, the most important information need to be gathered from the
BLOBs is the centroid. By finding the centroid, the locations of the BLOB in the
image are figured and can be used by virtual detector to count the vehicle.

2.5.1 Draw Bounding Box

Bounding box are drawn around each detected moving object to identify whether each
BLOB produce are connected to each other. Each separated BLOB can be seen clearly
after the box is drawn around each one of them. This is useful in determining the
resulting BLOB that should be connected or separated. Suppose that there are two
moving objects in the picture that are not connected, but after the detection process,
the BLOB produces are connected to each other. By drawing a bounding box around
each BLOB detected, the two main BLOBs that are connected can be seen clearly and
there are faulty happen during moving object detection process.

8
2.5.2 Plotting the Centroid

By finding the centroid of each BLOB detected, the location of the moving object in
the image can be identified. The centroids of the object are important in vehicle
counting process.

2.5.3 Virtual Detector

Virtual detector works just like the magnetic loop detector as proposed in [3]. Each
BLOB that passes through the rectangle region called virtual detector on every lane is
count as one vehicle. The centroid of each BLOB is very useful in detecting the
vehicle that passes through the virtual detector.
When the centroid of the vehicle are in the range of the virtual detector, the detector
will register that a hit. When the centroid of the vehicle is outside the range of virtual
detector, the detector will register as a miss. Two consecutive hit and miss registered
accordingly by the detector will count as one vehicle. The same rule applies on each
detector in every lane.

2.6 Vehicle Classification

To classify the class of the vehicle, the length of the vehicle detected is measured as
explain in [3]. Certain length is decided to classify the vehicles according to its class.
The length of the heavy vehicle; truck, bus and lorry is decided based on the average
length of the heavy vehicle sees by the computer. If the detected vehicles are in the
range of light vehicle, then the vehicle is classified as light vehicle. The same rules
apply for the heavy vehicle and motorcycle.

9
Figure 4: Vehicle classification based on length

10
CHAPTER 3
METHODOLOGY

3.1 Research Methodology

In order to achieve the main objectives of this project, the goals for the two sub
objectives highlighted earlier must be accomplished. In outlining the importance of
traffic census, detail review as well as brief research about the topic is focused on the
selected papers which concentrate on the application of image processing to detect
moving object, in this case the vehicle.

For the second sub objective which is to utilize the availability of image processing
technology to ease up human works, literature reviews as well as well as brief
research about the topic are carried out on several resources such as books, journals,
and internet.

The result gain from the system is then compared with the manual counting to
determine the accuracy of the result. Further improvement will be done to gain the
desired results.

11
3.2 Flow Chart

The following flow chart explains the methodology in executing the project:

Start

Brief research and literature review

Learn MATLAB coding

Image acquisition

Image analysis

NO
Vehicle detection

OK
NO
Vehicle counting
and classification

OK

Result

End

Figure 5: Methodology

12
3.3 Gantt Chart

In order to effectively monitor the progress of this project, a Gantt chart consists of 2 semester duration has been constructed.

Table 1: Gantt Chart FYP I

FINAL YEAR PROJECT I


ACTIVITIES WEEK NO.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Choose topic
Brief research and literature review
Learn MATLAB coding
Image acquisition
Image analysis
Collecting data

13
Table 2: Milestones FYP I

Completion of topic selection Week 1

Completion of brief research and literature review Week 5

Completion of image acquisition Week 6

Completion of image analysis Week 12

Completion of applying image processing algorithm Week 14


using MATLAB coding

Completion of collecting data Week 14

14
Table 3: Gantt Chart FYP II

FINAL YEAR PROJECT II


ACTIVITIES WEEK NO.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Improve accuracy of result
Beta testing

Table 4: Milestones FYP II

Completion of improving the accuracy of result Week 8

Completion of beta-testing Week 14

15
3.4 Tool Required

The MATLAB R2011b software is used as the main tool for detecting the vehicle
using image processing technology. MATLAB is an ideal tool for working with
image processing since it is highly efficient in performing matrix calculations. Image
Processing Toolbox which is included with the MATLAB software will provide
useful tool for working with image processing.

16
CHAPTER 4
RESULTS AND DISCUSSION

4.1 Results

The results for every method that is highlighted in the literature review section are
shown below. The last part of this section shown the results gain from an accuracy
test done on the algorithm to evaluate its functionality in real situation.

4.1.1 Lane Masking Results

In lane masking technique, parts of the image that is not needed in the calculation is
removed. The project had passed this phase without any problem. The results of this
method are shown below.

Figure 6: Original image before masking

17
Figure 7: Frame masking result

Figure 6 shows the original image without frame masking. After the masking process,
the output is shown in Figure 7. In Figure 7, parts of the image that has been
eliminated are in black colour, and parts of the image that is useful for the project are
stay in the original value. This process reduce the noise generate from the area of the
image that is not needed, hence improve the overall result of the process.

By adding lane masking instruction in the process, there is not much difference in
time taken for MATLAB to run the script, with the masking or without the masking.
The results for the execution time are shown in the figures below.

Figure 8: Execution time without frame masking

18
Figure 9: Execution time with frame masking

The result is gain from running a 12 seconds video, without running the video after
execution. The result shown is only the time taken for MATLAB to execute each
instruction. Notice that the difference in total execution time shown in Figure 8 (with
frame masking) compared to Figure 9 (without frame masking) is 0.124 seconds. The
difference can be neglected as it is quite small and will not make the performance of
the whole algorithm much slower. Plus, by applying masking on each frame, the
noise generated from the moving background object such as trees can be neglected,
thus improving the performance of the system in term of detecting moving objects.

4.1.2 Background Subtraction Results

Figures below showed the output of background subtraction or frame differencing.


Figure 10 shown the original image before subtraction and Figure 11 shown the
output image right after subtraction, without converting it to grayscale or black and
white image.

19
Figure 10: Original frame

Figure 11: Output image after subtraction (RGB)

4.1.3 Pixel neighbouring, bridging and thickening

To get a better output, the output image after subtraction process are converted to
grayscale image and then median filtering are applied to reduce the noise generated.
The results are shown in Figure 12. The images are then converted in black and white
image for the purpose of further process. The threshold value for black and white
conversion are set to be 20, which means the pixel value of grayscale image are
converted if only the value is more than 20. The resulting images are shown in figures
below.

20
Figure 12: Output image in grayscale

Figure 13: Output image in black and white

Figure 14: Output image in black and white after image filtering

Figure 13 shows the original black and white image of the output. Notice that there is
some part of the vehicle that is not connected after the conversion. To connect all

21
those separate part that belongs to the same vehicle, the image must undergo some
other process which is bridging, thickening and neighbouring. The results of these
alterations are shown in Figure 14. This process is needed because the BLOBs that
represent one vehicle must be connected altogether to avoid the confusion for the next
process.

4.1.4 Approximate Median

Approximate median is just another method used to detect the BLOB of moving
vehicle. By using this method, the output gained are much more better compared to
frame differencing method as the moving BLOB are not much separated from each
other after the process. The downside of this method is that the times taken to execute
the same video are much longer compared to frame differencing method.

Frame differencing method only took 27 seconds to execute a 32 seconds video file
while approximate median method took 127 seconds to execute the same video file.

The output image of implementing approximate median method is shown in Figure


15.

Figure 15: Output image of approximate median method

4.1.5 Draw Bounding Box

Bounding box is drawn around each BLOB for the purpose of tracking the BLOB.
Once the box are drawn, it is easier for the user to determine whether the BLOB

22
shown are represents for one vehicle or two or more vehicles that are connected to
each other due to the close distance between them.

The results for the implementation are shown in Figure 16. The bounding box is
drawn around each BLOB, thus separating it from each other. The user can now
define whether those separated BLOBs are should be separated or connected, hence
the correction on the configuration of the algorithm can be made to obtain the best
results.

Figure 16: Draw bounding box around each BLOB

4.1.6 Plotting the Centroid

Apart from drawing the bounding box around each BLOB to separate them from each
other, the centroid on each BLOB are determine to define the exact location of each
BLOB. Each separated BLOB now will have a centroid that shows its location.

To avoid plotting the centroid on a small BLOB, the selected BLOB that has an area
of bigger than 1000 pixel square will only have the centroid plotted on it. Assuming
that the small BLOB which is less than 1000 pixel square is not a vehicle, this will
improve the results of counting the vehicle.

The results of plotting the centroid on the image of Figure 15 are shown in Figure 16.
The plotted centroid on the BLOB indicates that the areas of the BLOB are bigger
than 1000 pixel square, thus represents a vehicle. Figure 17 shows the plotted
centroid on the original image.

23
Figure 17: Plotting the centroid on the BLOB

Figure 18: Plotting the centroid on the original image

4.1.7 Counting the Vehicles

The centroids obtained in the previous process are now used in counting the vehicle.
To count the vehicle, red boxes, representing the detector are defined on the image.
The detector works when the centroids are inside the red box, the detector will detect
as hit. Once the centroid leave the box, the detector will detect as miss. When the
detector detect two consecutive frames as hit and miss accordingly, the detector will
define that as a vehicle and the vehicle counter will count up. The methods for
counting the vehicles are shown in the Figure 19 and 20.

24
Figure 19: Detector detect as a hit

Figure 20: Detector detect as a miss

4.1.8 Classifying the vehicle

To classify the class of vehicle, the system use the length of the vehicle detected. The
moment the vehicle passed through the virtual detector, the system will analyze the
length of the vehicle and classify it according to its class. As for now, the system can
classify motorcycles, cars, and heavy vehicle; lorry and bus.

The accuracy test was done based on 20 minutes video taken in front of UTP’s
flyover from 4:50 pm to 5:10 pm on a sunny day. The video are reliable for testing
purpose because of the traffic congestion and the type of vehicle that use the road at
the time; bus, lorry, car and motorcycle. The accuracy test for counting and
classification of the vehicle are shown in the table below.

25
Table 5: Counting and classification results

Actual System Error Accuracy

Heavy vehicle
37 16 21 43.24 %
(lorry, bus)

Light vehicle
389 416 27 93.06 %
(car, van)

Motorcycle 73 77 4 94.52 %

4.2 Discussion

Based on the results of detecting the BLOB of moving object, it is clearly shown that
by using approximate median method, the resulting output are much more accurate
compared to frame differencing method. Although the time taken for the approximate
median method are much longer compared to the frame differencing method, the
quality of the results are much more important compared to the speed of the
execution. More research will be done to reduce the execution time taken for the
approximate median method.

After doing some optimization on the codes for approximate median method, the time
taken to execute the codes has been lower into half. The results are shown in the table
below

Table 6: Codes optimization

(c) Optimization
(a)Video (b)Execution Ratio
length time (a)/(b)

Original code 32 seconds 127 seconds 0% 3.9688

Optimize code 32 seconds 62 seconds 51.1811 % 1.9375

26
Since the bounding box can be drawn around the BLOB, the length of the box can be
used in classifying the vehicle. For example if the length of a light vehicle, which is
vehicle in the range of 100 to 150 pixels, then the vehicle will be classified as light
vehicle. If the length of the vehicle is more than 150 pixels, the vehicle will be
classified as heavy vehicle. Examples of heavy vehicle are lorry and bus.

The accuracy of classification for heavy vehicle is quite low (43.24%) because the
system misclassifies the lorry that is in the same length as car as a light vehicle.
Another problem that causes the misclassification is because the BLOB generated
from the system for the heavy vehicle is separated although it belongs to the same
vehicle. For example, the BLOB for a lorry are divided into two or more parts, this
problem can be seen clearly as there are more than one bounding box that are belongs
to the same vehicle. Figures below shown the problem arise for this particular matter.

Figure 21: Original frame

Figure 22: BLOBs produce based on Figure 21

27
CHAPTER 5
CONCLUSION AND RECOMMMENDATION

5.1 Conclusion

The lane masking technique is important process in reducing the noise generated from
the background. Background subtraction process is the key feature of this project. A
successful background subtraction can lead to a better detection result. Additional
method such as bridging, neighbouring and thickening the pixel are complimentary in
making sure the system producing a better result.

In conclusion, it can be said that this project is able to be completed with the given
time line to achieve the required objectives.

5.2 Recommendation

A variety of technique has been implemented on this project such as masking, frame
differencing and approximate median. This work can be expanded to investigate
which technique that will give a better image analysis. Furthermore, there some other
techniques that can produce a better output result but involving in more complex
algorithm in detecting moving object which are Mixture of Gaussian, optical flow,
and edge extraction. This technique can be implemented for the sake of future
development of the project.

28
REFERENCES

[1] Yiwei Wang; Doherty, J.F.; Van Dyck, R.E.; , "Moving object tracking in
video," Applied Imagery Pattern Recognition Workshop, 2000. Proceedings. 29th ,
vol., no., pp.95-101, 2000
doi: 10.1109/AIPRW.2000.953609

[2] E. Atkociunas, R. Blake, A. Juazapavicius, “Image Processing in Road Traffic


Analysis”, Nonlinear Analysis: Modelling and Control, vol. 10, No. 4, pp. 315-322,
2010

[3] Avery, R.P.; Wang, Y.; Scott Rutherford, G.; , "Length-based vehicle
classification using images from uncalibrated video cameras," Intelligent
Transportation Systems, 2004. Proceedings. The 7th International IEEE Conference
on , vol., no., pp. 737- 742, 3-6 Oct. 2004
doi: 10.1109/ITSC.2004.1398994

[4] Lei, M.; Lefloch, D.; Gouton, P.; Madani, K.; , "A Video-Based Real-Time
Vehicle Counting System Using Adaptive Background Method," Signal Image
Technology and Internet Based Systems, 2008. SITIS '08. IEEE International
Conference on , vol., no., pp.523-528, Nov. 30 2008-Dec. 3 2008
doi: 10.1109/SITIS.2008.91

[5] Lili Huang; , "Real-time multi-vehicle detection and sub-feature based tracking
for traffic surveillance systems," Informatics in Control, Automation and Robotics
(CAR), 2010 2nd International Asia Conference on , vol.2, no., pp.324-328, 6-7
March 2010
doi: 10.1109/CAR.2010.5456534

[6] Tamersoy, B.; Aggarwal, J.K.; , "Counting Vehicles in Highway Surveillance


Videos," Pattern Recognition (ICPR), 2010 20th International Conference on , vol.,
no., pp.3631-3635, 23-26 Aug. 2010
doi: 10.1109/ICPR.2010.886

29
[7] Jingwei Liu; Yong Zhao; Yule Yuan; Wei Luo; Kai Liu; , "Vehicle capturing and
counting using a new edge extraction approach," Intelligent Transportation Systems
(ITSC), 2011 14th International IEEE Conference on , vol., no., pp.62-66, 5-7 Oct.
2011
doi: 10.1109/ITSC.2011.6082938

[8] Dr. Brian Slack, “Traffic Count and Traffic Survey”,


http://people.hofstra.edu/geotrans/eng/ch9en/meth9en/ch9m2en.html

[9] Background Subtraction for Detection of Moving Objects,


https://computation.llnl.gov/casc/sapphire/background/background.html

[10] Sen-Ching S. Cheung and Chandrika Kamath “Robust Techniques for


Background Subtraction in Urban Traffic Video” IS&T/SPIE's Symposium on
Electronic Imaging 2004, pp. 1, 2003.

30

You might also like