gunspot a gunshot detection application for mobile...
TRANSCRIPT
GunSpot – A gunshot detection application for mobile phones
by
Simon Kleinsmith
A mini-thesis submitted in partial fulfillment of the requirements for the degree of
Bachelor of Science (Honours) in Computer Science
University of the Western Cape 2010
Supervisor: Mr Mehrdad Ghaziasgar
Co-supervisor: Mr James Connan
September 2010
Table of Contents
1. Chapter 1
1.1. The user’s view of the problem
1.2. The problem domain
1.3. Expectations of the software solution
2. Chapter 2
2.1. The designer’s interpretation of the problem
2.2. Requirements for the system
2.3. Existing solutions
3. Chapter 3
3.1. User Interface Specification
4. Chapter 4
4.1. Object oriented analysis
5. Chapter 5
5.1. Object oriented design
Introduction
A gunshot is the process where a firearm has been discharged. This involves a bullet passing
through the barrel of a gun by means of an explosion of the chemicals reactants in the bullet
itself. The sound of a gunshot is produced by two factors. One is the blast that the muzzle emits
when the explosive charge is triggered. Secondly, if the bullet travels at supersonic speed, it
produces a shock wave which travels in the opposite direction as the bullet. The characteristic
of the sound is dependant on the caliber of the gun, the length of the barrel, and the chemical
properties of the propellant found within the bullet.
The detection of gunshots offers many contributions to the public. It can speed up the dispatch
of both emergency services as well as the police. It can be used to generate statistical data
which can help identify areas where gunshots occur frequently. This can provide an indication
of where the presence of police should be increased.
The software being developed, GunSpot is a mobile phone application that detects the
occurrence of gunshots in the nearby vicinity. After the detection of a gunshot the location of
the phone is determined via GPS and the coordinates are sent back to a mapping server which
stores and graphically presents the location of all the gunshots.
Chapter 1
USERS REQUIREMENTS DOCUMENT (URD)
This chapter describes the needs of the user. It describes the problem domain pertaining to
gunshot detection, provides a description of the problem and what the user requires the software
to do. This chapter generally describes the problem to be solved as well as the functionality of
the software.
1.1. The user’s view of the problem
The user requires a portable system that can used to correctly identify gunshots in the nearby
surrounding area of where he/she is currently situated. The application should capture sound
from the immediate surrounding environment using the phone’s microphone, process it in real-
time and provide an indication of whether a gunshot has occurred. The application should then
allow users to view the locations of the gunshots on a map.
1.2. The problem domain
As the system constantly captures sound from the microphone, noise as well as the location
where a firearm is discharged can distort the sound being captured. The location of the cell
phone in relation to the user’s body also poses a problem as thick clothes and items in the user’s
pockets can dampen the sound. Should the cellular phone be located indoors, it can greatly
hamper the ability for the software to function correctly as the sound will be distorted and
dampened and the Global Positioning System (GPS) will not be able to determine the location of
the phone fast enough, if at all. The aforementioned factors affect the ability for the system to
correctly identify a gunshot.
1.3. Expectations of the software solution
The system is expected to be able to accurately detect the occurrence of a gunshot, alert the user
of this occurrence and map the location on a mapping system. This is achieved by performing a
series of steps.
1.3.1. Capture sound
The software has to continually capture sound from the environment using the phone’s
integrated microphone.
1.3.2. Apply the detection algorithm
Should a spike in the amplitude of the sound be detected, the gunshot detection algorithm
is applied in order to determine whether it is a gunshot or not.
1.3.3. Determine the location
The location of the phone is determined by either using the phone’s integrated GPS or by
using the base stations of the cellular network the user is subscribed to, to identify its
position. The phone should then send the location to the map server.
1.3.4. Map the location
The map software should display all the locations of gunshots stored on the server. The
map should have various controls so that the user can zoom in and out, see the
approximate location clearly and control the direction in which he/she is moving.
1.4. Not expected from the software solution
The software is not required to:
determine which type of firearm was discharged,
localize the occurrence of a gunshot,
determine whether a person was injured by the occurrence of a gunshot, and
dispatch emergency services to the location.
Chapter 2
REQUIREMENTS ANALYSIS DOCUMENT
This chapter focuses on the system and software requirements needed to implement the user
requirements. The requirements outlined in Chapter 1 are used as a starting point and interpreted
from the view of a designer.
2.1. Designer’s interpretation of the problem
One important factor of the system is the battery life of the mobile phone. Due to the system
constantly capturing sound from the phone’s microphone, the battery will drain much faster than
when it does under normal use of the phone. The sensitivity of the phone’s microphone is also a
factor as it determines the range in which a gunshot can be detected as well as the probability of
detection.
2.2. Requirements for the system
The system requires a mobile phone which is capable of running the software. The phone should
incorporate a processor which is powerful enough to run the software, an integrated microphone
that boasts sufficient sensitivity, and ideally a GPS to allow the location to be determined more
accurately. A server is required in order for the system to keep track of the location of the
gunshots.
2.3. Existing solutions
To my knowledge there is no system that implements gunshot detection on a mobile phone.
There is, however, a system known as ShotSpotter which implements gunshot detection and
localization. It achieves this by deploying acoustic sensors throughout the area which gunshots
are to be detected.
Chapter 3
User Interface Specification
This chapter documents how the user interfaces look, its functions and how the user interacts
with the application. The user interface comprises two parts: The mobile application, GunSpot;
and the map web application that runs on the server. Both of their interfaces and functions are
documented below.
3.1. The mobile application
GunSpot requires very little or no user intervention at all as the application is intended to run as a
service rather than to interact with the user continuously. The only user interface that the system
requires is to turn the application on and off as well as to provide the user with a notification of
the occurrence of a gunshot. The notification will be displayed for a period of time, e.g. 5
seconds. Images illustrating these two scenarios can be found below.
Figure 3.1.1 -A menu allowing the software to be turned on or off.
Figure 3.1.2 - An example of a notification presented to the user
3.2. The map interface
The images below shows the map interface as it is presented to the user. It consists of the map in
two different scenarios. Figure 3.3.1 shows the map in its default view without the user clicking
on a marker and triggering the associated changes. Figure 3.3.2 shows the map after the user has
clicked on a location marker. The map interface contains navigation and map type controls,
information windows, and location markers. Each of this will be explained in detail.
Figure 3.2.1
Figure 3.2.2
3.2.1. Location marker
This icon is used to depict the location of where the gunshot was detected. The user is able to
click on the icon in order to zoom in on the location, change the map type from Road to Hybrid
and also display an information window containing an approximate address of the location as
well as the GPS coordinates.
3.2.2. Navigation: Pan control
This control will move the map in the direction selected by the user. In addition to using the pan
controls, the user is able to click and drag the map in order to move to a different viewable area.
3.2.3. Navigation: Zoom control
This control will either zoom in or out of the map, depending on whether the user clicks on the
plus sign (zoom in) or minus sign (zoom out). The user can either drag the scroll manually to
zoom in (upward) or out (downward). In addition to aforementioned methods the user can also
double left-click on a point on the map to zoom in or double right-click to zoom out.
3.2.4. Map type control
Using this menu bar, the user can select to change the map type. Each of the images below shows
the same location except that they are using a different map type.
3.2.4.1 Road
This view shows the default road map view. It displays road names, area names and various
transport infrastructure types.
Figure 3.3.4.1
3.2.4.2 Satellite
This view shows the location in satellite view. No additional information is shown on the map.
Figure 3.3.4.2
3.2.4.3 Hybrid
This view shows a combination of the satellite and road map views. The location is shown by
means of satellite images, but with the addition of road names, area names, and transport
infrastructure types.
Figure 3.3.4.3
3.2.4.4 Terrain
This view displays the location based on information of the terrain.
Figure 3.3.4.4
Chapter 4
Object Oriented Analysis
This content of this chapter provides a high level view of the application and the objects it
contains. The chapter is focused providing an object oriented analysis, which is an object-
oriented view of the problem. Each object is defined and documented in the data dictionary. The
relationship between the objects is shown in the UML diagram below, along with the names,
attributes and methods of each of the classes.
Figure 5.1 – A class diagram of the objects in the GunSpot system.
4.1. Data dictionary
In the table below each of the objects are found along with a description of their function.
Object Description
ProcessAudio
This function of this class is to capture the
audio from the phone’s microphone and
process the sound. Processing includes
breaking the sound into its constituent samples,
applying the gunshot detection algorithm. This
class instantiates the LocationListener in order
to determine the location of the phone on
successfully detecting a gunshot.
LocationListener
The function of this class is to determine the
location of the phone and instantiate the
SendLocation class in order to send the
coordinates to the server for storage and
mapping.
SendLocation
This class sends the coordinates of where the
phone is located to the server for storage and
processing by the mapping application.
ReceiveLocation
This class resides on the server and receives
the coordinates sent from the server and writes
it to an XML file containing all the locations
where a gunshot has been detected.
GunSpotMap
This class resides on the server and displays
the map, markers and controls for the user. It
also converts the coordinates sent from the
phone into a more user readable version and
converts derives an approximate address from
Chapter 5
Object Oriented Design
This chapter provides an overview of the algorithms that are implemented in the objects of the
system as well as a description of the methods in each class.
5.1. The class that is currently under development is the algorithm which forms the core of the
GunSpot application. The methodology which the algorithm follows is described below.
Figure 5.1
While(true) {
Capture sound from microphone;
Break the sound into samples;
if(spike in sound) {
process the samples;
compare the samples to the stored values;
if(certain number of samples falls within range)
A gunshot has been detected;
Notify the user of the occurrence;
Determine the location of the phone;
Send the location to the server;
}
}
5.2. The object below is that of the mapping application. The algorithm which is
implemented is provided below.
Figure 5.2
Initialize the map;
foreach(location) {
read latitude and longitude;
convert the coordinates to an address;
create the marker;
create information windows for each marker;
display the marker on the map;
}
5.3. The object below is located on the server and its function is to receive the coordinates
sent from the phone. The pseudo code of its functioning is provided below.
Figure 5.3
Receive location;
Open file stream;
If(XML file doesn’t exist) {
Create file;
}
else {
Add marker to the file;
}
Close file stream;
5.4. The object below is part of the GunSpot application on the phone and is instantiated
when the location is to be sent to the server.
Figure 5.4
Create HTTP POST object linking to the server;
Create the list containing the name-value pairs;
Add the values for the determined location to the list;
Send the values to the server;
5.5. The object below is an abstract class that is called once the location of the phone’s
determined location has changed.
Figure 5.5
5.6. The data dictionary below provides a description of the purpose of the methods found in each
of the objects.
Class name Method name Description
ProcessAudio
verify
This method verifies
whether the sound captured
is a gunshot.
transformSamples
This method transforms the
samples from byte values
into integers.
readBounds
This method reads the
upper and lower bounds
from the text file packaged
with the application.
GunSpotMap
createMarker
This method creates the
marker and associated
information window on the
map for a location.
loadMarkers
This method reads all the
locations from the XML
file stored on the server
and passes the values to the
createMarker method.
reverseGeocode This method converts the
coordinates into an address.
convertCoordinate
This method converts the
coordinates from decimal
values to the more readable
degree-minute-second
notation.
LocationListener
onLocationChanged
This method is called when
the location on the phone
changes.
onProviderDisabled
This method is called when
the GPS or network
provider is disabled.
onProviderEnabled
This method is called when
the GPS or network
provider is enabled.
ReceiveLocation
addMarkerToFile
This method adds the
location received from the
phone to the XML file.
createFile This method creates the
XML file if it doesn’t exist.
SendLocation postData
This method sends the
location to the server in the
form of two name-value
pairs.