BHAGWAN MAHAVIR UNIVERSITY
Bhagwan Mahavir College of Engineering &
Technology, Surat
A Project Report On
BANK MANAGEMENT SYSTEM
WITH ASSEMBLY
Microprocessor and Interfacing(2010205615)
(Computer Engineering)
Submitted By:
Sr No. Name Enrollment No.
1. Gaurav Patel 2228020601061
2. Jinit Patel 2228020601062
3. Om Patel 2228020601066
4. Vaidik Patil 2228020601070
5. Krishna Ramprasadi 2228020601078
Prof. Sneha Patel Prof. Rauki Yadav
(Faculty Guide) (Head Of Department)
Academic Year
(2024 - 2025)
ABSTRACT
The Smart Traffic Management System (STMS) aims to alleviate urban traffic
congestion and enhance road safety by leveraging real-time data collection and
intelligent control mechanisms. Using sensors and cameras installed at critical
intersections, the system continuously monitors traffic parameters such as
vehicle count, speed, and density. The acquired data is processed through
computer vision and machine learning algorithms to estimate traffic conditions
accurately. Based on these insights, traffic signals are dynamically adjusted to
optimize traffic flow, reduce waiting times, and minimize congestion. A
user-friendly interface provides real-time traffic updates and system monitoring
capabilities. Testing the system in a real-world scenario demonstrated significant
improvements in traffic efficiency and responsiveness. This project highlights
the potential of integrating IoT and AI technologies to create smarter, safer, and
more efficient urban transportation networks.
Table of Contents
SR Title Page
NO No
1. Introduction 4
2. System Architecture 5
3. Code function 6
4. Working 8
5. Sample Output 10
6. Code 12
7. Challenges Faced 15
8. Conclusion 16
MIcroprocessor & Interfacing(2010205614) BMCET
1.Introduction
With the rapid growth of urban populations and increasing number of
vehicles on roads, traffic congestion has become a major challenge in
modern cities. Traditional traffic management systems, which often
rely on fixed-timed traffic signals, fail to adapt to dynamic traffic
conditions, leading to unnecessary delays, increased fuel consumption,
and higher pollution levels. To address these issues, a more intelligent
and adaptive approach is necessary.
The Smart Traffic Management System (STMS) is designed to improve
the efficiency of traffic control by using real-time data collection,
processing, and analysis. By integrating technologies such as IoT
sensors, cameras, and machine learning algorithms, the system can
monitor traffic flow, estimate traffic density, and dynamically adjust
traffic signal timings accordingly. This not only reduces congestion but
also improves overall road safety and commuter experience.
The goal of this project is to develop a system capable of intelligent
decision-making for traffic control, enabling cities to better manage
their transportation infrastructure and reduce the adverse effects of
traffic jams. The system also provides a user-friendly interface to
visualize traffic conditions and system status, promoting transparency
and easy monitoring for traffic authorities.
MIcroprocessor & Interfacing(2010205614) BMCET
2.System Architecture
The system is divided into the following modules:
● Data Collection Module: Uses cameras, infrared sensors, and
loop detectors at intersections to capture traffic parameters such
as vehicle count, speed, and density.
● Data Processing Module: Processes real-time data for traffic
analysis using image processing and machine learning.
● Control Module: Adjusts traffic signals dynamically based on
processed data to optimize flow.
● User Interface Module: Provides real-time traffic updates and
system monitoring via a web or mobile application.
MIcroprocessor & Interfacing(2010205614) BMCET
3.Code Function
● main.py
● Central controller managing the vehicle detection system
execution.
● Handles video stream input and initializes the detection
pipeline.
● Processes video frames for vehicle detection and counting in
real-time.
● Coordinates interaction between camera input, image
processing, and output display modules.
● Implements vehicle tracking, counting logic, and overlays
detection results on video frames.
● Manages system start, pause, and stop operations for smooth
execution
● simulation.py
● Simulation module responsible for modeling and testing
traffic scenarios.
● Generates synthetic or recorded traffic data to simulate
vehicle flow at intersections.
● Implements traffic signal timing logic based on real-time
traffic density inputs.
● Simulates dynamic adjustment of traffic lights to optimize
traffic flow and reduce congestion.
● Provides visualization of traffic conditions, signal changes,
and vehicle movements
MIcroprocessor & Interfacing(2010205614) BMCET
4.Working
● Signal Switching Algorithm
The Signal Switching Algorithm sets the green signal timer
according to traffic density returned by the vehicle detection
module, and updates the red signal timers of other signals
accordingly. It also switches between the signals cyclically
according to the timers. The algorithm takes the information about
the vehicles that were detected from the detection module, as
explained in the previous section, as input. This is in JSON format,
with the label of the object detected as the key and the confidence
and coordinates as the values. This input is then parsed to calculate
the total number of vehicles of each class. After this, the green
signal time for the signal is calculated and assigned to it, and the
red signal times of other signals are adjusted accordingly. The
algorithm can be scaled up or down to any number of signals at an
intersection. The following factors were considered while
developing the algorithm:
1. The processing time of the algorithm to calculate traffic density
and then the green light duration – this decides at what time the
image needs to be acquired
2. Number of lanes
3. Total count of vehicles of each class like cars, trucks,
motorcycles, etc.
4. Traffic density calculated using the above factors
5. Time added due to lag each vehicle suffers during start-up and
the non-linear increase in lag suffered by the vehicles which are at
the back [13]
6. The average speed of each class of vehicle when the green light
starts i.e. the average time required to cross the signal by each class
of vehicle [14]
7. The minimum and maximum time limit for the green light
duration - to prevent starvation
MIcroprocessor & Interfacing(2010205614) BMCET
MIcroprocessor & Interfacing(2010205614) BMCET
5.Output
MIcroprocessor & Interfacing(2010205614) BMCET
MIcroprocessor & Interfacing(2010205614) BMCET
6.Code(main.py)
import cv2
import os
from datetime import datetime
from ultralytics import YOLO
import numpy as np
# Load YOLOv8 large model for higher accuracy
model = YOLO('yolov8n.pt')
# Classes considered as vehicles
vehicle_classes = {"car", "bus", "motorbike", "truck", "bicycle"}
# Output directory for logs
text_output_path = os.path.join(os.getcwd(), "text_output")
os.makedirs(text_output_path, exist_ok=True)
# Video source
video_path = "txt.mp4" # change as needed or 0 for webcam
cap = cv2.VideoCapture(video_path)
# Tracking variables
vehicle_id_counter = 1
tracked_vehicles = {} # vehicle_id: center coordinates
frame_count = 0
total_unique_vehicles = 0
# Calculate Euclidean distance for tracking
def get_distance(p1, p2):
return np.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)
# Green signal time calculation
def calculate_green_time(avg_vehicle_count):
base_time = 15 # minimum green light duration in seconds
max_time = 90 # maximum green light duration
scaling_factor = 5 # seconds per vehicle (adjust as needed)
green_time = base_time + scaling_factor * avg_vehicle_count
green_time = max(base_time, min(green_time, max_time))
return int(green_time)
while cap.isOpened():
ret, frame = cap.read()
MIcroprocessor & Interfacing(2010205614) BMCET
if not ret:
break
frame_count += 1
result = model(frame)[0]
current_centers = []
matched_ids = set()
# Detect vehicles
for box in result.boxes:
cls_id = int(box.cls[0])
label = model.names[cls_id].lower()
if label in vehicle_classes:
x1, y1, x2, y2 = map(int, box.xyxy[0])
center_x, center_y = (x1 + x2) // 2, (y1 + y2) // 2
current_centers.append(((x1, y1, x2, y2), (center_x,
center_y), label))
# Track vehicles with unique IDs
for bbox, center, label in current_centers:
matched = False
for vehicle_id, old_center in tracked_vehicles.items():
if get_distance(center, old_center) < 50: # tracking
threshold
tracked_vehicles[vehicle_id] = center # update position
matched_ids.add(vehicle_id)
matched = True
break
if not matched:
tracked_vehicles[vehicle_id_counter] = center
matched_ids.add(vehicle_id_counter)
vehicle_id_counter += 1
# Remove lost vehicles (not matched in this frame)
tracked_vehicles = {vid: tracked_vehicles[vid] for vid in
matched_ids}
# Draw boxes and labels
for vid, center in tracked_vehicles.items():
# Find bbox for this center in current_centers to draw
for bbox, c, label in current_centers:
if c == center:
MIcroprocessor & Interfacing(2010205614) BMCET
x1, y1, x2, y2 = bbox
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.putText(frame, f"{label.capitalize()} {vid}", (x1, y1
- 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 2)
break
total_unique_vehicles = len(tracked_vehicles)
cv2.putText(frame, f"Total Unique Vehicles: {total_unique_vehicles}",
(10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
cv2.imshow("Traffic Surveillance", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
# Calculate average vehicles per frame for green time calculation
avg_vehicles = total_unique_vehicles # or you can modify to be average
over frames if preferred
green_signal_time = calculate_green_time(avg_vehicles)
# Save final report
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
output_file = os.path.join(text_output_path,
f"final_report_{timestamp}.txt")
with open(output_file, "w") as f:
f.write("Traffic Surveillance Final Report\n")
f.write("================================\n")
f.write(f"Timestamp: {timestamp}\n")
f.write(f"Total Unique Vehicles Detected: {total_unique_vehicles}\n")
f.write(f"Recommended Green Signal Time: {green_signal_time}
seconds\n")
f.write("Detected Vehicle IDs:\n")
for vid in tracked_vehicles:
f.write(f" - Vehicle {vid}\n")
print(f"Final report saved to: {output_file}")
print(f"Recommended Green Signal Time: {green_signal_time} seconds")
MIcroprocessor & Interfacing(2010205614) BMCET
7.Challenges Faced
● Hardware Issue
● Bad Weather And lightning
● Slow Processing:
● Connecting Different Parts:
● Traffic Signal Control:
● Testing with Real Data:
MIcroprocessor & Interfacing(2010205614) BMCET
8.CONCLUSION
The Smart Traffic Management System successfully
demonstrates how modern technologies like IoT, computer
vision, and machine learning can be integrated to improve
urban traffic flow and safety. By collecting and analyzing
real-time traffic data, the system dynamically adjusts traffic
signals, reducing congestion and waiting times at intersections.
Throughout the project, challenges such as hardware
limitations and environmental variations were addressed
through algorithm optimization and adaptive strategies. The
system’s effectiveness was validated through simulation and
real-world testing, showing promising results in traffic
management. This project highlights the potential for smart
technologies to create more efficient and sustainable
transportation networks, paving the way for future
enhancements such as predictive analytics and emergency
vehicle prioritization.