Alarm gun implementation - dnum-mi/basegun-ml GitHub Wiki

Alarm Gun model pipeline

The pipeline for alarm gun detection consists of three main stages:

  1. Assessing image quality using CNNIQA.
  2. Detecting and recognizing text using PaddleOCR.
  3. Running a text matching algorithm to determine whether the firearm is an alarm gun.

Alarm gun detection pipeline

Defining thresholds

To determine the thresholds for image quality and text detection, we used a small dataset of firearms, labeling the images with tags such as “good quality,” “bad quality,” and “text readable.” We then plotted the results to identify the best score for distinguishing between good and bad images for detection and quality.

CNNIQA test As shown, despite some outliers, the metric allows us to separate good and bad images using a threshold of 0.5, which we confirmed with a larger dataset. We used the same method to define the text detection threshold.

Dataset

The dataset used for evaluating the pipeline is composed of photos of alarm guns, blank-firing guns, and classic firearms. The photos were taken with different devices on various backgrounds. Some photos contain the entire weapon, while others show only certain parts.

Labels:

  • Overall View: Indicates if the photo contains the entire weapon (Basegun type photo).
  • Readable: Indicates if the markings on the weapon are readable from the photo for a human operator.
  • PAK: Indicates the presence of a PAK marking on the weapon.
  • AlarmModel: Indicates that from the markings on the photo, it can be determined that the weapon is part of the alarm gun models.
  • Marking Type: Indicates the type of marking (Molding, Engraving, Printing).

Pipeline evaluation results

We defined different scopes for the studies and the dataset used. Using the scope of good quality images with readable text, which corresponds to the criteria Basegun will accept, we obtained the following performance metrics:

  • 100% precision for detecting alarm gun models
  • 76% recall

We also determined that the performance of the pipeline depends on various factors:

  • Image-related factors: sharpness, brightness, reflections, type of view
  • Gun-related factors: marking type, marking condition, contrast of the marking