cppVAIBHAV
cppVAIBHAV
PROJECT REPORT
On
By
V.V.P. Polytechnic, Solapur (0854) has Completed the Final Year Project
We the undersigned have submitted the report for the proposed project work entitled
We declare that we have submitted the report after through study &it is not
copied from any other source.
217087
1 PHATE SUJAL HARIDAS
217125
2 SUPSANDE TANISHKA RAJENDRA
217132
3 KAVADE VAIBHAV DATTATRAY
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.
CHAPTER 1
1|Page
Detecting Traffic Rule Violence
INTRODUCTION
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.
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.
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
➢ 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.
▪ Hardware Requirements
Processing Power: Minimum of 8GB RAM and an Intel i5 processor or higher to
handle image processing tasks efficiently.
▪ Software Requirements
Operating System: Windows OS for compatibility with development tools.
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.
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:
➢ 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:
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:
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:
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:
16 | P a g e
Detecting Traffic Rule Violence
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
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"
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" />
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"
<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
@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
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()
30 | P a g e
Detecting Traffic Rule Violence
31 | P a g e
Detecting Traffic Rule Violence
32 | P a g e
Detecting Traffic Rule Violence
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
35 | P a g e
Detecting Traffic Rule Violence
36 | P a g e
Detecting Traffic Rule Violence
37 | P a g e
Detecting Traffic Rule Violence
38 | P a g e
Detecting Traffic Rule Violence
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
41 | P a g e
Detecting Traffic Rule Violence
42 | P a g e
Detecting Traffic Rule Violence
43 | P a g e
Detecting Traffic Rule Violence
44 | P a g e
Detecting Traffic Rule Violence
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
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
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
60 | P a g e
Detecting Traffic Rule Violence
REFERENCES
61 | P a g e
Detecting Traffic Rule Violence
ACTION PLAN
62 | P a g e