Software Design Document - CankayaUniversity/ceng-407-408-2021-2022-Smart-Traffic-System GitHub Wiki

1. INTRODUCTION

1.1 Purpose

Traffic congestion is one of the most serious issues that large cities face. The surge of vehicles as a result of breakdowns in other transportation sectors has resulted in high traffic density, which is especially noticeable around '+' road junctions. Several strategies have been implemented to alleviate traffic congestion in major cities. The construction of flyovers and bypass highways, the creation of ring roads, the assignment of traffic wardens to trouble zones, and the erection of traditional traffic lights based on counters are just a few examples. However, these initiatives fell short of the goal of liberating key '+' crossings, resulting in the loss of human lives and the squandering of important man hours during working days. This Smart Traffic Systems Project Document's major goal is to minimize the traffic problem as much as possible.

1.2 Scope

This article provides the Smart Traffic Systems Program's implementation specifics as well as a solution to road traffic problems in large cities by designing and implementing an intelligent system based on AI and ML. Users of the Smart Traffic System Program will be able to view the current traffic flow, check for problems and logs, watch the broadcast of the selected streetlight, and provide feedback.

1.3 Glossary

Glossary

1.4 Overview of Document

Below is a list of the remaining chapters and their contents.

Architectural Design is the second section, and it describes the project development phase. It also includes a system class diagram and an architecture design that describes actors, exceptions, basic sequences, priorities, pre-conditions, and post-conditions. The scenario generator's activity diagram is also included in this section.

Use Case Realization is the third section. A block diagram of the system is illustrated and explained in this section, which is designed according to use cases in the SRS paper.

The fourth section is about the environment. We've presented example frames of the environment from the prototype and detailed the situation in this part.

1.5 Motivation

We are a group of university students in the computer engineering department who are interested in Artificial Intelligence and Machine Learning technologies. As a group, we have participated in various AI and ML conferences to listen to different opinions about experts. Attending such conferences has allowed us to look at some problems from different angles. In addition, we took ML and AI lessons as a group. These lessons were the biggest factor in making this article. The articles we wrote and the projects we prepared during lessons took us to a higher level in AI and Ml. Because ın every project you do, new information and results about AI and ML technology emerge. AI and ML is a world that is without end and where each new knowledge creates another knowledge.

2.ARCHİTECTURE DESIGN

2.1 Simulation Design Approach

We're developing a system that combines artificial intelligence, machine learning, and computer vision technologies to automate traffic light monitoring systems. Every day, cameras mounted on traffic signals collect thousands of hours of footage that contains extremely useful information and can be utilized to minimize street congestion. It is feasible to produce traffic condition predictions using video footage data, a data set of traffic films, and machine learning algorithms.

Pattern recognition can be used to identify vehicle types, count the number of vehicles on the road, and classify light and heavy vehicles. This would increase the system's ability to predict traffic on each street and adjust traffic lights accordingly to reduce congestion. Because the training data sets contain enough data to forecast, the machine learning system can perform better. These data sets are expanding on a daily basis, and they can assist our system in determining traffic problems by observing daily data. Signals based on hard-coded time interval approaches do not always deliver outstanding outcomes in overcrowding circumstances. Because of the set time period, every street can have a distinct traffic scenario every hour, if not minute, causing time-based signals to fail and traffic jams to occur.

Using machines to complete this task can be very efficient and dependable. The suggested system analyzes forecasting future and present traffic to assist in determining when and where a signal release operation should be carried out. The suggested system will be a synchronized intelligent traffic signal monitoring system that will improve traffic monitoring and the way we deal with various transportation-related challenges and circumstances. A monitoring system and a control system will be the two components of the suggested model. Both components can communicate with one another and use data from the same directed backward signals at the same time to make intelligent decisions. The proposed model architecture is shown in Figure 1.

Simulation Design Figure

2.1.1 Class Diagram

Class Diagram

Fig 2: Class Diagram of the system

Figure 2 displays information about connections between the systems within the simulation.

  • SmartTrafficSystem class is the main system, which contains other systems. It is responsible for connections between other systems such as TrafficLight, Camera, Interface,CarDensityChecker.
  • Camera class collects all information from the streets and feeds the system with information like, car density, marked vehicles -green,red- and also the current state of the light.
  • Vehicle class that is derived from the camera class represents information about vehicles which are used in traffic and has the information of the car density value of each vehicle type.
  • TrafficLight class has information of traffic light’s ID, current state of the traffic light and timer on the light.
  • UI class represents the User Interface which the Actors of the system will encounter.
  • The CarDensityChecker class does the calculation of data and compares the density of roads. After doing that, the class sets the timer on the light.
  • Report class uses information from the camera, it checks for red_marked vehicles. Red_marked means that if the vehicle is red_marked, the vehicle waited at the light more than 1 times. If red_marked vehicles get higher from the threshold. It reports an issue and makes suggestions to correct that situation.

2.2 Architecture Design of System

Light Check and Vehicle Detection


Activity Diagram 1

Summary: This system is used by System. System gets data from the traffic light and camera. After getting data from the system do a calculation to density ratio on the street and set the time of lights.

Actor: System

Precondition: System must be runned, camera must be setted.

Basic Sequence:


1. System checks for red lights.

2. System reads data from the video.

3. If a vehicle exists, mark it green or red.

4. Calculate density based on marks.

Exception:


  • Cameras can’t see well

  • Database connection can be failed

  • Bad learning on train

Post Conditions: System gets density.

Priority: High

Setting Light Time:


Activity Diagram 2

Summary: This system is used by System. System gets density data from the check system. Compares densities based on roads and sets the traffic light times.

Actor: System

Preconditions: System must be runned, data flow needs to be clear.

Basic Sequence:


  1. System gets density from the check system.

  2. System compares density of roads

  3. Set traffic light time based on density ratio.

Exception: Database connection can be failed.

Post Condition: None.

Priority: High.

Red Mark Count


Activity Diagram 3

Summary: This system is used by System. System gets red marked vehicle data from the check system. Compares densities based on roads and sets the traffic light times.

Actor: System

Preconditions: System must be runned, data flow needs to be clear.

Basic Sequence:


  1. System gets red marked vehicle data from the check system.

  2. System change counter based by if condition

Exception: Database connection can be failed.

Post Condition: Feedback System

Priority: High.

Feedback System


Activity Diagram 4

Summary: This system is used by System. System gets counter data from the Red Mark Count System. Check counter value.

Actor: System

Preconditions: System must be runned, data flow needs to be clear.

Basic Sequence:


  1. System gets counter data from the Red Mark Count System.

  2. System gives feedback about to make upgrade this street

Exception: Database connection can be failed.

Post Condition: None.

Priority: High.

3. Vehicle Recognition

  • Troubleshooting Procedure

    The machine learning steps for car recognition will be broken down into three stages: pre-processing, training, and identification. In general, the system will be constructed as follows:

Diagram of Car Recognition System

The vehicle images are entered into the database via the first stage reading camera. The system will read the image and undertake a pre-processing step after it has been entered. Following the successful completion of preprocessing, the system began the training step, which is the phase during which the system learns to recognize an item (in this case car type). Following then, a well procedure, namely the introduction of a previously taught system, will be used to carry out the next step. The result will display the introduction of the type of car after the entire process has been completed successfully.

3.1 Datasets

In supervised learning, datasets used for machine learning research assign labels to the data. The vehicle detection system contains a large number of datasets, which allows for more accurate findings and a lower proportion of error throughout the machine learning process. A training set and a testing set are created from the dataset. Depending on the task's difficulty, the ratio between the training and testing sets may change.

3.1.1 Training dataset

The set of training samples is represented by the training dataset. It is a compilation of both positive and negative information. They are usually grouped together by the same number of components or features. The training dataset is an important component of future feature extraction for vehicle detection.

Training Testing

3.1.2 Testing dataset

The testing dataset is described as data that allows for an objective assessment of the final model after it has been fitted to the training dataset. It is the gold standard that is used in practice after the model has been fully trained.

3.2 Training and classification

In detection of the car classifier training is essential and can be done by its set of features, so that the computer can distinguish if the car is an image or not. This is classified by class labels such as vehicle and non-vehicle (OpenCV library). Training and classification are the substantial steps to reach the wanted goal. Process of step named training starts with getting a specified class's known content hence producing a classifier concerning this content. The quality of the process of training influences the output results iteratively while this classification of running on unknown content is a on-time process.

After being trained with a prepared dataset, Support Vector Machine (SVM) is one of the most popular supervised binary classification algorithms for deciding whether or not a vehicle exists. Figure 6 depicts the central concept underlying the SVM. There are two types of exits (for example, vehicles and non-vehicles), each represented by a different type of dot. During training, the algorithm is given a large number of examples from two classes. The task of the algorithm is to separate those classes. Figure 6 clearly shows the optimal hyperplane, which is the line that connects the two classes. The support vector machine will select the best plane that separates no more than two classes.

SVM

3.3 OpenCV library

OpenCv (Open Source Computer Vision Library) is a solid open - source software library. It contains around 2500 computer vision and machine learning algorithms that have been optimized. Face detection and recognition, object identification, human activity classifications in movies, and camera movement tracking are some of the applications of these techniques. The library is written in C and C++ to improve calculation efficiency and is compatible with most operating systems.

The OpenCv library is used to build the vehicle detection system. Its major aim is to modify received frames by analyzing them and creating a representation of them. cvSVM::CVM was used to classify two types of objects: vehicles and non-vehicles.

4.GUI Design

GUI design is responsible for interaction between the actors and the system. In this GUI design , there are also some sub-systems which are Main Page , Contact, Region , User Page . Main Page is a start page that the user sees as soon as the page is opened. He/She can see all the menus and information about the site , login,logout or register to the system. Region Page is the page that everyone can select the region, city , district and street . As the user clicks that Region Button , there is a search box in every section of the menu . The user can search the region,city,distinct,street etc.  By doing this , there will be a live broadcast playing in the middle of the page and the user will be able to see the traffic situation on that specific street . Contact Page , is the page where there will be a contact form for users to type whatever they want like requests,complaints,collaborations etc.In the User Page section , the user can edit his/her page , change settings, photo or general information .

Main Page

Main Page

After Log In

After Log In

Regions Dropdown Menu

Regions Dropdown Menu

Contact Page

Contact Page

User Page

User Page