23
CSE 3100 Report on Software Development Project – II Traffic Jam Detection System Date: 22 June, 2008 Authors: Khan Muhammad Nafee Mostafa 0507007 & Qudrat-E-Alahy Ratul 0507037 Supervisor: Rushdi Shams Lecturer, Dept of Computer Science and Engineering, Khulna University of Engineering & Technology, Bangladesh Khulna University of Engineering & Technology Department of Computer Science and Engineering

Traffic Jam Detection System by Ratul, Sadh, Shams

Embed Size (px)

DESCRIPTION

report on my project about an approach to automatically detect traffic jam with the aid of Image Processing in traffic points using computers

Citation preview

Page 1: Traffic Jam Detection System by Ratul, Sadh, Shams

 [Type the document title]  [Year] 

CSE 3100 Report on Software Development Project – II

 

Traffic Jam Detection System

Date: 22 June, 2008

Authors: Khan Muhammad Nafee Mostafa 0507007 & Qudrat-E-Alahy Ratul 0507037 Supervisor: Rushdi Shams Lecturer, Dept of Computer Science and Engineering, Khulna University of Engineering & Technology, Bangladesh

 

            Khulna University of Engineering & Technology 

            Department of Computer Science and Engineering 

Page 2: Traffic Jam Detection System by Ratul, Sadh, Shams

 

Acknowledgement  We express our gratitude to the Almighty and our family. 

We also thank Batch 2k5 of CSE and whole CSE department of KUET for being a beaming source of inspiration. 

Thousands of people have worked and been working in the field of Image Processing and Object Recognition. Our respects go to all of them. 

We dedicate our work to them who relate to traffic. 

 

Page 3: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

 

TRAFFIC JAM DETECTION SYSTEM 

 Contents 

 

Chapter 1: Introduction…01 1.1 Traffic Jam Detection…01 1.2 Techniques of Traffic Jam Detection…02 1.3 A Brief of Our Approach…03 1.4 Outcome of the Project…04  

Chapter 2: Background…05 2.1 About Traffic Jam…05 2.2 About Image Processing and Object Detection…06 2.3 Fundamental Steps in Digital Image processing…06 2.4 Idea of Image…07 2.5 Towards Traffic Jam Detection…07  

Chapter 3: Work Approach …08 3.1 Approach of Image Processing and Object Detection…08 3.2 Image Acquisition…08 3.3 Image Enhancement…09 3.4 Lane Masking…10 3.5 Further Enhancement…11 3.6 Erosion Operation…12 3.7 Adaptive smoothing…13 3.8 Blobs (Binary Large Objects)…14 3.9 Object Analysis…14 3.10 Motion Detect…15 3.11 Showing Result…15  Chapter 4: Result and Calculation…17  Chapter 5: Conclusion…18   Appendix I : Screenshot of Our  Application… A‐1      

Page 4: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  1 

TRAFFIC JAM DETECTION SYSTEM Chapter  1  Introduction  

 

Traffic  system  is  at  the  heart  of  civilized world  and  development  in many aspects of life relies on it. Excessive number of traffic in roads and improper controls  of  that  traffic  create  traffic  jam.  It  either  hampers  or  stagnate schedule,  regimen,  business,  and  commerce.  Automated  traffic  detection system  is  therefore  required  to  run  the civilization  smooth and  safe‐ which will eventually lead us towards proper analysis on traffics, proper adjustment of control management, and distribution of controlling signals. 

The  aim  of  this  project  is  to  develop  a  traffic  jam  detection  system  using image processing and object detection. Besides, we developed an application that uses this detection mechanism and provides  instant online  information through  Short Messaging  Service  (SMS)  and  e‐mail.  This  information  helps the travelers to  incorporate with current situation on specific roads and the authority to plan and schedule load balancing on the roads. 

 

 

1.1 Traffic Jam Detection  

Mostly,  automated  systems  need  the  interaction  with  a  computer  that requires an algorithm to meet the specific requirements. 

Human eye can easily detect whether there is a traffic jam or not. Within less than a second, human brain processes  the  image of  the  traffic, detects and analyzes  objects,  and  thereafter  comes  to  a  decision.  A  programmer  also detects, as being a human, traffic jam according to the analysis and detection of  objects.  But  implementation  of  such  a  biological  process  requires  some special treatment.  

Page 5: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  2 

Computers  can  recognize only binary  signals. A picture of  the  road  can be represented as a digital  image, which  is actually binary signal. This  image  is used  as  primary  source  of  data.  But,  an  image, when  it  is  captured  from natural  environment,  is  very  raw  and  unformatted.  Programmers  have  to process  the  data  and  extract  relevant  information  from  images.  Frequent need of extracting  information  from  images has  led  to  the development of several  fields  (e.g.  Image  processing,  Computer  Vision,  Object  recognition etc)  in  computing  industry.   We  have  used  image  processing  and  object detection to detect traffic jam. It takes several steps of image processing for us to make decision about traffic jam. Key points of these steps are, 

• Image Analysis 

• Object detection 

• Typed object count 

• Motion detection 

• Result representation 

We  have  integrated  these  steps  in  our  system  and  have  developed  an application to simulate it. 

 

 

1.2 Techniques of Traffic Jam Detection  

Several approaches have been  taken  to detect  traffic  jam. Oldest and most reliable approach of them  is to employ a person  in  important traffic points. But  with  the  advent  of  technology  and  increment  of  traffic  flow,  several approaches with less involvement of human have been taken. 

Magnetic Loop Detector  (MLD) used to count the number of plying vehicles using magnetic properties [Koller et al. 1994].  

Light beams (IR, LASER etc) are also use. As traffic move on road light beams are cut. Electronic devices can record these events and detect traffic jam. 

In  contemporary  approaches,  image  processing,  computer  vision  etc  are highly  recommended.  In  these  types  of  approaches  involvement  of computers  provide  online  characteristics,  facilitate  centralized  control  over distributed system and develop compact platform. Computer vision (or Robot Vision) can also provide other services. In these approaches, information feed 

Page 6: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  3 

through  telephone  or web  networks  can  easily  be  supported.  Even,  traffic flow of whole city can be observed from a centre and statistics can be made. Traffic  systems  design  and  urban  planning  can  be  very  efficient  by  taking statistics from computer aided traffic systems. 

We are using computer aided image processing to attain optimal support. 

 

 

1.3 A Brief of Our Approach  

In our project, as mentioned earlier, we have used  image processing. Major steps of our work are presented next, 

 

1.3.1 Image Analysis At first we must capture the image of the traffic point where we are going to detect  traffic  jam. This  image  is  taken using a good digital  camera. Usually some  fundamental  image  enhancements  using  Gaussian  filter  and  noise reductions are done by camera itself. So, we do not need to apply them again and kept this step for camera. 

 

1.3.2 Object Detection This step is very crucial. We used ‘Lane Masking’ [Atkociunas et al. 2005]. After masking  lane, the  image contains only traffic vehicles. Then ‘Euclidean Color Filter’  is applied.  It will fill pixels with white where the difference of color  is minimal. Then, the image will be converted into a binary (first ‘Grayscale’ and then  ‘Black & White’)  image  using  a  threshold  value. Afterwards,  ‘Erosion’ operator  and  ‘Adaptive  Smoothing’  are  applied.  Finally,  ‘blobs’  are  found from the image and are placed apart. We recognize these blobs as objects. 

We will call this technique as ‘Lane Masked Erosion‐Blob Technique of Object Extraction’. 

 

 

Page 7: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  4 

1.3.3 Typed Object Count  Object  detection  is  followed  by  object  count. We,  classify  all  the  objects found,  in previous  step,  into  four  groups  (small,  large,  critical  and perfect) and count them. This information is provided to determine the present state of traffic. 

We will call this technique as ‘Lane Masked Erosion‐Blob Technique of Typed Object Count’. 

 

1.3.4 Motion Detection To  detect  motion,  we  need  two  consecutive  captures  of  the  road.  Both images undergo ‘Erosion‐Blob Technique of Object Extraction’ (section 1.3.2). Then, we detect overlapped blobs. Then, we calculate the distance the same blob has moved. Finally we average the result to determine speed of plying traffic.   

We  will  call  this  technique  as  ‘Lane  Masked  Erosion‐Blob‐Displacement method of motion detection’. 

1.3.5 Result Representation We  simulate  our  system  with  an  application  developed  in  the  .Net Framework. 

 

 

1.4 Outcome of the Project  

Our  project  is  targeted  at  developing  a  tool  for  detecting  traffic  jam.  This project  reaches  the  target  successfully  and  can be  implemented  in  various online systems. We can feed information about:  

• Number of plying vehicle 

• Existence of Jam 

• Average speed of traffic 

 

In the next chapters we will represent details of our project. 

Page 8: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  5 

TRAFFIC JAM DETECTION SYSTEM Chapter  2  Background 

 

2.1 About Traffic Jam  

It  is  said  that  road  and  transport  system  is  the  mean  by  which  we  can measure  the  development  level  of  a  country.  And  Traffic  jam  is  the unavoidable part of road & transport. Insufficient roads, poor urban planning etc may cause traffic jam. In general sense, we say that there is a traffic jam when there plies more vehicles in a road than it can hold.  

In any one of the following cases, we say there is a traffic jam: 

• The vehicles are stopped 

• Vehicles are moving very slowly 

• There is an excessive number of vehicle on road 

 

Automated traffic control system can help us to reduce traffic  jam and save our  valuable  time. Again,  computer  aided  traffic  jam detection  system  can warn  people  about  traffic  points  with  traffic  jam  and  ask  people  to  try alternative path. We worked on traffic jam detection to build a base of such modern facilities to ensure better transport. 

 

 

 

Page 9: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  6 

2.2 About Image Processing and Object Detection  

Recently  computing  industry  is working a  lot  in both  image processing and objects  detection.  These  two  fields  are  contributed  in  the  development  of artificial intelligence and automated systems. 

According to Nils J. Nilson [Nilson, 2002], Image processing has been proved to  be  a  very  difficult  problem  for  machines.  Programmers  mainly  face difficulties from  

• Variable and uncontrolled illumination • Complex and hard to describe objects • Objects occluding other objects 

In  man  made  environment  difficulties  are  lessened  than  in  natural environment. 

 

Object detection is the outcome of image processing. Object recognition goes far more deep in analyzing images and objects from it. 

 

 

2.3 Fundamental Steps in Digital Image processing  

Some fundamental steps of image processing are, 

• Image Acquisition • Image Enhancement • Image Restoration • Color Image Processing • Wavelets processing • Compression • Morphological Processing • Segmentation • Representation and Description • Recognition 

 

(Please look for references, [Gonzalez & Woods, 2003], [TUDelft]) 

 

Page 10: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  7 

2.4 Idea of Image In most  contexts, we  studied  and worked  on,  the word  ‘image’  is  used  to mention  a  two  dimensional  array  (or matrix  or  a  plane)  of  bitmaps  and  is used to represent 2D vision of real‐life images.  

Every  bitmap  contains  3  fields:  R, G  and  B.  Respectively,  they  contain  the color values of red, green and blue of a particular point  (pixel). Sometimes, another fourth field may contain intensity of the very point. 

 

 

2.5 Towards Traffic Jam Detection Computer industry is getting enriched in image processing everyday. A lot of work of many  individuals  throughout  the world has helped us  to develop a traffic jam detection system. 

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

Page 11: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  8 

TRAFFIC JAM DETECTION SYSTEM Chapter  3  Work Approach  

We  have  developed  this  project  as  a  part  of  a  course  named  ‘Software Development Project  ‐  II’ within  the undergraduate engineering program  in Computer  Science  and  Engineering.  We  were  suggested  to  use  the  .Net framework as platform and C# as the language. To accomplish our project C# .Net  was  a  good  tool.  Amongst  several  different  approaches  of  image processing we have selected some to use. A precise description of our work is presented in this chapter. 

 

 

3.1 Approach of Image Processing and Object Detection  

A machine,  just  like a human being, requires to  ‘see’ the road  for detecting traffic jam on  it. To provide a machine the capability to see we must exactly follow the process a human being does.  

Image processing requires huge processing of data and several algorithms run in order of n2 or ny. Therefore, processes involving image processing are to be handled with care.  

 

 

3.2 Image Acquisition  

Image acquisition is the first step of our system. A precise image of the case road (traffic point) is acquired. We need to capture an image of the road with no vehicle plying on it. This is called as background image (fig 3.2‐b).  

Page 12: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  9 

Another  image  of  the  road  is  taken  exactly  at  the  time when we  need  to detect traffic jam. We have a sample image next (fig 3.2‐a).   

 

Fig3.2‐a: Sample Image taken on road at runtime  

 

 

Fig3.2‐b: Sample Image taken as the background image  

 

 

3.3 Image Enhancement  

Some  noise  frequently  comes  on  images  taken  on  natural  environment. Contemporary  technology brings  cameras  integrated with  image enhancing algorithms. So, we are not applying any enhancement separately. 

 

Page 13: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  10 

3.4 Lane Masking  This method is intended to separate the part of the road where vehicles are moving in one direction (Fig. 3.2‐a). This method simplifies the processing. As we eliminate background we have only to think about the objects. So, a huge amount of irrelevant information is discarded. 

 Masking algorithm is given by formula 

N(p) = M(p) × V (p), 

Where, M(p) is an image point value in primary frame,  N(p) is a new image point in the output image (Fig. 3.4‐a), V(p) is mask value for point p: V (p) = 0 if corresponding pixel is eliminated,  otherwise V (p) = 1. 

  

Masking is applied to each RGB color separately. 

 

  

Fig3.4‐a: Image after lane masked from main image  

 

‐  =   Fig 3.4‐b: the Lane Masking Process 

Page 14: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  11 

3.5 Further Enhancement After lanes are masked, the images are then enhanced by turning it into grayscale (fig3.5‐a).  

Grayscale algorithm is 

R=G=B= (r+g+b)/3  

Where,  R, G and B are new values of red, green and blue  r, g and b are old values of red, green and blue  

Then the image is converted into black & white binary image (fig3.5‐b). This requires the algorithm, 

  If (r+g+b > threshold) {       R=G=B = white; 

}       Else {           R=G=B=black;         } 

 

 

Fig3.5‐a : Grayscal conversion  

 

Fig 3.5‐b : Binary Converted Image 

Page 15: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  12 

3.6 Erosion Operation The Erosion operator is defined as, 

 

   

 

 

Fig 3.6‐a: Erosion Operator 

In the case of object extract we can get good result by applying this operator. Fig 3.6‐b depicts an image with erosion applied on it. 

 

Fig3.6‐a: Figure with erosion applied on it 

 

Page 16: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  13 

3.7 Adaptive smoothing While traditional smoothing methods use the same window shape and size to smooth  an  image  independent  of  its  content,  in  adaptive  smoothing,  the  window  shape  and  size  are  varied  across  the  image domain depending on local  image  content.  In adaptive  smoothing a window  is  sized according  to the gradient magnitude locally and shaped in such a way that it has a shorter side across an edge compared to along the edge. This mechanism maintains edge details while smoothing random noise. 

Fig3.7a shows the picture processed with adaptive smoothing. And fig3.7b is without adaptive smoothing. 

 

 

Fig 3.7a: Figure after Adaptive smoothing 

 

  

Fig 3.7b: Figure without Adaptive smoothing 

 

 

 

 

Page 17: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  14 

3.8 Blobs (Binary Large Objects) Blobs are the largest objects. To find blob, we blur the image to eliminate all small noises. Figure below shows the largest blob found by our method, ‘Lane Masked Erosion‐Blob Technique of Object Extraction’. 

 

Fig3.8a: Perfect Blob of 7 found blobs  

3.9 Object Analysis  

Blobs  found  in  previous  step  is  now  processed mathematically  to  classify them in 4 groups, 

• Small • Critical • Perfect • Large 

 

Small objects are discarded as they are mostly noises. Large objects are never car or bus. They can be the image itself or other large portion of image. Most of  the  cars  lie  in  the  perfect  blob  group.  But  sometimes  critical  blob  hold portions of car (hood, trunk etc). 

We count the number of blobs  in each class. Then the count  is compared to standard  conditions  and  a decision  about  jam  status  is  then  can be made. This  approach  can  be  called  as  ‘Lane  Masked  Erosion‐Blob  Technique  of Typed Object Count’. 

Page 18: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  15 

3.10 Motion Detect  

Motion detection is another good way of telecasting information about traffic jam. To do so,  

• we take two  consecutive images of the road 

• find the blobs 

• detect overlapping blobs 

• find axis‐wise displacement 

• calculate the average displacement to determine speed 

This  approach  can  be  called  as  ‘Lane  Masked  Erosion‐Blob‐Displacement method of motion detection’. 

Two images are given below showing motion detection: 

               

Fig3.10a: two images for detecting traffic motion 

 

3.11 Showing Result   

In  all  the  stages,  described  above,  necessary  information  for  deciding whether there is a traffic jam or not is produced. Now we can display or even feed this information to several systems. 

In addition to traffic jam detection our simulation program can, 

• Generate string describing traffic status 

• Receive request through  SMS  

• Respond to a SMS immediately 

• Receive request through e‐mail  

• Respond to e‐mail requests 

Page 19: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  16 

Total integration of our application has also included set‐up features and set‐up data are stored with the help of filing system. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Page 20: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  17 

 TRAFFIC JAM DETECTION SYSTEM Chapter  4  Result and Calculation  

Our project has been tested in several conditions. We have found that, it takes 3 to 4 second for our system to determine the objects and their speed when the image is 1024*768 pixels.  

Our system can work efficiently work in standard environment. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Page 21: Traffic Jam Detection System by Ratul, Sadh, Shams

TRAFFIC JAM DETECTION SYSTEM 

 

  18 

TRAFFIC JAM DETECTION SYSTEM Chapter  5 Conclusion  

Traffic  jam  recognition  systems  have  been  developed  in  several  different ways. Our  approach  is  analytical.  It  also  takes  the  advantage  of  statistical data. Lane masking has contributed greatly  in reducing time complexity and has tremendously have improved performance. 

In future our work can support online centralized traffic system for a city. In this system, every  important traffic point will be monitored with our ‘Traffic Jam Detection System’. Then,  information will be  fed to central server. This server can analyze all points’  traffic  state and can control  traffic  flow. Such system may reduce traffic jam greatly. 

 

 

Page 22: Traffic Jam Detection System by Ratul, Sadh, Shams

 

 

References [Atkociunas et al. 2005] http://www.lana.lt/journal/19/Atkociunas.pdf  [Gonzalez & Woods, 2003] Rafael C. Gonzalez, Richard E. Woods,”Digital Image Processing ”2/e,2003   [Koller et al. 1994] Dieter Koller, Joseph Weber and Jitendra Malik, "Robust Multiple Car Tracking with Occlusion Reasoning" ECCV (1) 1994 [Nilson, 2002] Nils J. Nilson “Artificail Intelligence”, 2002  [TUDelft]  http://www.qi.tnw.tudelft.nl/Courses/FIP/noframes/fip.html

 

Page 23: Traffic Jam Detection System by Ratul, Sadh, Shams

  A‐1 

Appendix I: Screenshots of Aour Application