When I was researching school security in early 2018 I thought of an idea that could help enhance school security. I had been working with facial recognition developing a profiling tool that could detect sex offenders from live video and I wanted to see if I could adapt it to detect objects, such as weapons and guns.
Two companies claimed to have technology to detect guns and weapons from live video feeds. One company, Athena Security, offers the technology at a very reasonable price. What I needed to do is prove that the technology worked before reaching out to school board members and state officials.
A neural network is a software model that is designed to train and learn like a human brain. A neural network is a network of software connected neurons which mimic the human brain. There are several free to use neural network libraries. In this experiment I was using the dLib library which was better suited for neural networks designed for detecting objects in images.
Like the human brain, neural networks need to be trained by example.
The first step when developing an artificial neural network is gathering data to train the neural network. I needed a lot of pictures of people holding guns in various poses in many different scenes so that I could train the software to learn what a gun looks like. Just getting pictures of guns themselves wouldn’t work because the software would only be trained to look for guns by themselves, and not guns within a scene such as in the woods, or in a stairwell.
What I ended up doing is taking video of myself holding a 9mm Beretta in various positions around my house. I down sampled the video from 30 frames per second to 10 frames per second which gave me a very large data set to work with.
Using the imagelab tool that comes with the neural network framework I was using I identified the gun in all 1000 plus images. The coordinates of the gun is saved in an XML files to be used in training later.
Training a model
Using the 1000 plus images from the videos I took and the XML file that identifies the location of the gun in each of the images, I started training a gun detection neural network model. I started off with a convolutional neural network model that is used for facial recognition and started tweaking it for my own gun detection tests.
At first I was using an nVidia 1050Titan graphics processing unit and the first training session took four days to complete. I purchased an upgrade, a 2060 RTX graphics processing unit and the training time was reduced down to a little over three hours. This let me
After a month or so I ended up with a model that could generalize. What this means is that I can feed an image to the model that it has never seen before and it could detect if a gun was present in the image.
Live Video Detection
Using an off-the-shelf home surveillance camera I was able to setup a demonstration where a gun would be detected and an alarm sent. As you can see from the image below, the gun was detect as the burglar (me pretending to be a bad guy) was attempting to break into a home.
If you are interested in downloading the neural network model to train your own gun detection neural network please visit my GitHub repository.
I was able to prove that the technology is very viable and could be a tangible enhancement to school security. The technology could be modified to detect fights and even detect if suspended students are on campus. An alert could be sent to a school resource officer and/or a school administrator which would allow for a much faster reaction to a crisis.
Athena Security was offering the technology with two cameras for around $14,000 per year at the time of my experiment. Virginia schools receive more than $250,000 each year which is mostly spent on locks and “administrative” items related to security.
You can download the model on my GitHub repository.