Monday 23 November 2015

HOG+SVM for gun detection in CCTV images

I have made a small collection of training data (currently around 18 images images, in two sets of 9 of people with guns and people without guns) and have made a basic implementation which attempts to guess whether somebody has a gun using support vector machines based off of 128x128 CCTV camera stills of people either carrying a gun or not carrying a gun. The present implementation appears to overfit the data so I will attempt to resolve this; it always correctly classifies everything in the training set but usually errs to the side of false negatives when  classifying test data from casual observation.

Progress to be made on this:

Collect more images (ideally 50 with guns, and I can take the rest of the images from pre-existing person reid datasets like ViPER - edit: may need some images from scenes in which guns appear in case the detector becomes influenced by the lighting/other composition of the scene.)

Find out how to regularise(?)/prevent overfitting in the model I've come up with

Formalise the analysis stage.

The source code for this version of the program can be found here:

http://pastebin.com/nz5cQx3k

To be honest, you can get rid of that opencv dependency.

Sunday 22 November 2015

An eye for guns

In my upcoming series of posts, I will be exploring ways to automatically detect armed attackers in CCTV feeds using Python and OpenCV. Of course I'm sure the motivation for this given the recent terrorist attacks in Paris, Mali and others is obvious. The scope of this is currently quite broad, so I will attempt to narrow it down to some key points:


  • Reliable detection of an AK-47/Kalashnikov rifle from a low quality video feed.
    •  The motivation for this should be self explanatory
  • Suspicious body language detection
    •     There is some reason to believe that body language can be indicative of unusual behaviour. Being able to detect this may lead to effective tracking of suspicious individuals before they are capable of executing an attack
  •  Suspicious dress behaviour
    •  The attackers in Paris dressed in dark clothing and attacked at night. This could prove challenging, however in combination with body language detection a useful detector could be produced.

Goal one:
AK-47 detection in a still image - this will hopefully lend itself to progress in a real-time video detection scheme. More specifically, this should be a gun currently being carried by somebody rather than just in some luggage. This may be extended to potential containers for an AK-47 as they must be transported somehow.

Literature dump: 
http://www.sciencedirect.com/science/article/pii/S1877050915014076

http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=7253863&url=http%3A%2F%2Fieeexplore.ieee.org%2Fiel7%2F7227935%2F7253613%2F07253863.pdf%3Farnumber%3D7253863
http://cvgl.stanford.edu/teaching/cs231a_winter1415/prev/projects/CS231AGun.pdf

http://airccse.org/journal/ijcseit/papers/2212ijcseit16.pdf

http://staffnet.kingston.ac.uk/~ku33185/MEDUSA.html
... + more but lazy.

Edit: The MEDUSA project looks like a promising source of information, although appears like it may have been underfunded.

Youtube has a large collection of videos involving potential attackers and mock attacks which may contain highly useful training data for supervised learning based detectors.

Labelling data may prove difficult. I will have to evaluate whether it is worth doing it myself, generating the data (3D images can be effectively be used for object recognition in combination with domain adaptation techniques).

I would ultimately like to come up with some affordable way to disable firearms within a room - although my initial thoughts on this remind me of a children's TV show where the contestants would be covered in some kind of gunk - thinking about the way custard works - perhaps a more hardy non-newtonian fluid could be used to jam a rifle? 

Should I be successful in any of these topics, they shall of course be free and open to all so that hopefully these systems can be implemented to help prevent terrorist attacks in major cities and for those who are otherwise interested in learning about computer vision applications. A hefty research grant of course would not go amiss.