0% found this document useful (0 votes)
11 views

cppVAIBHAV

The project report titled 'Detecting Traffic Rule Violence' outlines a computer vision-based system designed to automatically detect traffic violations such as speeding, helmet use, and wrong-way driving using deep learning techniques. The system employs Yolov3 for object detection and integrates number plate recognition to maintain logs and provide alerts to traffic authorities, aiming to enhance road safety. The report includes various chapters detailing the project's introduction, literature survey, scope, problem definition, methodology, and system design.
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)
11 views

cppVAIBHAV

The project report titled 'Detecting Traffic Rule Violence' outlines a computer vision-based system designed to automatically detect traffic violations such as speeding, helmet use, and wrong-way driving using deep learning techniques. The system employs Yolov3 for object detection and integrates number plate recognition to maintain logs and provide alerts to traffic authorities, aiming to enhance road safety. The report includes various chapters detailing the project's introduction, literature survey, scope, problem definition, methodology, and system design.
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/ 69

A

PROJECT REPORT
On

“Detecting Traffic Rule Violence ”


Has been
Submitted in partial fulfillment of the Project In

Diploma in Computer Engineering

By

Name of the Students Enrolment No. Seat No.


PHATE SUJAL HARIDAS 2208540067 217087
SUPSANDE TANISHKA RAJENDRA 2208540119 217125
KAVADE VAIBHAV DATTATRAY 2208540128 217132
AWCHARE ANVITA ANIL 2208540143 217140
KADAM OMKAR AUDUMBAR 2208540172 217161

UNDER THE GUIDANCE OF

Prof. Buddhe M.V

NBA Accredited & ISO 9001:2015 certified


VIDYA VIKAS PRATISHTHAN POLYTECHNIC SOLAPUR
NBA Accredited & ISO 9001:2015 certified
VIDYA VIKAS PRATISHTHAN POLYTECHNIC,
SOLAPUR

This is to certify that the Project entitled

“Detecting traffic Rules Voilence ”


Has been completed By

Name of the Students Enrolment No. Seat No.


PHATE SUJAL HARIDAS 2208540067 217087
SUPSANDE TANISHKA RAJENDRA 2208540119 217125
KAVADE VAIBHAV DATTATRAY 2208540128 217132
AWCHARE ANVITA ANIL 2208540143 217140
KADAM OMKAR AUDUMBAR 2208540172 217161
T.Y.(Computer Engineering)
Institute Code – 0854

Has been submitted in partial fulfillment of Project in “Diploma in


Computer Engineering” as per the curriculum laid by M.S.B.T.E. Mumbai,
during the academic year 2024-2025

Prof. Buddhe M.V Prof. Dhobale M.R.


(Guide) (H.O.D.)

(External Examiner) (Principal)


NBA Accredited & ISO 9001:2015 certified VIDYA
VIKAS PRATISHTHAN POLYTECHNIC,
SOLAPUR

This is to certify that MR. KAVADE VAIBHAV DATTATRAY Seat No.

217132 of sixth semester of “Diploma in Computer Engineering” of Institute

V.V.P. Polytechnic, Solapur (0854) has Completed the Final Year Project

Work satisfactory in Subject “Capstone Project Execution & Report Writing

(22060)” for the Academic year 2024-25 as prescribed in the curriculum.

Prof. Buddhe M.V. Prof. Dhobale M.R.


(Guide) (H.O.D.)

(External Examiner) (Principal)


Declaration

We the undersigned have submitted the report for the proposed project work entitled

Detecting Traffic Rules Voilence ”

We declare that we have submitted the report after through study &it is not
copied from any other source.

Sr.No. Name of Students Seat No. Sign

217087
1 PHATE SUJAL HARIDAS

217125
2 SUPSANDE TANISHKA RAJENDRA

217132
3 KAVADE VAIBHAV DATTATRAY

AWCHARE ANVITA ANIL 217140


4

KADAM OMKARAUDUMBAR 217161


5

Allotted Guide: Prof. Buddhe.M.V

Dated Sign of Guide:


INDEX

Title Page No

1
1. Chapter 1 1-2
Introduction 2
2. Chapter 2 3-5
Literature Survey 4
3. Chapter 3 6-7
Scope of Project 6
4. Chapter 4 8-9
Problem Definition 8
5. Chapter 5 10-17
Requirement Gathering 11
System Design 14
Use Case Diagram 15
Data Flow Diagram 16
6. Chapter 6 18-14
Code 19
Output 38
7. Chapter 7 41-45
Testcases 42
8. Chapter 8 46-50
Conclusion 47
Future Scope 48
References 49
Action Plan 50
ABSTRACT

Every now and then we hear about road accidents. The most
common cause of these accidents is Over-speeding. So we
proposed a computer vision based solution using deep learning
that automatically detects traffic violators. The main objective is
to detect vehicles that do not follow the rules of traffic, such as
over- speeding, overloading, not wearing helmet and running on
the wrong side of the road. We use Yolov3 for object detection
and Deep Sort for tracking the vehicles and pedestrians. The
system detects the type of violation along with the vehicle
information, maintains a log of violations, provides a detailed
dashboard and provides alerts to the traffic police personnel. The
logs can also be used for forensic purposes.

In the proposed approach, we employed a two-stage process. In


the first stage, pre-trained models are introduced for the
detection of motorcycle riders without helmets, triple riding on
bikes, and accident detection. In the second stage, we integrated
number plate recognition, achieved through YOLOv8, and
character recognition, facilitated using the EasyOCR library,
along with the detection of vehicle images to gather evidence
necessary for taking appropriate action. The proposed model's
performance is evaluated on traffic videos, and the results are
obtained and analyzed using Python. In conclusion, our
proposed system promises to improve public safety by detecting
and deterring traffic rule violations.
Detecting Traffic Rule Violence

CHAPTER 1

1|Page
Detecting Traffic Rule Violence

INTRODUCTION

Detecting traffic rule violations is a critical component of modern transportation systems.


Nowadays, the number of road accidents is happening, and implementing effective solutions
has become essential. The objective of our project is to minimize accidents by addressing key
violations. Traffic rule violation detection systems, leveraging technologies like computer
vision and AI, are designed to enhance road safety and enforce traffic regulations by
automatically identifying violations like speeding, red light running, or lane violations, and
alerting authorities.

Our system incorporates features such as detecting riders not wearing helmets, identifying
vehicles speed limits, and recognizing those driving on the wrong side of the road. The system
automatically detects the vehicle's license plate and takes prompt action. A warning message is
sent to the vehicle owner, notifying them of the violation. This proactive approach aims to
enhance road safety by encouraging compliance with traffic rules and reducing the risk of
accidents.

the increasing number of cars in cities can cause high volume of traffic, and implies that traffic
violations become more critical nowadays in Bangladesh and also around the world. This
causes severe destruction of property and more accidents that may endanger the lives of the
people. To solve the alarming problem and prevent such unfathomable consequences, traffic
violation detection systems are needed. For which the system enforces proper traffic
regulations at all times, and apprehend those who does not comply. A traffic violation detection
system must be realized in real-time as the authorities track the roads all the time. Hence, traffic
enforcers will not only be at ease in implementing safe roads accurately, but also efficiently;
as the traffic detection system detects violations faster than humans. This system can detect
most common three types of traffic violation in real-time which are signal violation, parking
violation and wrong direction violation. A user friendly graphical interface is associated with
the system to make it simple for the user to operate the system, monitor traffic and take action
against the violations of traffic rules.

2|Page
Detecting Traffic Rule Violence

3|Page
Detecting Traffic Rule Violence

LITERATURE SURVEY

1. The research paper "Detecting Motorcycle Helmet Use with Deep Learning by
Felix Wilhelm Siebert and Hanhe Lin introduces an automated system for
identifying motorcycle helmet usage from video footage. The primary objective of this
study is to enhance the efficiency and accuracy of helmet use data collection, which
plays a crucial role in implementing targeted injury prevention strategies. By utilizing
deep learning techniques, the researchers aim to provide a scalable solution for real-
time monitoring of helmet compliance among motorcyclists. To develop the detection
system, the researchers compiled a dataset of 91,000 annotated video frames
collected from seven cities in Myanmar. The performance evaluation of the algorithm
was conducted by comparing its detection results with human observations. The
findings demonstrated that the system’s helmet use detection accuracy was within a
margin of -4.4% to
+2.1% when compared to human-recorded data.

2. The research paper titled "Automatic Helmet Violation Detection Using


Deep Learning Algorithms" presents a novel approach to identifying
motorcyclists who violate helmet-wearing regulations through the application
of deep learning
techniques. The study emphasizes the importance of helmet use in preventing injuries
and fatalities among motorcycle riders and aims to enhance traffic surveillance systems
by automating the detection of helmet violations. In this study, the authors propose a
Convolutional Neural Network (CNN)-based multi-task learning (MTL) method
designed to detect and track individual motorcycles in video footage. The system is
capable of identifying the number of riders on each motorcycle and determining
whether each rider is wearing a helmet.

4|Page
Detecting Traffic Rule Violence

3. The research paper titled "Real-Time Helmet Violation Detection Using YOLOv5
and Ensemble Learning" presents an innovative approach to automatically identify
motorcyclists violating helmet-wearing regulations. The study leverages the YOLOv5
deep learning model, renowned for its real-time object detection capabilities, to detect
motorcyclists and assess helmet usage. Trained on a dataset comprising 100 videos, the
model demonstrates its applicability in accurately detecting helmet violations under
various conditions. The system achieves a mean Average Precision (mAP) score of
0.5267, indicating a moderate level of precision in detecting helmet use. The
implementation of this system can significantly aid in providing real-time data on
helmet usage, facilitating targeted enforcement and educational campaigns, and
enhancing road safety measures, particularly in regions where motorcycles are a
prevalent mode of transportation.The research paper titled "Automated Helmet
Detection and Citation System Using License Plate Recognition" by Ketha Ankith
Kumar and Dr. Md. Asif introduces an innovative approach to enhance road safety by
automating the detection of motorcyclists who violate helmet-wearing regulations. The
study addresses the increasing number of motorcycle accidents attributed to riders
neglecting helmet use and proposes a system that integrates advanced surveillance video
analysis with machine learning techniques to identify and penalize offenders effectively.

4. The research paper titled "Traffic Violation Prediction Using Deep Learning
Based on Helmets with Number Plate Recognition" by Dr. S G Balakrishnan,
Dhinakaran P M, Dinesh A, Gokul M, and Akash T presents an innovative approach
to enhancing road safety by automating the detection of motorcycle riders who violate
helmet-wearing regulations. The study leverages advanced image processing techniques
and machine learning algorithms to identify non-compliant riders and facilitate
enforcement actions.The proposed system utilizes the YOLOv8 (You Only Look Once
version 8) algorithm, renowned for its real-time object detection capabilities, to
accurately identify motorcycle riders not wearing helmets.

5|Page
Detecting Traffic Rule Violence

CHAPTER 3

6|Page
Detecting Traffic Rule Violence

SCOPE OF PROJECT

Project focused on detecting traffic rule violations could encompass a wide range of violations,
from red light running and speeding and seatbelt violations, and aim to improve road safety
through automated detection and enforcement. the use of advanced computer vision techniques,
such as YOLOv5 for object detection, EasyOCR for number plate recognition, and OpenCV
for image processing.

Vehicle Type Classification: Distinguish between different types of vehicles (cars, motorcycles,
buses, trucks, etc.).

Vehicle Tracking: Track the movement of vehicles over time and across different locations.

Traffic Monitoring and Management:

• Monitoring traffic density to optimize signal timings and manage congestion.


• Providing updates on traffic conditions to commuters in real-time.

Public Awareness:

• Informing and educating citizens about traffic rules and road safety measures.
• Encouraging responsible driving through campaigns and programs.

7|Page
Detecting Traffic Rule Violence

CHAPTER 4

8|Page
Detecting Traffic Rule Violence

Problem Definition

A mobile-based traffic violation detection system that uses video analysis to automatically identify
helmet violations, speed violations, number plates, and triple-seat riding, with an option for manual fine
entry by authorities.

9|Page
Detecting Traffic Rule Violence

CHAPTER 5

10 | P a g e
Detecting Traffic Rule Violence

Proposed Methodology for Traffic Violation Detection System

➢ Requirement Gathering:
▪ Functional Requirements
Helmet Detection: The system must accurately determine whether motorcyclists
are wearing helmets using image processing techniques.

Number Plate Recognition: The system should recognize and extract vehicle
number plates from captured images or video feeds.

Real-Time Notifications: The system must send alerts to vehicle owners regarding
detected violations, including details of the offense.

Speed Detection: The system must measure and record the speed of vehicles in real-
time.

Fetch details of vehicles: The system should retrieve and display information about
the vehicles detected, such as make, model, and registration details.

11 | P a g e
Detecting Traffic Rule Violence

▪ Non-Functional Requirements
Reliability: The system should consistently provide accurate detection results
with minimal false positives or negatives.

Performance: The system must operate in real-time, processing video feeds with
low latency to ensure timely notifications.

Scalability: The system should be designed to accommodate future enhancements,


such as integration with IoT devices or additional traffic violation detection
features.

▪ Hardware Requirements
Processing Power: Minimum of 8GB RAM and an Intel i5 processor or higher to
handle image processing tasks efficiently.

Camera: High-resolution camera capable of capturing clear images or video for


accurate detection.

Android device: Android 12 or upward

▪ Software Requirements
Operating System: Windows OS for compatibility with development tools.

Development Tools: Android Studio for application development.

Technologies: Use of Java programming language for application development,


XML for layout design.

12 | P a g e
Detecting Traffic Rule Violence

▪ User Requirements

User Interface: The system should have a user-friendly interface for traffic
police to monitor violations and access reports.

Feedback Mechanism: The system must allow users to provide feedback on


detection accuracy and system performance for continuous improvement.

System Overview
The traffic violation detection system will utilize advanced technologies such as
Android vision, and data processing to monitor traffic violations in real-time. The
primary objectives of the system include:

- Detecting whether motorcyclists are wearing helmets.


- Recognizing vehicle number plates for identification of violators.
- Sending alerts to vehicle owners regarding violations.
- Detecting whether motorcyclists are driving in limited speed or crossing
over speed.

➢ Literature Review
Conduct a thorough literature review to understand existing systems and
technologies used in traffic violation detection, particularly focusing on
implementations using Java and XML.

This includes:

Analysing Previous Research: Review studies and projects that have


utilized Java for helmet detection and number plate recognition, examining
their methodologies and outcomes.

Reviewing Algorithm Effectiveness: Evaluate the performance of various


algorithms and technologies implemented in Java for image processing and
machine learning, assessing their accuracy and efficiency in detecting
traffic violations.

Identifying Methodological Gaps: Highlight shortcomings in current


systems that utilize Java and XML, pinpointing areas

13 | P a g e
Detecting Traffic Rule Violence

System Design

Architecture Diagram: Create an architectural diagram that illustrates the system components and their
interactions. The main components include:

- Image capture module.


- Violation detection module.
- Notification module.

14 | P a g e
Detecting Traffic Rule Violence

Activity Diagram: Develop a Activity diagram to represent the interactions between users
(traffic police) and the system. Key use cases include:

- Detecting helmet usage.


- Recognizing number plates.
- Sending alerts to vehicle owners.

15 | P a g e
Detecting Traffic Rule Violence

Use case Diagram: Develop a use case diagram to represent the interactions between
users (traffic police) and the system. Key use cases include:

- Detecting helmet usage.


- Recognizing number plates.
- Sending alerts to vehicle owners.

16 | P a g e
Detecting Traffic Rule Violence

Data Flow Diagram:

Create data flow diagrams to visualize how data moves through the system.
This includes:

- Level 0 Data Flow Diagram: Overview of the system inputs and outputs.

17 | P a g e
Detecting Traffic Rule Violence

Level 1 Data Flow Diagram: Detailed view of internal processes,


including helmet detection and number plate recognition.

18 | P a g e
Detecting Traffic Rule Violence

CHAPTER 6

19 | P a g e
Detecting Traffic Rule Violence

Program Code:
XML code:- xmlns:android="http://schemas.android.co
m/apk/res/android"
activity_splash:-
android:layout_width="match_parent"
android:layout_height="match_parent"
<?xml version="1.0" encoding="utf-8"?>
android:backgroundTint="#903737"
<LinearLayout
xmlns:android="http://schemas.android.co android:padding="16dp">
m/apk/res/android"
<LinearLayout
xmlns:app="http://schemas.android.com/ap android:layout_width="match_parent"
k/res-auto"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent" android:gravity="center"
android:gravity="center" android:orientation="vertical" >
android:orientation="vertical"
android:background="@color/white"> <pl.droidsonroids.gif.GifImageView
<com.airbnb.lottie.LottieAnimationView android:id="@+id/iv2"
android:id="@+id/lottieAnimation"
android:layout_width="300dp" android:layout_width="wrap_content"
android:layout_height="300dp" android:layout_height="200dp"
android:src="@drawable/gif2"
app:lottie_rawRes="@raw/splash_animatio
n" android:layout_gravity="center_horizontal"
app:lottie_autoPlay="true" />
app:lottie_loop="true"/>
<Button
<TextView android:id="@+id/anprButton"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="StreetScan" android:layout_height="wrap_content"
android:textSize="24sp"
android:layout_marginBottom="16dp"
android:textColor="@android:color/black" android:text="ANPR" />
android:textStyle="bold"/>
</LinearLayout> <Button

android:id="@+id/manualEntryButton"

activity_dashboard:-
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_height="wrap_content"

20 | P a g e
Detecting Traffic Rule Violence

android:layout_width="match_parent"
android:layout_marginBottom="16dp"
android:text="Manual Fine Entry" android:layout_height="wrap_content"
/>
android:layout_marginBottom="16dp"
<Button android:text="Add Traffic Rules" />
android:id="@+id/fvdButton"
<Button
android:layout_width="match_parent"
android:id="@+id/violationsHistoryButton
android:layout_height="wrap_content" "

android:layout_marginBottom="16dp" android:layout_width="match_parent"
android:text="FVD" />
android:layout_height="wrap_content"
<Button
android:layout_marginBottom="16dp"
android:id="@+id/fineIssuanceButton" android:text="Violations History"
/>
android:layout_width="match_parent"
<Button
android:layout_height="wrap_content"
android:id="@+id/HelmetB
android:layout_marginBottom="16dp" utton"
android:text="Fine Reminder" />
android:layout_width="match_parent"

<Button
android:layout_height="wrap_content"

android:id="@+id/addCameraFootageButt
android:layout_marginBottom="16dp"
on"
android:text="Helmet Detection" />
android:layout_width="match_parent" </LinearLayout>
</ScrollView>
android:layout_height="wrap_content"

android:layout_marginBottom="16dp" activity_anpractivity:-
android:text="Add Camera
Footage" />
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<Button xmlns:android="http://schemas.android.co
m/apk/res/android"
android:id="@+id/addTrafficRulesButton" android:layout_width="match_parent"
android:layout_height="match_parent"

21 | P a g e
Detecting Traffic Rule Violence

android:padding="10dp">

<pl.droidsonroids.gif.GifImageView activity_manual_entry:-
android:id="@+id/iv1" <?xml version="1.0" encoding="utf-8"?>
android:layout_width="wrap_content" <ScrollView
android:layout_height="70dp" xmlns:android="http://schemas.android.co
m/apk/res/android"
android:src="@drawable/gif1"
android:layout_width="match_parent"
android:layout_marginLeft="20dp"/>
android:layout_height="match_parent"
android:padding="16dp">
<TextureView
android:id="@+id/textureView"
<LinearLayout
android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_below="@id/iv1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="10dp"/>
android:gravity="center_horizontal">

<TextView
<EditText
android:id="@+id/numberPlateText"
android:layout_width="wrap_content"
android:id="@+id/vehicleNumberInput"

android:layout_height="wrap_content"
android:layout_width="match_parent"

android:layout_below="@id/textureView"
android:layout_height="wrap_content"
android:text="Detected Number Plate:
"
android:inputType="textCapCharacters"
android:textSize="18sp"
android:hint="Enter Vehicle
Number"
android:layout_marginBottom="16dp"/>
android:layout_marginBottom="16dp" />
<Button
android:id="@+id/detectButton" <EditText
android:layout_width="wrap_content"
android:id="@+id/violationTypeInput"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/numberPlateT
ext" android:layout_height="wrap_content"
android:text="Start Detection"/> android:hint="Enter Violation
</RelativeLayout> Type"

android:layout_marginBottom="16dp" />

22 | P a g e
Detecting Traffic Rule Violence

<EditText android:layout_marginBottom="16dp"
android:layout_gravity="right"
android:id="@+id/fineAmountInput"
android:layout_marginRight="15dp"/>
android:layout_width="match_parent"
<Button
android:layout_height="wrap_content" android:id="@+id/submitButton"
android:hint="Enter Fine Amount"
android:layout_width="match_parent"
android:inputType="numberDecimal"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" /> android:text="Submit"

<EditText android:layout_marginBottom="16dp" />


android:id="@+id/locationInput"
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent" android:id="@+id/iv3"

android:layout_height="wrap_content" android:layout_width="wrap_content"
android:hint="Enter Location"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" /> android:src="@drawable/img"
android:layout_marginTop="16dp"
<EditText android:layout_gravity="center" />
</LinearLayout>
android:id="@+id/officerNameInput"
</ScrollView>
android:layout_width="match_parent"

android:layout_height="wrap_content" activity_fvdactivity:-
android:hint="Enter Officer Name"
<?xml version="1.0" encoding="utf-8"?>
android:layout_marginBottom="16dp" /> <LinearLayout
xmlns:android="http://schemas.android.co
m/apk/res/android"
<Button

xmlns:app="http://schemas.android.com/ap
android:id="@+id/selectProofButton"
k/res-auto"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content" android:layout_marginTop="50dp"
android:text="Upload proof" android:orientation="vertical"

23 | P a g e
Detecting Traffic Rule Violence

android:padding="16dp"> android:layout_marginBottom="16dp"
android:visibility="gone" />.
<EditText
<Button
android:id="@+id/vehicleNumberInput" android:id="@+id/isf1"
android:layout_width="match_parent" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:hint="Enter Vehicle Number" android:layout_below="@id/vehicleDetails
Output"
android:inputType="textCapCharacters" android:layout_gravity="right"
android:padding="12dp" /> android:layout_marginTop="10dp"
android:layout_marginRight="15dp"
<Button android:layout_marginBottom="16dp"
android:padding="12dp"
android:id="@+id/fetchDetailsButton" android:text="Issue Fine"
android:layout_width="match_parent" android:visibility="gone" />
</LinearLayout>
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:padding="12dp"
Activity_fine_issuance:-
android:text="Fetch Details" />

<?xml version="1.0" encoding="utf-8"?>


<TextView
<ScrollView
xmlns:android="http://schemas.android.co
android:id="@+id/vehicleDetailsOutput" m/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
android:layout_marginTop="16dp"
android:padding="12dp"
<LinearLayout
android:text=""
android:layout_width="match_parent"
android:textSize="18dp" />
android:layout_height="wrap_content"
<ProgressBar android:orientation="vertical">
android:id="@+id/progressBar"
android:layout_width="wrap_content" <LinearLayout

android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_gravity="center"

24 | P a g e
Detecting Traffic Rule Violence

android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginBottom="10dp">
android:padding="8dp" >
<EditText
<EditText
android:id="@+id/fineAmountInput"
android:id="@+id/vehicleNumberInput"
android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="48dp"
android:layout_height="48dp" android:hint="Enter fine amount"

android:inputType="textCapCharacters" android:inputType="numberDecimal"
android:hint="Enter vehicle android:minHeight="48dp"/>
number"
android:minHeight="48dp"/> <Button
</LinearLayout>
android:id="@+id/selectDateButton"
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="wrap_content" android:text="Select Due Date"
/>
android:orientation="vertical"
</LinearLayout>
android:padding="8dp”>

<Button
<EditText
android:id="@+id/issueFineButton"
android:id="@+id/violationTypeInput"
android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="48dp"
android:text="Remind Fine"
android:hint="Enter violation
type"
android:layout_marginBottom="16dp"
android:minHeight="48dp"/>
android:minHeight="48dp"/>
</LinearLayout>
<LinearLayout
<androidx.recyclerview.widget.RecyclerVi
android:layout_width="match_parent"
ew

android:layout_height="wrap_content"
android:id="@+id/finesRecyclerView"
android:orientation="vertical"
android:padding="8dp" android:layout_width="match_parent"

25 | P a g e
Detecting Traffic Rule Violence

<TextView
android:layout_height="wrap_content"/>
</LinearLayout> android:id="@+id/ownerNameTextView"
</ScrollView> android:layout_width="wrap_content"

android:layout_height="wrap_content"
activity_add_camera_footage:- android:text="Owner Name: "
android:textSize="18sp"
<?xml version="1.0" encoding="utf-8"?> android:textStyle="bold"
<LinearLayout android:layout_marginTop="8dp" />
xmlns:android="http://schemas.android.co </LinearLayout>
m/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" activity_add_traffic_rules:-
android:orientation="vertical"
android:padding="16dp"> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<Button xmlns:android="http://schemas.android.co
android:id="@+id/addVideoButton" m/apk/res/android"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content" android:padding="16dp">
android:text="Add Video" />
<EditText
<VideoView android:id="@+id/ruleInput"
android:id="@+id/videoView" android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="250dp" android:layout_height="wrap_content"
android:layout_marginTop="16dp" /> android:hint="Enter traffic rule"

android:layout_marginBottom="16dp"/>
<TextView

android:id="@+id/numberPlateTextView" <Button
android:layout_width="wrap_content" android:id="@+id/addRuleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="wrap_content"
android:text="Add Rule"
android:text="Number Plate: " android:layout_below="@id/ruleInput"
android:textSize="18sp"
android:textStyle="bold" android:layout_marginBottom="16dp"/>
android:layout_marginTop="16dp" />

26 | P a g e
Detecting Traffic Rule Violence

<androidx.recyclerview.widget.RecyclerVi android:layout_height="match_parent"
ew android:padding="16dp">

android:id="@+id/rulesRecyclerView"
<androidx.camera.view.PreviewView
android:layout_width="match_parent"
android:id="@+id/previewView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="300dp"
android:layout_below="@id/addRuleButto
n"/> android:layout_marginBottom="16dp"/>
</RelativeLayout>
<TextView
android:id="@+id/helmetStatus"
android:layout_width="wrap_content"
activity_violations_history:- android:layout_height="wrap_content"

<?xml version="1.0" encoding="utf-8"?> android:layout_below="@id/previewView"


<LinearLayout android:text="Detected Helmet: "
xmlns:android="http://schemas.android.co android:textSize="18sp"
m/apk/res/android"
android:layout_width="match_parent" android:layout_marginBottom="16dp"/>
android:layout_height="match_parent"
android:orientation="vertical" <Button
android:padding="16dp"> android:id="@+id/detectButton"
android:layout_width="wrap_content"

<androidx.recyclerview.widget.RecyclerVi android:layout_height="wrap_content"
ew
android:layout_below="@id/helmetStatus"
android:id="@+id/violationsRecyclerView android:text="Start Detection"/>
"
</RelativeLayout>
android:layout_width="match_parent"

android:layout_height="match_parent"
android:layout_marginTop="16dp" />
</LinearLayout>
JAVA code:-

SplashActivity:-
activity_helmet:-
package com.example.myapplication;
import android.content.Intent;
<RelativeLayout
xmlns:android="http://schemas.android.co import android.os.Bundle;
m/apk/res/android" import android.os.Handler;
android:layout_width="match_parent" import android.widget.Toast;

27 | P a g e
Detecting Traffic Rule Violence

import androidx.annotation.NonNull; ==BiometricManager.BIOMETRIC_SUCC


import ESS;
androidx.appcompat.app.AppCompatActivi }
ty; private void showBiometricPrompt() {
import Executor executor =
androidx.biometric.BiometricManager; ContextCompat.getMainExecutor(this);
import BiometricPrompt biometricPrompt =
androidx.biometric.BiometricPrompt; new BiometricPrompt(this, executor,
import new
androidx.core.content.ContextCompat; BiometricPrompt.AuthenticationCallback()
import {
com.airbnb.lottie.LottieAnimationView; @Override
import java.util.concurrent.Executor; public void
public class SplashActivity extends onAuthenticationError(int errorCode,
AppCompatActivity { @NonNull CharSequence errString) {

@Override super.onAuthenticationError(errorCode,
errString);
protected void onCreate(Bundle
savedInstanceState) { Toast.makeText(SplashActivity.this,
"Authentication error: " + errString,
super.onCreate(savedInstanceState);
Toast.LENGTH_SHORT).show();
}
setContentView(R.layout.activity_splash);
LottieAnimationView lottieAnimation
= findViewById(R.id.lottieAnimation); @Override
lottieAnimation.playAnimation(); public void
onAuthenticationSucceeded(@NonNull
new Handler().postDelayed(() -> {
BiometricPrompt.AuthenticationResult
if (checkBiometricSupport()) { result) {
showBiometricPrompt();
} else { super.onAuthenticationSucceeded(result);
startMainActivity(); startMainActivity();
} }
}, 3000);
} @Override
public void
private boolean checkBiometricSupport() onAuthenticationFailed() {
{
BiometricManager biometricManager super.onAuthenticationFailed();
= BiometricManager.from(this); Toast.makeText(SplashActivity.this,
return "Authentication failed",
biometricManager.canAuthenticate(Biomet Toast.LENGTH_SHORT).show();
ricManager.Authenticators.BIOMETRIC_S }
TRONG) });

28 | P a g e
Detecting Traffic Rule Violence

BiometricPrompt.PromptInfo private final int[] gifResources = {


promptInfo = new R.drawable.gif5,
BiometricPrompt.PromptInfo.Builder()
R.drawable.gif3,
.setTitle("Biometric
R.drawable.gif4,
Authentication")
R.drawable.gif2
.setSubtitle("Authenticate to
proceed to the app") };
private int currentGifIndex = 0;
.setNegativeButtonText("Cancel") @Override
.build(); protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
biometricPrompt.authenticate(promptInfo);
} setContentView(R.layout.activity_dashboar
d);
Button anprButton =
private void startMainActivity() {
findViewById(R.id.anprButton);
startActivity(new
Button addCameraFootageButton =
Intent(SplashActivity.this,
findViewById(R.id.addCameraFootageButt
MainActivity.class));
on);
finish();
Button addTrafficRulesButton =
} findViewById(R.id.addTrafficRulesButton
} );
Button fineIssuanceButton =
findViewById(R.id.fineIssuanceButton);
Dashboard_Activity:- Button manualEntryButton =
findViewById(R.id.manualEntryButton);
Button violationsHistoryButton =
package com.example.myapplication;
findViewById(R.id.violationsHistoryButto
n);
import android.content.Intent; Button helmetButton =
import android.os.Bundle; findViewById(R.id.HelmetButton);
import android.os.Handler; Button fvdButton =
import android.widget.Button; findViewById(R.id.fvdButton);
import gifImageView =
androidx.appcompat.app.AppCompatActivi findViewById(R.id.iv2);
ty; handler = new Handler();
import com.bumptech.glide.Glide; gifRunnable = new Runnable() {
import pl.droidsonroids.gif.GifImageView; @Override
public class DashboardActivity extends public void run() {
AppCompatActivity { loadNextGif();
private GifImageView gifImageView; handler.postDelayed(this, 8000);
private Handler handler; // Repeat every 8 seconds
private Runnable gifRunnable; }

29 | P a g e
Detecting Traffic Rule Violence

}; 1) % gifResources.length;
handler.post(gifRunnable); }
anprButton.setOnClickListener(v -> @Override
startActivity(new protected void onDestroy() {
Intent(DashboardActivity.this,
super.onDestroy();
ANPRActivity.class)));

handler.removeCallbacks(gifRunnable);
addCameraFootageButton.setOnClickListe
ner(v -> startActivity(new }
Intent(DashboardActivity.this, }
AddCameraFootageActivity.class)));
ANPRActivity:-
addTrafficRulesButton.setOnClickListener
(v -> startActivity(new
Intent(DashboardActivity.this, package com.example.myapplication;
AddTrafficRulesActivity.class)));
import android.Manifest;
fineIssuanceButton.setOnClickListener(v - import
> startActivity(new android.content.pm.PackageManager;
Intent(DashboardActivity.this,
FineIssuanceActivity.class))); import android.graphics.*;
import android.hardware.camera2.*;
manualEntryButton.setOnClickListener(v - import android.os.*;
> startActivity(new import android.util.*;
Intent(DashboardActivity.this, import android.view.*;
ManualEntryActivity.class)));
import android.widget.*;
violationsHistoryButton.setOnClickListene import com.bumptech.glide.Glide;
r(v -> startActivity(new import androidx.annotation.NonNull;
Intent(DashboardActivity.this, import
ViolationsHistoryActivity.class))); androidx.appcompat.app.AppCompatActivi
helmetButton.setOnClickListener(v -> ty;
startActivity(new import androidx.core.app.ActivityCompat;
Intent(DashboardActivity.this, import
HelmetActivity.class))); androidx.core.content.ContextCompat;
fvdButton.setOnClickListener(v -> import pl.droidsonroids.gif.*;
startActivity(new
Intent(DashboardActivity.this, import
FVDActivity.class))); } com.google.android.gms.vision.Frame;
private void loadNextGif() { import
com.google.android.gms.vision.text.*;
Glide.with(this)
import java.util.Arrays;
.asGif()

.load(gifResources[currentGifIndex]) public class ANPRActivity extends


AppCompatActivity {
.into(gifImageView);
private static final int
currentGifIndex = (currentGifIndex + CAMERA_PERMISSION_REQUEST_C

30 | P a g e
Detecting Traffic Rule Violence

ODE = 100; PackageManager.PERMISSION_GRANT


private static final String TAG = ED) {
"ANPRActivity";
private TextureView textureView; ActivityCompat.requestPermissions(this,
new
private CameraDevice cameraDevice;
String[]{Manifest.permission.CAMERA},
private CameraCaptureSession CAMERA_PERMISSION_REQUEST_C
cameraCaptureSession; ODE);
private CaptureRequest.Builder } else {
captureRequestBuilder;
openCamera();
private Handler backgroundHandler;
}
private HandlerThread
detectButton.setOnClickListener(v ->
backgroundThread;
{
private TextView numberPlateText;
if (isDetecting) {
private Button detectButton;
stopDetection();
private boolean isDetecting = false;
detectButton.setText("Start
@Override Detection");
protected void onCreate(Bundle } else {
savedInstanceState) {
startDetection();
super.onCreate(savedInstanceState);
detectButton.setText("Stop
Detection");
setContentView(R.layout.activity_anpracti
}
vity);
});
textureView =
findViewById(R.id.textureView); }
numberPlateText = private void openCamera() {
findViewById(R.id.numberPlateText); CameraManager cameraManager =
detectButton = (CameraManager)
findViewById(R.id.detectButton); getSystemService(CAMERA_SERVICE);
GifImageView gifImageView = try {
findViewById(R.id.iv1); String cameraId =
GifDrawable gifDrawable = cameraManager.getCameraIdList()[0];
(GifDrawable) if
gifImageView.getDrawable(); (ActivityCompat.checkSelfPermission(this,
gifDrawable.start(); Manifest.permission.CAMERA) !=
PackageManager.PERMISSION_GRANT
ImageView imageView =
ED) {
findViewById(R.id.iv1);
Log.e(TAG, "Camera permission
Glide.with(this)
not granted");
.asGif()
return;
.load(R.drawable.gif1)
}
.into(imageView);
if cameraManager.openCamera(cameraId,
(ContextCompat.checkSelfPermission(this, new CameraDevice.StateCallback() {
Manifest.permission.CAMERA) !=
@Override

31 | P a g e
Detecting Traffic Rule Violence

public void onOpened(@NonNull s.asList(surface), new


CameraDevice camera) { CameraCaptureSession.StateCallback() {
Log.d(TAG, "Camera @Override
opened"); public void
cameraDevice = camera; onConfigured(@NonNull
startPreview(); CameraCaptureSession session) {
} cameraCaptureSession =
session;
@Override
try {
public void
cameraCaptureSession.setRepeatingReques
onDisconnected(@NonNull CameraDevice
t(captureRequestBuilder.build(), null,
camera) {
backgroundHandler);
Log.d(TAG, "Camera
Log.d(TAG, "Camera
disconnected");
preview started");
cameraDevice.close();
} catch
cameraDevice = null; (CameraAccessException e) {
} Log.e(TAG,
@Override "CameraAccessException: " +
public void onError(@NonNull e.getMessage(), e);
CameraDevice camera, int error) { }
Log.e(TAG, "Camera error: " + }
error); @Override
cameraDevice.close(); public void
cameraDevice = null; onConfigureFailed(@NonNull
} CameraCaptureSession session) {
}, backgroundHandler);
Toast.makeText(ANPRActivity.this,
} catch (CameraAccessException e) { "Failed to start camera preview",
Log.e(TAG, Toast.LENGTH_SHORT).show();
"CameraAccessException: " + Log.e(TAG, "Camera preview
e.getMessage(), e); configuration failed");
}
}
}
}, backgroundHandler);
private void startPreview() { } catch (CameraAccessException e) {
SurfaceTexture surfaceTexture = Log.e(TAG,
textureView.getSurfaceTexture();
"CameraAccessException: " +
Surface surface = new e.getMessage(), e);
Surface(surfaceTexture);
}
try {
}
captureRequestBuilder =
private void startDetection() {
cameraDevice.createCaptureRequest(Came
raDevice.TEMPLATE_PREVIEW); isDetecting = true;
backgroundThread = new
captureRequestBuilder.addTarget(surface); HandlerThread("CameraBackground");
cameraDevice.createCaptureSession(Array backgroundThread.start();

32 | P a g e
Detecting Traffic Rule Violence

backgroundHandler = new e.getMessage(), e);


Handler(backgroundThread.getLooper()); }
SurfaceTexture surfaceTexture = }
textureView.getSurfaceTexture();
@Override
Surface surface = new
public void
Surface(surfaceTexture);
onConfigureFailed(@NonNull
CameraCaptureSession session) {
try {
captureRequestBuilder = Toast.makeText(ANPRActivity.this,
cameraDevice.createCaptureRequest(Came "Failed to start camera preview",
raDevice.TEMPLATE_PREVIEW); Toast.LENGTH_SHORT).show();
Log.e(TAG, "Camera session
captureRequestBuilder.addTarget(surface); configuration failed");
cameraDevice.createCaptureSession(Array }
s.asList(surface), new
}, backgroundHandler);
CameraCaptureSession.StateCallback() {
} catch (CameraAccessException e) {
@Override
Log.e(TAG,
public void
"CameraAccessException: " +
onConfigured(@NonNull
e.getMessage(), e);
CameraCaptureSession session) {
}
cameraCaptureSession =
session; }
try { private void stopDetection() {
cameraCaptureSession.setRepeatingReques isDetecting = false;
t(captureRequestBuilder.build(), new if (backgroundHandler != null) {
CameraCaptureSession.CaptureCallback() backgroundHandler.removeCallbacksAnd
{ Messages(null);
@Override backgroundHandler.getLooper().quitSafely
public void ();
onCaptureCompleted(@NonNull backgroundThread.quitSafely();
CameraCaptureSession session, @NonNull Log.d(TAG, "Background thread
CaptureRequest request, @NonNull stopped");
TotalCaptureResult result) {
}
super.onCaptureCompleted(session,
request, result); numberPlateText.setText("Detected
Number Plate: ");
if (isDetecting) {
}
detectNumberPlate(); private void detectNumberPlate() {
} Bitmap bitmap =
textureView.getBitmap();
}
if (bitmap != null) {
}, backgroundHandler);
TextRecognizer textRecognizer =
} catch
new
(CameraAccessException e) {
TextRecognizer.Builder(getApplicationCo
Log.e(TAG, ntext()).build();
"CameraAccessException: " +
if (!textRecognizer.isOperational())

33 | P a g e
Detecting Traffic Rule Violence

{ registrationdate[0]=
Toast.makeText(this, "Text "01/Dec/2023";
recognizer not available", insurance[0] ="valid Upto
Toast.LENGTH_SHORT).show(); 30/Nov/2028";
Log.e(TAG, "Text recognizer not Rto[0]="Solapur";
operational"); break;
return; case "MH45AR8808":
} ownerName[0] = "Sujal
Frame frame = new Phate";
Frame.Builder().setBitmap(bitmap).build(); vehicleModel[0] = "Pulsar
SparseArray<TextBlock> 125";
textBlocks = textRecognizer.detect(frame); registrationdate[0]=
if (textBlocks.size() > 0) { "22/May/2022";
StringBuilder detectedText = new insurance[0] ="valid Upto
StringBuilder(); 21/May/2027";
for (int i = 0; i < textBlocks.size(); Rto[0]="Akluj";
i++) { break;
TextBlock textBlock = case "MH13ER4700":
textBlocks.valueAt(i);
ownerName[0] = "Sitaram
detectedText.append(textBlock.getValue())
Phate";
.append("");
vehicleModel[0] = "Bullet
}
350 classic";
String cleanedDetectedText =
registrationdate[0]=
detectedText.toString().replaceAll("[\\n\\r]
"08/Jan/2025";
+", "").replaceAll("\\s+", "").trim();
insurance[0] ="Valid Upto
Log.d(TAG, "Detected Number
07/jan/2030";
Plate (cleaned): " + cleanedDetectedText);
Rto[0]="Solapur";
String detectedNumberPlate =
cleanedDetectedText; break;
final String[] ownerName = {""}; case "MH13EC0047":
final String[] vehicleModel = ownerName[0] = "Sumit
{""}; Phate";
final String[] registrationdate = vehicleModel[0] = "Hyundai
{""}; Creta";
final String[] insurance ={""}; registrationdate[0]=
"01/May/2022";
final String[] Rto ={""};
insurance[0] ="Valid Upto
String rtoCode =
30/April/2027";
detectedNumberPlate.length() >= 4 ?
detectedNumberPlate.substring(0, 4) : ""; Rto[0]="Solapur";
switch (detectedNumberPlate) { break;
case "MH13EH2124": case "MH13ET4747":
ownerName[0] = "Mahesh ownerName[0] = "Suyash
Ganpatil"; Phate";
vehicleModel[0] = "Jawa"; vehicleModel[0] = "CB

34 | P a g e
Detecting Traffic Rule Violence

Shine"; vehicleModel[0] = "Activa";


registrationdate[0]= registrationdate[0]=
"31/Jan/2025"; "12/Nov/2023";
insurance[0] ="Valid Upto insurance[0] ="valid upto
30/Jan/2030"; 11/Nov/2028";
Rto[0]="Solapur"; Rto[0]="Pune";
break; break;
case "MH13EC7861": case "MH14LD7264":
ownerName[0] = "Vasim ownerName[0] = "Vaishnavi
Mujawar"; Tarange";
vehicleModel[0] = "Suzuki vehicleModel[0] = "Activa";
XL6"; registrationdate[0]=
registrationdate[0]= "12/Nov/2023";
"21/May/2023"; insurance[0] ="valid upto
insurance[0] 11/Nov/2028";
="20/May/2028"; Rto[0]="Pune";
Rto[0]="Solapur"; break;
break; default:
case "MH13ES4747": ownerName[0] = "Unknown
ownerName[0] = "Suraj Owner";
Phate"; vehicleModel[0] =
vehicleModel[0] = "Unknown Model";
"Mahindra Thar RWD"; registrationdate[0]= "Can't
registrationdate[0]= Find";
"21/Jan/2025"; insurance[0] ="Can't Find";
insurance[0] ="Valid Upto
20/Jan/2030";
switch (rtoCode) {
Rto[0]="Solapur";
case "MH01":
break;
Rto[0] = "Central
case "MH13EH1638": Mumbai";
ownerName[0] = "Asmita break;
Tele";
case "MH02":
vehicleModel[0] = "Access
Rto[0] = "West
125";
Mumbai";
registrationdate[0]=
break;
"12/Nov/2023";
case "MH03":
insurance[0] ="valid upto
11/Nov/2028"; Rto[0] = "East
Mumbai";
Rto[0]="Solapur";
break;
break;
case "MH04":
case "MH12WH4566":
Rto[0] = "Thane";
ownerName[0] = "Pratiksha
Tarange"; break;

35 | P a g e
Detecting Traffic Rule Violence

case "MH05": Rto[0] = "Srirampur";


Rto[0] = "Kalyan"; break;
break; case "MH18":
case "MH06": Rto[0] = "Dhule";
Rto[0] = "Raigad"; break;
break; case "MH19":
case "MH07": Rto[0] = "Jalgaon";
Rto[0] = break;
"Sindhudurga"; case "MH20":
break; Rto[0] =
case "MH08": "Sambhajinagar";
Rto[0] = "Ratnagiri"; break;
break; case "MH21":
case "MH09": Rto[0] = "Jalna";
Rto[0] = "Kolhapur"; break;
break; case "MH22":
case "MH10": Rto[0] = "Parbhani";
Rto[0] = "Sangli"; break;
break; case "MH23":
case "MH11": Rto[0] = "Beed";
Rto[0] = "Satara"; break;
break; case "MH24":
case "MH12": Rto[0] = "Latur";
Rto[0] = "Pune"; break;
break; case "MH25":
case "MH13": Rto[0] = "DharaShiv";
Rto[0] = "Solapur"; break;
break; case "MH26":
case "MH14": Rto[0] = "Nanded";
Rto[0] = "Pimpri- break;
Chnchwad"; case "MH27":
break; Rto[0] = "Amravati";
case "MH15": break;
Rto[0] = "Nashik"; case "MH28":
break; Rto[0] = "Buldhana";
case "MH16": break;
Rto[0] = case "MH29":
"Ahilyanagar";
Rto[0] = "Yavatmal";
break;
break;
case "MH17":
case "MH30":

36 | P a g e
Detecting Traffic Rule Violence

Rto[0] = "Akola"; Rto[0] = "Washi new


break; Mumbai";
case "MH31": break;
Rto[0] = "Nagpur"; case "MH44":
break; Rto[0] = "Ambajogai";
case "MH32": break;
Rto[0] = "Wardha"; case "MH45":
break; Rto[0] = "Akluj";
case "MH33": break;
Rto[0] = "Gadchiroli"; case "MH46":
break; Rto[0] = "Panvel";
case "MH34": break;
Rto[0] = "Chandrapur"; case "MH47":
break; Rto[0] = "Malvan";
case "MH35": break;
Rto[0] = "Gondia"; case "MH48":
break; Rto[0] = "Vasai virar";
case "MH36": break;
Rto[0] = "Bhandara"; case "MH49":
break; Rto[0] = "East Nagpur";
case "MH37": break;
Rto[0] = "Washim"; case "MH50":
break; Rto[0] = "Karad";
case "MH38": break;
Rto[0] = "Hingoli"; case "MH51":
break; Rto[0] = "Nashik
Gramin";
case "MH39":
break;
Rto[0] = "Nandurbar";
default:
break;
Rto[0] = "Unknown
case "MH40":
RTO";
Rto[0] = "Nagpur
break;
Gramin";
break; }
break;
case "MH41":
}
Rto[0] = "Malegaon";
runOnUiThread(() -> {
break;
case "MH42":
numberPlateText.setText("Detected
Rto[0] = "Baramati"; Number Plate: \n" + detectedNumberPlate +
break; "\nOwner: " +
case "MH43": ownerName[0] +

37 | P a g e
Detecting Traffic Rule Violence

"\nModel: " + if (grantResults.length > 0 &&


vehicleModel[0] + grantResults[0] ==
"\nRegistration Date: " + PackageManager.PERMISSION_GRANT
registrationdate[0] + ED) {
"\nInsurance: " + openCamera();
insurance[0] + } else {
"\nRTO: "+ Rto[0]); Toast.makeText(this, "Camera
}); permission is required",
Toast.LENGTH_SHORT).show();
}
Log.e(TAG, "Camera permission
} else {
not granted");
Log.e(TAG, "Failed to capture
}
bitmap from TextureView");
}
}
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
ManualEntryActivity:-
if (cameraDevice != null) {
cameraDevice.close();
package com.example.myapplication;
cameraDevice = null;
Log.d(TAG, "Camera device
closed"); import android.Manifest;
} import android.content.Intent;
if (backgroundHandler != null) { import android.net.Uri;
import android.os.Bundle;
backgroundHandler.getLooper().quitSafely import android.telephony.SmsManager;
(); import android.widget.*;
backgroundThread.quitSafely(); import androidx.annotation.NonNull;
Log.d(TAG, "Background thread import
safely quit"); androidx.appcompat.app.AppCompatActivi
} ty;
} import androidx.biometric.*;
@Override import androidx.core.app.ActivityCompat;
public void import
onRequestPermissionsResult(int androidx.core.content.ContextCompat;
requestCode, @NonNull String[] import
permissions, @NonNull int[] grantResults) android.content.pm.PackageManager;
{
import java.text.SimpleDateFormat;
super.onRequestPermissionsResult(request
Code, permissions, grantResults); import java.util.*;
if (requestCode == import java.util.concurrent.Executor;
CAMERA_PERMISSION_REQUEST_C
ODE) { public class ManualEntryActivity extends

38 | P a g e
Detecting Traffic Rule Violence

AppCompatActivity { public void


private EditText vehicleNumberInput, onAuthenticationSucceeded(@NonNull
violationTypeInput, fineAmountInput, BiometricPrompt.AuthenticationResult
locationInput, officerNameInput; result) {
private Button submitButton,
selectProofButton; super.onAuthenticationSucceeded(result);
sendSmsToOwner(vehicleNumberInput.get
private static final int
Text().toString().trim());
SMS_PERMISSION_REQUEST_CODE =
sendEmailWithProof(vehicleNumberInput.
1;
getText().toString().trim());
private static final int
}
PICK_PROOF_REQUEST_CODE = 2;
@Override
private Uri proofUri; // Store the selected
proof public void
onAuthenticationFailed() {
private Executor executor;
super.onAuthenticationFailed();
private BiometricPrompt
Toast.makeText(ManualEntryActivity.this,
biometricPrompt;
"Fingerprint authentication failed",
@Override Toast.LENGTH_SHORT).show();
protected void onCreate(Bundle }
savedInstanceState) {
@Override
super.onCreate(savedInstanceState);
public void
setContentView(R.layout.activity_manual_
onAuthenticationError(int errorCode,
entry);
@NonNull CharSequence errString) {
vehicleNumberInput =
super.onAuthenticationError(errorCode,
findViewById(R.id.vehicleNumberInput);
errString);
violationTypeInput = Toast.makeText(ManualEntryActivity.this,
findViewById(R.id.violationTypeInput); "Authentication error: " + errString,
fineAmountInput = Toast.LENGTH_SHORT).show();
findViewById(R.id.fineAmountInput); }
locationInput = });
findViewById(R.id.locationInput);
submitButton.setOnClickListener(v ->
officerNameInput = {
findViewById(R.id.officerNameInput);
String vehicleNumber =
submitButton = vehicleNumberInput.getText().toString().tri
findViewById(R.id.submitButton); m();
selectProofButton = String violationType =
findViewById(R.id.selectProofButton); violationTypeInput.getText().toString().tri
m();
executor = String fineAmount =
ContextCompat.getMainExecutor(this); fineAmountInput.getText().toString().trim(
biometricPrompt = new );
BiometricPrompt(this, executor, new String location =
BiometricPrompt.AuthenticationCallback() locationInput.getText().toString().trim();
{ String officerName =
@Override officerNameInput.getText().toString().trim(
);

39 | P a g e
Detecting Traffic Rule Violence

if (proofUri == null) { }
Toast.makeText(this, "Please private Map<String, String[]>
upload proof before submitting.", getContactDetailsForVehicle() {
Toast.LENGTH_SHORT).show(); Map<String, String[]> contactDetails
return; = new HashMap<>();
} contactDetails.put("MH13ET4747",
if (vehicleNumber.length() != 10) { new String[]{"8767464704",
"suyashphate@gmail.com"});
Toast.makeText(this, "Please
enter a valid 10-digit vehicle number", contactDetails.put("MH13CR2669",
Toast.LENGTH_SHORT).show(); new String[]{"9699713823",
"pratikshatarnge567@gmail.com"});
return;
contactDetails.put("MH45AR8808",
}
new String[]{"7709294500",
if (vehicleNumber.isEmpty() || "kawadevaibhav004@gmail.com"});
violationType.isEmpty() ||
contactDetails.put("MH13BT4393",
fineAmount.isEmpty() || location.isEmpty()
new String[]{"7387687992",
|| officerName.isEmpty()) {
"owner4@example.com"});
Toast.makeText(this, "Please fill
contactDetails.put("MH13EH1638",
in all fields.",
new String[]{"8698088003",
Toast.LENGTH_SHORT).show();
"owner5@example.com"});
return;
contactDetails.put("MH13EC7861",
} new String[]{"9370403327",
if "owner6@example.com"});
(ActivityCompat.checkSelfPermission(this, return contactDetails;
Manifest.permission.SEND_SMS) !=
}
PackageManager.PERMISSION_GRANT
ED) {
private void sendSmsToOwner(String
ActivityCompat.requestPermissions(this, vehicleNumber) {
new Map<String, String[]> contactDetails
String[]{Manifest.permission.SEND_SMS = getContactDetailsForVehicle();
}, String[] details =
SMS_PERMISSION_REQUEST_CODE); contactDetails.get(vehicleNumber);
} else { if (details != null && details.length >
authenticateWithFingerprint(); 0) {
} String phoneNumber = details[0]; //
}); First element is the phone number
String fineAmount =
selectProofButton.setOnClickListener(v -> fineAmountInput.getText().toString();
{ String currentDateTime = new
Intent intent = new SimpleDateFormat("dd/MM/yyyy
Intent(Intent.ACTION_PICK); HH:mm:ss",
Locale.getDefault()).format(new Date());
intent.setType("image/* video/*");
startActivityForResult(intent, String message = "Alert: Your
PICK_PROOF_REQUEST_CODE); vehicle " + vehicleNumber + " has violated
the traffic rule at " + currentDateTime +
});

40 | P a g e
Detecting Traffic Rule Violence

". You have been fined INR " + currentDateTime +


fineAmount + ".\nFor more info, contact the " at " + location + ". The fine
nearest RTO."; imposed is INR " + fineAmount + ". Please
SmsManager smsManager = contact the nearest RTO for further
SmsManager.getDefault(); details.\n\nRegards,\nTraffic Police";
try {
Intent emailIntent = new
smsManager.sendTextMessage(phoneNum Intent(Intent.ACTION_SEND);
ber, null, message, null, null); emailIntent.setType("vnd.android.cursor.di
Toast.makeText(this, "Alert sent r/email");
to " + phoneNumber, emailIntent.putExtra(Intent.EXTRA_EMAI
Toast.LENGTH_SHORT).show(); L, new String[]{email});
emailIntent.putExtra(Intent.EXTRA_SUBJ
} catch (Exception e) {
ECT, subject);
Toast.makeText(this, "Error emailIntent.putExtra(Intent.EXTRA_TEXT
sending SMS: " + e.getMessage(), , message);
Toast.LENGTH_SHORT).show(); emailIntent.putExtra(Intent.EXTRA_STRE
} AM, proofUri); // Attach the proof
} else { try {
Toast.makeText(this, "No contact startActivity(Intent.createChooser(emailInt
details found for vehicle " + vehicleNumber, ent, "Send Email"));
Toast.LENGTH_SHORT).show(); } catch (Exception e) {
} Toast.makeText(this, "Error
} sending email: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
private void sendEmailWithProof(String
vehicleNumber) { }
Map<String, String[]> contactDetails } else {
= getContactDetailsForVehicle(); Toast.makeText(this, "No email
String[] details = found for vehicle " + vehicleNumber,
contactDetails.get(vehicleNumber); Toast.LENGTH_SHORT).show();
if (details != null && details.length > }
1) { }
String email = details[1]; private void
String fineAmount = authenticateWithFingerprint() {
fineAmountInput.getText().toString(); if (isBiometricAvailable()) {
String location = BiometricPrompt.PromptInfo
locationInput.getText().toString(); promptInfo = new
String currentDateTime = new BiometricPrompt.PromptInfo.Builder()
SimpleDateFormat("dd/MM/yyyy .setTitle("Biometric
HH:mm:ss", Authentication")
Locale.getDefault()).format(new Date()); .setSubtitle("Authenticate to
String subject = "Traffic Violation proceed to send SMS and email")
Alert: Vehicle " + vehicleNumber;
String message = "Dear Vehicle .setNegativeButtonText("Cancel")
Owner,\n\nYour vehicle " + vehicleNumber .build();
+ " has committed a traffic violation on " +

41 | P a g e
Detecting Traffic Rule Violence

biometricPrompt.authenticate(promptInfo); import android.content.Intent;


} else { import android.os.Bundle;
Toast.makeText(this, "Biometric import android.os.Handler;
authentication not available",
import android.view.View;
Toast.LENGTH_SHORT).show();
import android.widget.Button;
}
import android.widget.EditText;
}
import android.widget.ProgressBar;
private boolean isBiometricAvailable() {
import android.widget.TextView;
BiometricManager biometricManager
= BiometricManager.from(this); import
androidx.appcompat.app.AppCompatActivi
return
ty;
biometricManager.canAuthenticate(Biomet
ricManager.Authenticators.BIOMETRIC_S public class FVDActivity extends
TRONG) AppCompatActivity {
== private EditText vehicleNumberInput;
BiometricManager.BIOMETRIC_SUCCE private TextView vehicleDetailsOutput;
SS; private ProgressBar progressBar;
} private Button isf1;
@Override @Override
protected void onActivityResult(int protected void onCreate(Bundle
requestCode, int resultCode, Intent data) { savedInstanceState) {
super.onActivityResult(requestCode, super.onCreate(savedInstanceState);
resultCode, data);
if (requestCode == setContentView(R.layout.activity_fvdactivi
PICK_PROOF_REQUEST_CODE && ty);
resultCode == RESULT_OK && data !=
vehicleNumberInput =
null) {
findViewById(R.id.vehicleNumberInput);
proofUri = data.getData();
vehicleDetailsOutput =
Toast.makeText(this, "Proof findViewById(R.id.vehicleDetailsOutput);
selected: " + proofUri,
Button fetchDetailsButton =
Toast.LENGTH_SHORT).show();
findViewById(R.id.fetchDetailsButton);
} else {
progressBar =
Toast.makeText(this, "No proof findViewById(R.id.progressBar);
selected",
isf1 = findViewById(R.id.isf1);
Toast.LENGTH_SHORT).show();
}
fetchDetailsButton.setOnClickListener(ne
} w View.OnClickListener() {
} @Override
public void onClick(View v) {
progressBar.setVisibility(View.VISIBLE);
FVDActivit:-
vehicleDetailsOutput.setText("Fetching
vehicle details...");
package com.example.myapplication;

42 | P a g e
Detecting Traffic Rule Violence

String vehicleNumber = ManualEntryActivity.class);


vehicleNumberInput.getText().toString().tri startActivity(intent);
m();
}
new Handler().postDelayed(new
});
Runnable() {
}
@Override
private VehicleDetails
public void run() {
getVehicleDetails(String vehicleNumber) {
VehicleDetails
VehicleDetails details = new
vehicleDetails =
VehicleDetails();
getVehicleDetails(vehicleNumber);
progressBar.setVisibility(View.GONE); switch (vehicleNumber) {
if (vehicleDetails != null) { case "MH13EH2124":
String detailsMessage = details.ownerName = "Mahesh
"Owner: " + vehicleDetails.ownerName + Ganpatil";
"\n" + details.vehicleModel = "Jawa";
"Model: " + details.registrationDate =
vehicleDetails.vehicleModel + "\n" + "01/Dec/2023";
"Registration Date: " details.insurance = "valid Upto
+ vehicleDetails.registrationDate + "\n" + 30/Nov/2028";
"Insurance: " + details.rto = "Solapur";
vehicleDetails.insurance + "\n" + break;
"RTO: " + case "MH45AR8808":
vehicleDetails.rto;
details.ownerName = "Sujal
vehicleDetailsOutput.setText(detailsMessa
Phate";
ge);
details.vehicleModel = "Pulsar
125";
isf1.setVisibility(View.VISIBLE);
details.registrationDate =
} else {
"22/May/2022";
vehicleDetailsOutput.setText("Vehicle
number not found."); details.insurance = "valid Upto
21/May/2027";
}
details.rto = "Akluj";
}
break;
}, 2000); // Delay of 2 seconds
(2000 milliseconds) case "MH13ER4700":
} details.ownerName = "Sitaram
Phate";
});
details.vehicleModel = "Bullet
isf1.setOnClickListener(new
350 classic";
View.OnClickListener() {
details.registrationDate =
@Override
"08/Jan/2025";
public void onClick(View v) {
details.insurance = "Valid Upto
// Intent to navigate to 07/Jan/2030";
ManualEntryActivity
details.rto = "Solapur";
Intent intent = new
break;
Intent(FVDActivity.this,
case "MH13EC0047":

43 | P a g e
Detecting Traffic Rule Violence

details.ownerName = "Sumit case "MH13EH1638":


Phate"; details.ownerName = "Asmita
details.vehicleModel = "Hyundai Tele";
Creta"; details.vehicleModel = "Access
details.registrationDate = 125";
"01/May/2022"; details.registrationDate =
details.insurance = "Valid Upto "12/Nov/2023";
30/April/2027"; details.insurance = "valid upto
details.rto = "Solapur"; 11/Nov/2028";
break; details.rto = "Solapur";
case "MH13ET4747": break;
details.ownerName = "Suyash default:
Phate"; return null;
details.vehicleModel = "CB }
Shine";
return details;
details.registrationDate =
}
"31/Jan/2025";
private static class VehicleDetails {
details.insurance = "Valid Upto
30/Jan/2030"; String ownerName;
details.rto = "Solapur"; String vehicleModel;
break; String registrationDate;
case "MH13EC7861": String insurance;
details.ownerName = "Vasim String rto;
Mujawar"; }
details.vehicleModel = "Suzuki }
XL6";
details.registrationDate =
"21/May/2023";
FineIssuanceActivity:-
details.insurance =
"20/May/2028";
package com.example.myapplication;
details.rto = "Solapur";
break;
import android.Manifest;
case "MH13ES4747":
import android.app.DatePickerDialog;
details.ownerName = "Suraj
Phate"; import
android.content.pm.PackageManager;
details.vehicleModel =
"Mahindra Thar RWD"; import android.os.Bundle;
details.registrationDate = import android.telephony.SmsManager;
"21/Jan/2025"; import android.widget.Button;
details.insurance = "Valid Upto import android.widget.DatePicker;
20/Jan/2030"; import android.widget.EditText;
details.rto = "Solapur"; import android.widget.Toast;
break; import

44 | P a g e
Detecting Traffic Rule Violence

androidx.appcompat.app.AppCompatActivi adapter = new FineAdapter(fines);


ty;
import androidx.core.app.ActivityCompat; finesRecyclerView.setLayoutManager(new
import LinearLayoutManager(this));
androidx.recyclerview.widget.LinearLayou
tManager; finesRecyclerView.setAdapter(adapter);
import
androidx.recyclerview.widget.RecyclerVie selectDateButton.setOnClickListener(v ->
w; showDatePickerDialog());
import java.util.ArrayList; issueFineButton.setOnClickListener(v
import java.util.Calendar; -> {
import java.util.List; String vehicleNumber =
vehicleNumberInput.getText().toString().tri
m();
public class FineIssuanceActivity extends
String violationType =
AppCompatActivity {
violationTypeInput.getText().toString().tri
private EditText vehicleNumberInput, m();
violationTypeInput, fineAmountInput;
String fineAmountStr =
private Button issueFineButton, fineAmountInput.getText().toString().trim(
selectDateButton; );
private RecyclerView if (vehicleNumber.length() != 10) {
finesRecyclerView;
Toast.makeText(this, "Please
private FineAdapter adapter; enter a valid 10-digit vehicle number",
private List<Fine> fines; Toast.LENGTH_SHORT).show();
private String selectedDate; return;
@Override }
protected void onCreate(Bundle if (!vehicleNumber.isEmpty() &&
savedInstanceState) { !violationType.isEmpty() &&
super.onCreate(savedInstanceState); !fineAmountStr.isEmpty() &&
selectedDate != null) {
setContentView(R.layout.activity_fine_issu double fineAmount =
ance); Double.parseDouble(fineAmountStr);
vehicleNumberInput = fines.add(new
findViewById(R.id.vehicleNumberInput); Fine(vehicleNumber, violationType,
fineAmount));
violationTypeInput =
findViewById(R.id.violationTypeInput); adapter.notifyDataSetChanged();
fineAmountInput =
findViewById(R.id.fineAmountInput); sendSmsReminder(vehicleNumber);
issueFineButton = vehicleNumberInput.setText("");
findViewById(R.id.issueFineButton); violationTypeInput.setText("");
selectDateButton = fineAmountInput.setText("");
findViewById(R.id.selectDateButton); selectedDate = null;
finesRecyclerView = selectDateButton.setText("Select
findViewById(R.id.finesRecyclerView); Due Date");
fines = new ArrayList<>();

45 | P a g e
Detecting Traffic Rule Violence

} else { (ActivityCompat.checkSelfPermission(this,
Toast.makeText(this, "Please fill Manifest.permission.SEND_SMS) !=
all fields and select a due date", PackageManager.PERMISSION_GRANT
Toast.LENGTH_SHORT).show(); ED) {
}
ActivityCompat.requestPermissions(this,
});
new
} String[]{Manifest.permission.SEND_SMS
private void showDatePickerDialog() { }, 1);
Calendar calendar = } else {
Calendar.getInstance(); String phoneNumber =
int currentYear = getPhoneNumberForVehicle(vehicleNumb
calendar.get(Calendar.YEAR); er);
int currentMonth = if (phoneNumber != null) {
calendar.get(Calendar.MONTH); String message = "Reminder:
int currentDay = Please pay your pending fine for the vehicle
calendar.get(Calendar.DAY_OF_MONTH) " + vehicleNumber +
; " of INR: " + fineAmount +
DatePickerDialog datePickerDialog = ". Payment due by: " + selectedDate + ".";
new DatePickerDialog(this, SmsManager smsManager =
(view, year, month, dayOfMonth) SmsManager.getDefault();
-> { try {
selectedDate = dayOfMonth + smsManager.sendTextMessage(phoneNum
"/" + (month + 1) + "/" + year; // Month is ber, null, message, null, null);
zero-based Toast.makeText(this,
selectDateButton.setText("Due "Reminder sent to " + phoneNumber,
Date: " + selectedDate); Toast.LENGTH_SHORT).show();
}, } catch (Exception e) {
currentYear, currentMonth, e.printStackTrace();
currentDay); Toast.makeText(this, "Error
datePickerDialog.getDatePicker().setMinD sending SMS: " + e.getMessage(),
ate(System.currentTimeMillis()); Toast.LENGTH_SHORT).show();
Calendar maxDate = }
Calendar.getInstance();
} else {
maxDate.add(Calendar.MONTH, 6); //
Toast.makeText(this, "No phone
Add 6 months
number found for vehicle " +
datePickerDialog.getDatePicker().setMaxD
vehicleNumber,
ate(maxDate.getTimeInMillis());
Toast.LENGTH_SHORT).show();
datePickerDialog.show();
}
}
}
public void sendSmsReminder(String
}
vehicleNumber) {
private String
String fineAmount =
getPhoneNumberForVehicle(String
fineAmountInput.getText().toString();
vehicleNumber) {
if
switch (vehicleNumber) {

46 | P a g e
Detecting Traffic Rule Violence

case "MH45AR8808":
return "7709294500"; AddCameraFootageActivity:-
case "MH13ET4747":
return "8767464704"; package com.example.myapplication;
case "MH13BT4393":
return "7387687992"; import android.annotation.SuppressLint;
case "MH13CR2669": import android.content.Intent;
return "9699713823"; import android.net.Uri;
case "MH13EC7861": import android.os.Bundle;
return "9370403327"; import android.provider.MediaStore;
case "MH13EH1638": import android.widget.Button;
return "8698088003"; import android.widget.TextView;
default: import android.widget.VideoView;
return null; import androidx.annotation.Nullable;
} import
} androidx.appcompat.app.AppCompatActivi
ty;
@Override
public class AddCameraFootageActivity
public void
extends AppCompatActivity {
onRequestPermissionsResult(int
requestCode, String[] permissions, int[] private static final int
grantResults) { PICK_VIDEO_REQUEST = 1;
private VideoView videoView;
super.onRequestPermissionsResult(request private Button addVideoButton;
Code, permissions, grantResults); private TextView numberPlateTextView,
if (requestCode == 1) { ownerNameTextView;
if (grantResults.length > 0 && @SuppressLint("MissingInflatedId")
grantResults[0] == @Override
PackageManager.PERMISSION_GRANT
protected void onCreate(Bundle
ED) {
savedInstanceState) {
String vehicleNumber =
super.onCreate(savedInstanceState);
vehicleNumberInput.getText().toString().tri
setContentView(R.layout.activity_add_cam
m();
era_footage);
videoView =
sendSmsReminder(vehicleNumber);
findViewById(R.id.videoView);
} else {
addVideoButton =
Toast.makeText(this, "Permission findViewById(R.id.addVideoButton);
to send SMS is required",
numberPlateTextView =
Toast.LENGTH_SHORT).show();
findViewById(R.id.numberPlateTextView)
} ;
} ownerNameTextView =
} findViewById(R.id.ownerNameTextView);
} addVideoButton.setOnClickListener(v
-> {

47 | P a g e
Detecting Traffic Rule Violence

Intent intent = new


Intent(Intent.ACTION_PICK, ViolationsHistoryActivity:-
MediaStore.Video.Media.EXTERNAL_C
ONTENT_URI);
package com.example.myapplication;
startActivityForResult(intent,
PICK_VIDEO_REQUEST);
}); import android.os.AsyncTask;
} import android.os.Bundle;
import android.util.Log;
@Override import
androidx.appcompat.app.AppCompatActivi
protected void onActivityResult(int
ty;
requestCode, int resultCode, @Nullable
Intent data) { import
androidx.recyclerview.widget.LinearLayou
super.onActivityResult(requestCode,
tManager;
resultCode, data);
import
if (requestCode ==
androidx.recyclerview.widget.RecyclerVie
PICK_VIDEO_REQUEST && resultCode
w;
== RESULT_OK && data != null) {
import java.util.List;
Uri videoUri = data.getData();
public class ViolationsHistoryActivity
if (videoUri != null) {
extends AppCompatActivity {
private RecyclerView
videoView.setVideoURI(videoUri);
violationsRecyclerView;
videoView.start();
private ViolationAdapter
violationAdapter;
processVideoForNumberPlate(videoUri);
@Override
}
protected void onCreate(Bundle
} savedInstanceState) {
} super.onCreate(savedInstanceState);

private void setContentView(R.layout.activity_violation


processVideoForNumberPlate(Uri s_history);
videoUri) { violationsRecyclerView =
String detectedNumberPlate = findViewById(R.id.violationsRecyclerVie
"MH12AB1234"; w);
String ownerName = "Rajesh Sharma"; violationsRecyclerView.setLayoutManager
(new LinearLayoutManager(this));
numberPlateTextView.setText("Number addSampleViolations();
Plate: " + detectedNumberPlate); logViolationsCount();
ownerNameTextView.setText("Owner new LoadViolationsTask().execute();
Name: " + ownerName); }
} private void logViolationsCount() {
} new AsyncTask<Void, Void,
Integer>() {

48 | P a g e
Detecting Traffic Rule Violence

@Override @Override
protected Integer protected List<Violation>
doInBackground(Void... voids) { doInBackground(Void... voids) {
return return
AppDatabase.getInstance(ViolationsHistor AppDatabase.getInstance(ViolationsHistor
yActivity.this) yActivity.this)
.violationDao() .violationDao()
.getAllViolations() .getAllViolations();
.size(); }
} @Override
@Override protected void
protected void onPostExecute(List<Violation> violations)
onPostExecute(Integer count) { {
Log.d("ViolationsHistoryActivity", violationAdapter = new
"Number of violations: " + count); ViolationAdapter(violations);
} violationsRecyclerView.setAdapter(violati
onAdapter);
}.execute();
}
}
}
private void addSampleViolations() {
}
new AsyncTask<Void, Void, Void>()
{
@Override
protected Void
doInBackground(Void... voids) {
ViolationDao violationDao =
AppDatabase.getInstance(ViolationsHistor
yActivity.this)
.violationDao();
violationDao.insert(new
Violation("Speeding", "Main Street",
"2023-10-01 10:00:00", 100.00));
violationDao.insert(new
Violation("Red Light Jump", "Downtown",
"2023-10-02 11:00:00", 150.00));
violationDao.insert(new
Violation("Illegal Parking", "City Center",
"2023-10-03 12:00:00", 200.00));
return null;
}
}.execute();
}
private class LoadViolationsTask extends
AsyncTask<Void, Void, List<Violation>>
{

49 | P a g e
Detecting Traffic Rule Violence

Output

50 | P a g e
Detecting Traffic Rule Violence

51 | P a g e
Detecting Traffic Rule Violence

52 | P a g e
Detecting Traffic Rule Violence

CHAPTER 7

53 | P a g e
Detecting Traffic Rule Violence

Test cases for result

54 | P a g e
Detecting Traffic Rule Violence

55 | P a g e
Detecting Traffic Rule Violence

56 | P a g e
Detecting Traffic Rule Violence

57 | P a g e
Detecting Traffic Rule Violence

CHAPTER 8

CONCLUSION AND
FUTURE SCOPE

58 | P a g e
Detecting Traffic Rule Violence

Conclusion

The STREET SCAN application successfully integrates computer vision (OpenCV) and a database-driven
fine system to detect and record traffic violations effectively. By leveraging image processing techniques, the
system identifies rule-breakers and cross-references their vehicle details with an existing database, ensuring
accurate and automated enforcement. This solution not only enhances traffic monitoring efficiency but also
promotes road safety by discouraging violations through systematic penalty tracking. The integration of real-
time detection and digital record-keeping minimizes manual intervention, reducing human errors and
increasing accountability.

59 | P a g e
Detecting Traffic Rule Violence

Future Scope

1. Government Permissions and Integration:


For full-scale deployment, the application can be integrated with official traffic and vehicle
registration databases (e.g., VAHAN in India or DMV in other countries) through secured
APIs. This would require government approval and compliance with data protection laws.
Once integrated, the system could
,Automatically fetch owner information from number plates, Generate e- challans (digital
fines),Send violation notifications via SMS or email, Log violations in official records

2. Triple-Seat Detection Enhancement with Identity Recognition:


In future versions, the triple-seat detection module can be enhanced by integrating facial
recognition or ID-based identification systems. This would help in verifying individual
identities and matching them with government records or databases. Such features can be
especially useful in tracking repeat offenders or minors involved in traffic violations.

3. Live CCTV Camera Footage Integration:


The system can be upgraded to directly process live feeds from roadside CCTV or surveillance
cameras. This will enable continuous, real-time monitoring of traffic violations across large
areas without manual intervention. With proper camera calibration, the system can detect
violations as they happen and alert traffic control centers instantly.

4. Automated E-Challan System:


With government integration, the app can automatically generate and issue e- challans based
on violation type, location, and offender history. This will reduce manual effort and ensure
consistency in enforcement.

60 | P a g e
Detecting Traffic Rule Violence

REFERENCES

1. Siebert & Lin (Helmet Detection with Deep Learning):


An automated deep learning system detects motorcycle helmet use from video with high accuracy using
a dataset of 91,000 frames.

2. Automatic Helmet Violation Detection (CNN + MTL):


This study uses a CNN-based multi-task learning model to detect helmet violations and count riders on
motorcycles from video footage.

3. YOLOv5 Helmet Detection with Ensemble Learning:


The paper implements YOLOv5 for real-time helmet violation detection, achieving moderate accuracy
across diverse video conditions.

4. Helmet Detection with Number Plate Recognition (YOLOv8 + OCR):


This research integrates YOLOv8 and OCR to detect helmet violations and extract license plate data for
automatic enforcement.

61 | P a g e
Detecting Traffic Rule Violence

ACTION PLAN

Stage 1: Analysis, Literature Survey review, 10-Aug-2024 to 24-Sep-2024


Forming problem statement

Stage 2: Designing 5-Oct-2024 to 20-Oct-2024

Stage 3: Implementation of the module 1-Nov-2024 to 10-Jan-2025

Stage 4: Integration of Modules & 1-Feb-2025 to 28-Feb-2025


Testing

Stage 5: Deployment & Results 1-Mar-2025 to 15-Mar-2025

62 | P a g e

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy