PotholeDetectionPythonReport
PotholeDetectionPythonReport
in
by
Naman Rathore R (38110350)
Naman N Jain(38110349)
SCHOOL OF COMPUTING
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
APRIL 2021
i
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with ―A‖ grade by NAAC
Jeppiaar Nagar, Rajiv Gandhi Salai, Chennai – 600
119
www.sathyabama.ac.in
BONAFIDE CERTIFICATE
This is to certify that this Project Report is the bonafide work of Naman Rathore R
(38110350),Naman N Jain38110349who carried out the project entitled “DETECTING POTHOLES
USING IMAGE PROCESSING TECHNIQUES AND REAL-WORLD
Internal
Guide Dr. V.
Nagarajan
I Naman Rathore R (38110350) hereby declare that the Project Report entitled “DETECTING
POTHOLES USING IMAGE PROCESSING TECHNIQUES
AND REAL-WORLD FOOTAGE” done by me under the guidance of Dr. V .
Nagarajan is submitted in partial fulfillment of the requirements for the award of
Bachelor of Engineering degree in Computer Science and Engineering.
DATE:
iii
ACKNOWLEDGEMENT
I am pleased to acknowledge my sincere thanks to Board of Management of
SATHYABAMA INSTITUTE OF SCIENCE AND TECHNOLOGY for their kind
encouragement in doing this project and for completing it successfully. I am grateful
to them.
I would like to express my sincere and deep sense of gratitude to my Project Guide
Dr. V. Nagarajan for her valuable guidance, suggestions and constant
encouragement paved way for the successful completion of my project work.
I wish to express my thanks to all Teaching and Non-teaching staff members of the
Department of Computer Science and Engineering who were helpful in many
ways for the completion of the project.
iv
ABSTRACT
Roads are the main mode for transportation, now a days. As we use roads heavily
and frequently it sometimes leads to potholes. Environmental factors also leads to
potholes in several ways. These potholes are main reason for many accidents. A
Scheduled and proper maintenance is required where we need to monitor each and
every road. AS this maintenance of all the roads at a time is not possible because it
is not easy to monitor every single place or just because people ignore to check
which causes formation of potholes that causes unnecessary traffic and many of
accidents. To monitor all the roads this project for pothole detection using image
processing techniques implemented. To test the performance of the proposed
system is going to be implemented in a linux environment using Open CV Library.
Techniques of Image processing which detects the potholes on roads and save the
data of pothole for road maintenance department. This helps in keeping manual
labour to the minimum number. Canny Edge Detecting technique and alone with the
Contour Detecting Technique are techniques of Image Processing we use in the
proposed system. Hough transformation technique in the end gives effective output
of potholes, very accurately.
v
Table of Contents
ABSTRACT v
LIST OF FIGURES vii
i
1 INTRODUCTION 1
1.1 POTHOLE DETECTION 1
1.2 OBJECTIVE 2
1.3 MOTIVATION 2
2 LITERATURE SURVEY 4
2.1 AUTOMATIC POTHOLE DETECTION 4
2.2AUTOMATIC DETECTION AND
NOTIFICATION OF HUMPS ON 5
ROADS
2.3SMART SENSING OF POTHOLES
AND OBSTACLES 6
2.4DETECTION AND NOTIFICATION
OF POTHOLES AND HUMPS 7
2.5AN APPROACH FOR REAL-TIME
ROAD DEFORMATION DETECTION 8
2.6POTHOLES DETECTION BASED
BLOB DETECTION METHOD 9
3 METHODOLOGY 12
3.1 EXISTING SYSTEM 12
3.1.1 Disadvantages 12
3.2 PROPOSED SYSTEM 12
3.2.1 Advantages 13
3.3 FLOW CHART 14
3.4 HARDWARE REQUIREMENTS 15
3.5 SOFTWARE REQUIREMENTS 15
3.5.1 Linux 15
3.5.2 Ubuntu 16
3.5.3 Ubuntu Variants 16
3.5.4 Python 17
3.6 SYSTEM DESIGN 18
3.7 ALGORITHM 19
3.8 CANNY EDGE DETECTION ALGORITHM 19
3.8.1 Gaussian Filter 19
3.8.2 Intensity Gradient 20
3.8.3 Non-Maximum Suppression 21
vi
3.8.4 Double Threshold 22
3.8.5 Edge Tracking By Hysteresis 23
3.9IMAGE THRESHOLDING 24
3.9.1 Otsus’s Method 24
3.10HOUGH TRANSFORM 25
3.10.1 Theory 26
3.10.2 Example 1 27
3.10.3 Example 2 29
REFERENCES 34
APPENDIX 35
A.SOURCE CODE 35
B. SCREENSHOTS 37
C. PUBLICATION WITH PLAGIARISM REPORT 40
vii
LIST OF FIGURES
viii
CHAPTER 1
INTRODUCTION
2
vision-based solutions can detect potholes as well. Regions
corresponding to potholes are represented in a matrix of square tiles
and the estimated shape of the pothole is determined. However, the 2D
vision-based solution can work only under uniform lighting conditions
and cannot obtain the exact depth of potholes. To remove the
limitations of the above approaches, we propose a detection method
based on computer stereo vision, which provides 3-dimensional
measurements. Therefore, the geometric features of potholes can be
determined easily based on computer vision techniques.
1.2 OBJECTIVE
1.3 MOTIVATION
4
potholes for the future use. Ideally the vicinity is every rout till the
next access point.
5
CHAPTER 2
LITERATURE SURVEY
Most of the Indian rural and sub urban roads are not ideal for
driving due to faded lanes, irregular potholes, improper and invisible
road signs. This has led to many accidents causing loss of lives and
severe damage to vehicles. Many techniques have been proposed in the
past to detect these problems using image processing methods. But
there has been little work specifically carried out for detecting such
issues of Indian roads. Potholes can generate damage such as flat tire
and wheel damage, impact and damage of lower vehicle, vehicle
collision, and major accidents. Thus, accurately and quickly detecting
potholes is one of the important tasks for determining proper strategies
in ITS (Intelligent Transportation System) service and road management
system. Several efforts have been made for developing a technology
which can automatically detect and recognize potholes. In this project, a
pothole two dimensional (2D) images based pothole detection method is
used for improving the existing method. This system proposes a system
Automatic detect the number of recently published papers dealing with
crack detection and characterization of pavement surface distresses
shows an increasing interest in this area. A recent publication a
hierarchical method present in [1], which deals with detection of roads
and slopes. In this paper, a novel framework is proposed for segmenting
road images in a hierarchical manner that can separate the following
objects: road and slopes with or without collapse, sky, road signs, cars,
buildings and vegetation from the images. The experiments show that
the approach in this paper can achieve a satisfied result on various road
images. The roads are unstructured, which are more complex than the
structured roads. In [2] multi scale approach based on Markov random
field is proposed to segment fine structures (cracks) in road pavement
surface images. Cracks are enhanced using a 1-D Gaussian smoothing
filter and then processed by a 2-D matched filter to detect them. A total
6
of 64 road pavement surface images representing several crack types
are considered for experimentation, producing a qualitative evaluation.
Details on image characteristics or the type of sensor used to capture
them are not provided. Another paper evidences the difficulty of
7
detecting cracks of less than 3 mm width when using edge detectors. A
non-sub sampled contourlet transform is adopted in to detect cracks,
wherein a limited set of experimental results is presented. A complete
methodology to automatically detect and characterize pavement defects
is proposed in, using gray scale images captured by line scan cameras
illuminated by lasers during road surveys performed using a high-speed
image acquisition system. Crack detection uses a conditional texture
anisotropy measurement to each image, and defect characterization
uses a multilayer perceptron neural network with two hidden layers. The
results presented are promising, but the experimental evaluation does
not support the distinction of multiple cracks in the same image. In
paper, Neural network method is used. The automated pavement
defect detection can only identify crack type defects. To classify defect,
a multi-layer perceptron neural network (MLPNN) is used. Neural
network is used to classify the images into four classes: defect-free,
crack, joint and bridged. Experimental results are performed on real
road images which are labeled by human operators. There are more
additional filters required for this system. In paper, Vision-based
approaches are used to address functionalities such as lane marking
detection, traffic sign recognition, pedestrian detection, etc. This system
is possible to detect the free road surface ahead of the ego-vehicle
using an on board camera. Novelty Method is used for both Shadowed
and unshadow regions which provide highest performance. Road
detection algorithm is devised by combining the illuminant invariant
feature space and likelihood based classifier. The defect of this system
is under saturation by improving image acquisition system. In paper, A
neural network based technique for the classification of segments of
road images into cracks and normal images. The features are passed to
a neural network for the classification of images into images with and
without cracks. Another approach
[9] extracts linear features (cracks) using two methodologies: one based
on holistic thresholding and the second employing the Otsu algorithm.
8
One of the major problems in developing countries is
maintenance of roads. Well maintained roads contribute a Major portion
to the country’s economy. Identification of pavement Distress such as
potholes and humps not only helps drivers to avoid accidents or vehicle
damages, but also helps authorities to
9
Maintain roads. This paper discusses previous pothole detection
methods that have been developed and proposes a cost-effective
solution to identify the potholes and humps on roads and provide timely
alerts to drivers to avoid accidents or vehicle damages. Ultrasonic
sensors are used to identify the potholes and humps and also to
measure their depth and height, respectively. The proposed system
captures the geographical location coordinates of the potholes and
humps using a global positioning system receiver Taehyeong Kim and
Seung- Ki Ryu proposed a detection system which starts with noise
removal, followed by adjustment of brightness and simplification of
video by binarization. Then, noise removal is applied to the binarized
image. After noise removal, the process of extraction of the outlines of
the segmented objects is carried out. Extraction is followed by selection
and square zoning for the objects. After all these processes, desired
pothole area information is returned. Sudarshan Rode proposed a
pothole detection system which is divided into three subsystems. First is
sensing subsystem which senses the potholes encountered by it, by
using accelerometer or by camera which scans the road. Both are
mounted on the car. Then communication subsystem which transfers
the information between Wi-Fi access point and mobile node. Access
Point broadcasts the data about potholes in its area. Eriksson et al.
studied mobile sensing of roads to monitor and report any potholes. The
system used accelerometer and GPS for detection and location
respectively. Cars give detections which are fed to a central server.
11
required. AmilaAkagic, Emir Buza and Samir Omanavic used the RGB
image processing technique, complex figuring devices that consolidate
programming and equipment to process the pothole pictures are
required in this technique. It is also consumes more time when
compared to other methods. Also the accuracy rate is low in this
approach. Moreover it needs prior knowledge of the images i.e., a large
quantity of training sets have to be given. Wang didnt attainability
concentrate to lead the comprehensive review of asphalt conditions by
methods for of stereovision innovation. In this strategy, two advanced
cameras are appended to the vehicle, which is utilized to cover an
asphalt surface. The initial step is to dissect 2D pictures from every one
of the two cameras to recognize and order any splits. To recuperate the
3D properties from given sets of 2D pictures on a similar asphalt
surface, the succession of steps, for example, camera alignment,
twisting right, coordinating stereo focuses, 3D recreate, and profile
report ought to be performed. It needs complex computation capabilities
when compared to other methods. Kana Azhary, FeerdMurtaza,
Muhammad Herboon mohammed and Hafed Adman Habit stated an
approach of finding and localizing the potholes based on computer
vision in asphalt pavement images. Histograms from the input images
are classified using naïve bayes classifier using normalized graph cut
segmentation scheme. This experimentation showed 90% accuracy on
localizing the potholes from the pothole images.
13
potholes in video sequences taken by a camera placed inside a moving
car. The region of interest for the detection of the potholes is chosen as
the picture territory where the street is seen with the highest resolution.
The paper proposed an algorithm for pothole detection and tracking.
The region of interest (ROI) was chosen off-line and candidate regions
were produced utilizing a threshold based algorithm. The upsides of this
paper, great accuracy and a little runtime. Vinay Rishiwal et al. shows a
vibration based approach for programmed location of potholes and
speed breakers alongside their co-ordinates. In this approach, a
database is kept up for every street, which is made accessible to the
general population with the assistance of worldwide database or through
an entry. The proposed favourable circumstances are cost effective and
extremely successful for street surface checking. discuss about the
significance of street surface monitoring in terms of comfort and
security required by the street travellers. This approach can be
advantageously for secure travelling particularly in obscure street
conditions. The demerits are more complex. Rajeshwari S. et a. displays
an intelligent traffic control framework to pass crisis vehicles easily.
Each individual vehicle is equipped with special RFID tag (placed at a
key area), which makes it difficult to remove or destroy. This paper
utilizes RFID peruse, NSK EDK-125–TTL and PIC16F877A framework on-
chip to peruse the RFID labels attached to the vehicle. As the whole
framework is computerized, it requires less human intercession. With
stolen vehicle exploration, the signal naturally swings to red, so that the
cop can make fitting move, on the off chance that he/she is available at
the intersection. From literature survey we can conclude that, Potholes
can be detected by using image pre-processing, segmentation and
ultrasonic sensor techniques for pothole identification. Location of
potholes and speed breakers alongside their coordinates can be
detected by using vibration based approach.
15
vehicle wheels traverse through the deformities and not the ones which
pass between the two side wheels. As described in paper by Emir Buza
where Otsu thresholding method is used which segments images to
obtain binary images from gray scale. Spectral clustering is then
employed for determining shapes of irregular objects like road
deformities from the selected images. In this shadows of surrounding
objects and manhole covers can also get tagged as potholes and may
not perform well in low light conditions. Ajit Danti and Seungkiryu
presented a novel approach by first using lane detection, then mapping
a virtual polygon considering the lanes as sides of the polygon and then
defined it as Region of Interest thus extracting a small part of the
incoming video to reduce the processing load on the system and then by
inspecting various features, such as the length, area, variance, and
trajectory pothole extraction has been carried out. The important part in
this is that not all roads have lane lines are present and in such situation
by fixing lane vanishing point the unknown lane line is plotted virtually.
They have implemented this is a commercially available black box
camera embedded system; due to which this implementation technically
faces limitation of the processing capabilities of that embedded system
and also future modifications may not be possible[2 & 3]. In paper by
Christoph Mertz, another novel approach by using line laser light
projected on the road surface that helps in two ways: one for highly
detailed 3D profiling of the road damages and other for plotting basic 2D
graphical representation of the road deformations which can be well be
used for filtering shadows and other objects that may get tagged as
deformities which would be an improvement over the use of simple
spectral clustering method. But use of this system may not work
effectively while in broad daylight but will generate one of the best
results at night time. Thus this paper presents a combination of lane
detection, laser and spectral clustering of the road for accurate
detection of potholes and cracks well in advance before the vehicle
passes over it.
16
Some existing methods to detect pothole, such as; vibration-
based methods, 3D reconstruction-based methods, and vision-based
methods. Varadharajadan et al. introduces potholes inspection system
using vision- based methods. Smart camera from a smart phone
captures road images for
17
segmentation. For detecting cracks on road or other road damage,
Super pixel SLIC variation algorithm is utilized. Road damages are
confirmed using Multiple Instance Learning Algorithm. The result shows
the system is able to detect road cracks, and has potential to detect
potholes, patches, etc. Koch and Ioannis classifying a road based on its
defect and non-defect regions for potholes detection. The algorithm
consists of three stages which is image segmentation, shape extraction,
and texture extraction and comparison. Image segmentation
accomplished by using histogram shape-based thresholding algorithm.
There are two procedure to detect a pothole in elliptical shape based on
the detected shades. First is morphological thinning to minimize the
cracks effect from the potholes. The second one is elliptic regression to
approximate an ellipse. A remote-controlled robot was used to collect
the data and simulate a high speed vehicle. The data is classify by a
high variety potholes such as by shapes and sizes, non-defect asphalt
pavements and other defect such as cracking and patching, and
shadows that caused by lighting condition. This method has 85.9%
accuracy and 81.6% precision. Although it is inefficient for the
computation due the redetected pothole from processing every single
image of the road pavement videos. Buza et al. provides another option
for pothole detection by utilize image analysis and spectral clustering.
Data is collected by mounting the system on passenger vehicles. The
defects region are detected from every frame, then being analyzed
later. Spectral clustering is used on the shape extraction process. This
method adds Otsu Image Thresholding to automatically decide threshold
values every image with internal algorithms either. The estimation
accuracy of potholes detection by this algorithm is around 81%. Pawade
et al. have presented a low-cost potholes detection method with Field
Programmable Gate Arrays (FPGA). FPGA is a digital devices with simply
design. The main algorithms to detect potholes by using three edge
detection technique which is Sobel, Prewitt, and Canny. The pre-
processing using canny method as it is one of the best efficient noise
removal technique. The three edge detection technique is processed in
parallel threads by FPGA, which caused real-time detection is hard to be
18
achieved. Nevertheless, this system has good result of the amount of
potholes on the pavement road and can also alert the driver about
location of the potholes via GPS technology. Simple image processing
technique to detect some potholes in real world footage has been
proposed by Nienaber et al. The road
19
region is extracted based on the contour and colour of the road itself.
The algorithm defines a pothole as shape which has strong dark edge,
so canny edge detection method was capable to get potholes contour.
Convex hull algorithm was applied to decrease the noise effect and a
Gaussian filter is used to increase edge detection result. This pothole
detection system method is tested by using a Go Pro.
20
CHAPTER 3
METHODOLOGY
3.1.1 Disadvantages
GSM technology has been used which causes delay in message delivery.
It is a paid message service.
The severity is less estimated.
21
It is exceptionally costly in nature and it can't be connected to
working class level vehicles.
3.2 PROPOSED SYSTEM
22
In this proposed system Video has been captured using a camera
module interfaced with raspberry pi. Frames of the video are extracted
and the individual frame is considered as an image which is further
processed. The image is firstly blurred using aver aging then it goes
through Gaussian filet technique and lastly through median blur for
removing unnecessary noise in the image. We modified the process
with morphological operations just for achieving the most approximate
detection of edge from the depth image. In general, these operations
are a group of nonlinear operations that are carried out analogously on
ordering of pixels without stirring their numerical values. Erosion,
Dilation are morphological key operators. We have used erosion after
blurring operations which is followed by two iterations of dilation. The
pothole detection is utilizing canny edge detection technique. Detection
techniques are multi - stage method to detect wide ranges of edges in
images.
3.2.1 Advantages
23
3.3 FLOW CHART
24
Software and Hardware Requirements and Specifications
HARDWARE REQUIREMENTS
Hardware :Processor Intel dual core and above
Clock speed :3.0 GHz
RAM size :512 MB
Hard Disk capacity :400 GB
Monitor type :15 inch color monitor
SOFTWARE REQUIREMENTS
Operating System :Windows XP, Windows 7, Windows 8,Windows
10
Application :HTML, CSS, JS, Python, Flask
Browser :Google chrome, Firefox
Database :MySQL, Google Firestore.
Documentation :MS-Office
3.3.1 Python
25
Python Software Foundation, manages and directs resources for Python
and CPython development. Python is meant to be an easily readable
language. Its formatting is visually uncluttered, and it often uses English
keywords where other languages use punctuation. Unlike many other
languages, it does not use curly brackets to delimit blocks, and
semicolons after statements are optional. It has fewer syntactic
exceptions and special cases than C or Pascal.
26
Python uses whitespace indentation, rather than curly brackets or
keywords, to delimit blocks. An increase in indentation comes after
certain statements; a decrease in indentation signifies the end of the
current block. Thus, the program's visual structure accurately
represents the program's semantic structure. This feature is sometimes
termed the off-side rule, which some other languages share, but in most
languages indentation doesn't have any semantic meaning.
Module Descriptions
1. Flask: Flask is a high-level Python web framework that enables rapid development of secure and
maintainable websites. It provides a powerful set of tools for building web applications, including a
robust ORM (Object-Relational Mapping) system, automatic admin interface, and built-in security
features.
2. Python: Python is a high-level programming language used for a wide range of purposes, including web
development. It is known for its ease of use, simplicity, and versatility
3. HTML: Hypertext Markup Language (HTML) is the standard markup language used to create web pages.
It provides a structure for content on the internet, allowing developers to define and organize the various
elements on a webpage.
4. CSS: Cascading Style Sheets (CSS) is a language used for describing the presentation of a document
written in HTML. It provides a way to add style and design to a webpage, including colors, fonts, and
layouts.
5. Java Script: JavaScript (JS) is a programming language used primarily for developing interactive and
dynamic front-end web applications. It allows for the creation of responsive and user friendly websites.
27
6. DBSql: DBSql is a SQL database system that provides a flexible and scalable solution for storing and
retrieving data. It is designed for handling large volumes of data and provides high availability and
automatic scaling.
29
3.5 ALGORITHM
In the proposed system video has been captured using a camera
module and Frames of the video are extracted and the individual frame
is considered as an image. We use canny edge detection technique for
pothole detection which is a multi-stage method used to detect wide
range of images. The image is blurred using Gaussian filter and median
blur to remove unwanted noise from image. Morphological operations
are used to achieve more accurate edge detection from the depth
image. The key operators for morphological operations are erosion and
dilation. We have used erosion after blurring operations which is
followed by two iterations of dilation.
1. Apply Gaussian Filter to smooth the image in order to remove the noise.
Since all edge detection results are easily affected by the noise in
the image, it is essential to filter out the noise to prevent false detection
caused by it. To smooth the image, a Gaussian filter kernel is convolved
with the image. This step will slightly smooth the image to reduce the
30
effects of obvious noise on the edge detector. The equation for a
Gaussian filter kernel of size (2k+1)×(2k+1) is given by :
31
Here is an example of a 5×5 Gaussian filter, used to create the adjacent
image, with = 1. (The asterisk denotes a convolution operation.)
32
the horizontal direction ( Gx ) and the
33
vertical direction ( Gy ). From this the edge gradient and direction can be
determined :
where G can be computed using the hypot function and a tan2 is the
arctangent function with two arguments. The edge direction angle is
rounded to one of four angles representing vertical, horizontal and the
two diagonals (0°, 45°, 90° and 135°). An edge direction falling in each
colour region will be set to a specific angle values, for instance θ in [0°,
22.5°] or [157.5°, 180°] maps to 0°.
1. Compare the edge strength of the current pixel with the edge
strength of the pixel in the positive and negative gradient
directions.
35
value to 0) if its magnitude is not greater than the magnitude of the two
neighbours in the gradient direction. For example,
Note that the sign of the direction is irrelevant, i.e. north–south is the
same as south–north and so on.
37
weak gradient value and preserve edge pixels with a high gradient
value. This is accomplished by selecting high and low threshold values.
If an edge pixel’s gradient value is higher than the high threshold value,
it is marked as a strong edge pixel. If an edge pixel’s gradient value is
smaller than the high threshold value and larger than the low threshold
value, it is marked as a weak edge pixel. If an edge pixel’s value is
smaller than the low threshold value, it will be suppressed. The two
threshold values are empirically determined and their definition will
depend on the content of a given input image.
39
3.7 IMAGE THRESHOLDING
We use Otsu’s method for reduction of a grey level image to a
binary image.
The system then uses contour detection technique. For better
accuracy, use binary images. So we have applied threshold and
canny edge detection.
While capturing video the hassle of adjusting speed is eliminated.
Hence, the images give a clear view.
40
For 2 classes, minimizing the intra-class variance is equivalent to
maximizing inter- class variance :
41
The Hough transform is a feature extraction technique used in
image analysis, computer vision, and digital image processing. The
purpose of the technique is to find imperfect instances of objects within
a certain class of shapes by a voting procedure. This voting procedure is
carried out in a parameter space, from which object candidates are
obtained as local maxima in a so-called accumulator space that is
explicitly constructed by the algorithm for computing the Hough
transform. The classical Hough transform was concerned with the
identification of lines in the image, but later the Hough transform has
been extended to identifying positions of arbitrary shapes,
most commonly circles or ellipses. The Hough transform as it is
universally used today was invented by Richard Duda and Peter Hart in
1972, who called it a “generalized Hough transform” after the related
1962 patent of Paul Hough. The transform was popularized in the
computer vision community by Dana H. Ballard through a 1981 journal
article titled “Generalizing the Hough transform to detect arbitrary
shapes”.
3.8.1 Theory
43
R = x cos θ + y sin θ
where ‘r’ is the distance from the origin to the closest point on the
straight line, and ө (theta) is the angle between the x axis and the line
connecting the origin with that closest point.
Given a single point in the plane, then the set of all straight lines going
through that point corresponds to a sinusoidal curve in the (r,θ) plane,
which is unique to that point. A set of two or more points that form a
straight line will produce sinusoids which cross at the (r,θ) for that
line. Thus, the problem of detecting collinear points can be
converted to the problem of finding concurrent curves.
3.8.2 Example 1
44
Fig 3.4 Example 1
From the calculations, it can be seen that in either case the support line at
60° has a similar length. Hence, it is understood that the corresponding
lines (the blue ones in the above picture) are very similar. One can thus
assume that all points lie close to the blue line.
3.8.3 Example 2
The results of this transform were stored in a matrix. Cell value represents
the number of curves through any point. Higher cell values are rendered
brighter. The two distinctly bright spots are the Hough parameters of
the two lines. From these spots' positions, angle and distance from
image center of the two lines in the input image can be determined.
46
CHAPTER – 4
RESULTS AND
DISCUSSION
The Video has been captured using a camera module and Frames of the
video are extracted and the individual frame is considered as an image.
47
Fig 4.2 Preprocessing Image
The image is blurred using Gaussian filter and median blur to remove
unwanted noise from image.
48
49
CHAPTER – 5
5.1 CONCLUSION
50
REFERENCES
[1] R Gass, J Scott, C Diot, “Measurements of In-Motion 802.11
Networking”, IEEE Workshop on Mobile Computing System and
Applications, 2006.
[2] X Zhang, JK Kurose, BN Levine, D Towsley, H Zhang , “Study of a
bus-based disruption-tolerant network: mobility modeling and impact
on routing”, 13th annual ACM international conference, 2007.
[3] “ http://www.its.dot.gov/vii “, RITA | ITS | Vehicle Infrastructure
Integration, JAN 2007.
[4] “ http://dev.emcelettronica.com/datasheet/st/LIS3L06AL “,
Datasheet of ST LIS3L06AL accelerometer, JAN 2008.
[5] “ http://www.gps.gov/ “, Global Positioning System, JAN 2007.
[6] JW Byers, M Lubyt, M Mitzenmachert, “A Digital Fountain
Approach to Reliable Distribution of Bulk Data”, SIGCOMM,
1998.
[7] M Mitzenmacher, “Digital fountains: a survey and look forward”,
Information Theory Workshop, 2004. IEEE, 2004.
[8] “Pothole detection System using WiFi”, Mtech project Report
submitted by Shonil Vijay, JUL 2007.
[9] “FireBird Reference manual”, Embedded and real Time
Systems Lab, Computer science and Engineering Department,
IITB
51
Screen Shots
Home Page
About Page
Services
52
Gallery
UserLogin
53
AdminLogin
NewUser
54
ContactPage
UserMainPage
55
UserViewProfilePage
CheckPotholePage
56
UserViewReportsPage
57
AdminMainPage
58
AdminViewUsersPage
AdminViewReportsPage
59
Code
import urllib.request
import time
import shutil
from PIL import Image
import os
from ultralytics import YOLO
from flask import
Flask,render_template,request,redirect,send_from_directory,url_for,
session
import firebase_admin
import random
from firebase_admin import credentials, firestore
from flask import Flask, render_template, request, redirect
import numpy as np
import pandas as pd
# Import socket module
import socket
UPLOAD_FOLDER = 'static/uploads/'
cred = credentials.Certificate("key.json")
firebase_admin.initialize_app(cred)
app = Flask(__name__)
app.secret_key = "PotholeDetection@12345"
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
ipaddress='192.168.0.103'
@app.route('/usercheckpothole', methods=['POST','GET'])
def usercheckpothole():
try:
path='./runs'
if(os.path.exists(path)):
print("Deleting Folder")
shutil.rmtree(path)
filename, detected, msg, detectedfilename="",False,"",""
userid=session['userid']
if request.method == 'POST':
file = request.files['file']
imgid=str(round(time.time()))
filename="Img"+imgid+".jpg"
detectedfilename = "Dectected" + imgid + ".jpg"
60
print("File Name : ", filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'],
filename))
time.sleep(3)
image =
Image.open(os.path.join(app.config['UPLOAD_FOLDER'], filename))
#Detection Starts here
yolo = YOLO("last.pt")
results = yolo.predict(image,save=True,show=True)
print("Folder Created Success")
time.sleep(3)
for r in results:
print(len(r.boxes.conf))
num = len((r.boxes.conf))
print(f"The number of potholes are: {num}")
if num == 0:
msg= "No Pothole Detected"
else:
detected=True
msg= str(num) + " Potholes Detected"
srcfile = './runs/detect/predict/'+filename
destfile =
os.path.join(app.config['UPLOAD_FOLDER'], detectedfilename)
shutil.copyfile(srcfile, destfile)
time.sleep(3)
shutil.rmtree(path)
db = firestore.client()
newdb_ref = db.collection('newuser')
userdata =
newdb_ref.document(userid).get().to_dict()
print("Folder Deleted Success")
id = str(random.randint(1000, 9999))
json = {'id': id, 'UserId':userid,
'FirstName': userdata['FirstName'],
'LastName': userdata['LastName'],
'EmailId': userdata['EmailId'],
'PhoneNumber': userdata['PhoneNumber'],
'FileName':filename,'PotholeFileName':detectedfilename}
61
print("Json : ",json)
newdb_ref = db.collection('newpothole')
newdb_ref.document(id).set(json)
url = "https://api.thingspeak.com/update?
api_key=0O9ST784GQ33T8UK&field1="+str(num)
urllib.request.urlopen(url)
print("data uploaded")
print("Data Saved Success")
# Create a socket object
#s = socket.socket()
# Define the port on which you want to connect
#port = 12345
#s.connect((ipaddress, port))
# Send the Text to Server
#s.send(str(num).encode('ascii'))
# receive data from the server and decoding to get the
string.
#print(s.recv(1024).decode())
# close the connection
#s.close()
return render_template("usercheckpothole.html",
filename=filename, msg=msg, detected=detected,
detectedfilename=detectedfilename)
except Exception as e:
return render_template("usercheckpothole.html", msg=e)
@app.route('/')
def homepage():
try:
return render_template("index.html")
except Exception as e:
return str(e)
@app.route('/index')
def indexpage():
try:
return render_template("index.html")
except Exception as e:
return str(e)
62
@app.route('/logout')
def logoutpage():
try:
return render_template("index.html")
except Exception as e:
return str(e)
@app.route('/about')
def aboutpage():
try:
return render_template("about.html")
except Exception as e:
return str(e)
@app.route('/usermakepredictions')
def usermakepredictions():
try:
return render_template("usermakepredictions1.html")
except Exception as e:
return str(e)
@app.route('/logout')
def logout():
try:
return render_template("index.html")
except Exception as e:
return str(e)
@app.route('/services')
def servicespage():
try:
return render_template("services.html")
except Exception as e:
return str(e)
@app.route('/gallery')
def gallerypage():
try:
63
return render_template("gallery.html")
except Exception as e:
return str(e)
@app.route('/adminviewstaffs')
def adminviewstaffspage():
try:
db = firestore.client()
newstaff_ref = db.collection('newstaff')
staffdata = newstaff_ref.get()
data = []
for doc in staffdata:
print(doc.to_dict())
print(f'{doc.id} => {doc.to_dict()}')
data.append(doc.to_dict())
print("Staff Data ", data)
return render_template("adminviewstaffs.html", data=data)
except Exception as e:
return str(e)
@app.route('/adminviewreports')
def adminviewreports():
try:
db = firestore.client()
dbref = db.collection('newpothole')
dbdata = dbref.get()
data = []
for doc in dbdata:
data.append(doc.to_dict())
print("Pothole Data ", data)
return render_template("adminviewreports.html", data=data)
except Exception as e:
return str(e)
@app.route('/userviewreports')
def userviewreports():
try:
id=session['userid']
64
db = firestore.client()
dbref = db.collection('newpothole')
dbdata = dbref.get()
data = []
for doc in dbdata:
temp=doc.to_dict()
if(str(temp['UserId'])==str(id)):
data.append(doc.to_dict())
print("Pothole Data ", data)
return render_template("userviewreports.html", data=data)
except Exception as e:
return str(e)
@app.route('/adminviewusers')
def adminviewuserspage():
try:
db = firestore.client()
dbref = db.collection('newuser')
userdata = dbref.get()
data = []
for doc in userdata:
data.append(doc.to_dict())
print("Staff Data ", data)
return render_template("adminviewusers.html", data=data)
except Exception as e:
return str(e)
@app.route('/adminviewcontacts')
def adminviewcontacts():
try:
db = firestore.client()
dbref = db.collection('newcontact')
userdata = dbref.get()
data = []
for doc in userdata:
data.append(doc.to_dict())
return render_template("adminviewcontacts.html", data=data)
except Exception as e:
return str(e)
65
@app.route('/adminlogin', methods=["POST", "GET"])
def adminloginpage():
try:
if request.method == 'POST':
uname = request.form['uname']
pwd = request.form['pwd']
if uname == "admin" and pwd == "admin":
return render_template("adminmainpage.html")
else:
return render_template("adminlogin.html",
msg="UserName/Password is Invalid")
return render_template("adminlogin.html", msg="")
except Exception as e:
return str(e)
@app.route('/userlogin', methods=['POST','GET'])
def userlogin():
msg=""
if request.method == 'POST':
uname = request.form['uname']
pwd = request.form['pwd']
db = firestore.client()
print("Uname : ", uname, " Pwd : ", pwd)
newdb_ref = db.collection('newuser')
dbdata = newdb_ref.get()
flag = False
for doc in dbdata:
data = doc.to_dict()
if (data['UserName'] == uname and data['Password'] ==
pwd):
flag = True
session['userid'] = data['id']
break
if (flag):
print("Login Success")
return render_template("usermainpage.html")
else:
66
return render_template("userlogin.html",
msg="UserName/Password is Invalid")
return render_template("userlogin.html", msg=msg)
# except Exception as e:
# return render_template("userlogin.html", msg=e)
@app.route('/newuser', methods=['GET','POST'])
def newuser():
try:
print("Add New User page")
msg=""
if request.method == 'POST':
fname = request.form['fname']
lname = request.form['lname']
uname = request.form['uname']
pwd = request.form['pwd']
email = request.form['email']
phnum = request.form['phnum']
address = request.form['address']
id = str(random.randint(1000, 9999))
json = {'id': id,
'FirstName': fname, 'LastName': lname,
'UserName': uname, 'Password': pwd,
'EmailId': email, 'PhoneNumber': phnum,
'Address': address}
db = firestore.client()
newuser_ref = db.collection('newuser')
id = json['id']
newuser_ref.document(id).set(json)
msg = "New User Added Success"
return render_template("newuser.html", msg=msg)
except Exception as e:
return str(e)
68
@app.route('/adminaddstaff', methods=['POST', "GET"])
def adminaddstaff():
try:
if request.method == 'POST':
print("Add New Staff page")
fname = request.form['fname']
lname = request.form['lname']
uname = request.form['uname']
pwd = request.form['pwd']
email = request.form['email']
phnum = request.form['phnum']
address = request.form['address']
id = str(random.randint(1000, 9999))
json = {'id': id,
'FirstName': fname, 'LastName': lname,
'UserName': uname, 'Password': pwd,
'EmailId': email, 'PhoneNumber': phnum,
'Address': address}
db = firestore.client()
newuser_ref = db.collection('newstaff')
id = json['id']
newuser_ref.document(id).set(json)
return render_template("adminaddstaff.html", msg="New
Staff Added Success")
else:
return render_template("adminaddstaff.html", msg="New
Staff Not Added Success")
except Exception as e:
return str(e)
69
id = str(random.randint(1000, 9999))
json = {'id': id,
'ContactName': name,
'Message': message, 'Subject': subject,
'EmailId': email}
db = firestore.client()
db_ref = db.collection('newcontact')
id = json['id']
db_ref.document(id).set(json)
msg = "Contact Added Success"
return render_template("contact.html", msg=msg)
else:
return render_template("contact.html")
except Exception as e:
return str(e)
@app.route('/userviewprofile')
def userviewprofile():
try:
id = session['userid']
print("Id", id)
db = firestore.client()
newdb_ref = db.collection('newuser')
data = newdb_ref.document(id).get().to_dict()
print(data)
return render_template("userviewprofile.html", data=data)
except Exception as e:
return str(e)
return render_template("userlogin.html", msg=e)
@app.route('/staffviewprofile')
def staffviewprofile():
try:
id = session['staffid']
print("Id", id)
db = firestore.client()
newdb_ref = db.collection('newstaff')
data = newdb_ref.document(id).get().to_dict()
70
print(data)
return render_template("staffviewprofile.html", data=data)
except Exception as e:
return str(e)
return render_template("stafflogin.html", msg=e)
if __name__ == '__main__':
app.debug = True
app.run()
71