## 2 Related Work and Our Contributions
Anomalous events refer to unusual actions, behaviors, or situations that pose risks to public health, safety, or the economy. Work [36] proposed a real-world anomaly detectionapproach using the UCF-Crime dataset, a large-scale collection of surveillance videos that includes 13 types of realistic anomalies such as fighting, road accidents, burglary, and firearm usage alongside normal activities. The existing approaches to OCC-based visual anomaly detection (AD) primarily focus on learning a model of the normal distribution using autoencoders [37; 38; 39], generative adversarial networks (GANs) [40; 41], or other unsupervised adaptation techniques [42]. VAEs are particularly well-suited for anomaly detection. They leverage deep learning networks, allowing for automatic feature learning, and they do not require labeled data from all classes of interest. Instead, VAE models are trained exclusively on objects from the target class, which are typically abundant. More recently, studies such as [43] have proposed a data-driven approach for constructing OCCs using a variational autoencoder (VAE-SIMCA) [44]. Their method determines classification decisions based on a linear combination of distances between the original and reconstructed images. These distances are approximated using a scaled chi-square distribution, with the decision boundary derived from the theoretical quantile function of this distribution and a predefined probability. Notably, their approach eliminates the need for specific optimization, as the decision boundary is solely determined by the model outcomes from the training set. Despite this lack of adaptation, these models exhibit strong AD performance and reliable spatial localization of defects in industrial products. The fundamental principle behind these methods lies in feature matching between test and normal samples while leveraging the multi-scale nature of deep feature representations. High-resolution features facilitate the segmentation of subtle, whereas structural deviations and image-level AD are effectively managed by features at higher levels of abstraction [45]. OCC-based approaches enhance the accuracy and robustness of AD systems, making them well-suited for real-world applications. Firearms are, by definition, rarely observed and considered uncommon objects [18]. Consequently, firearm detection can be framed as an AD problem, where OCCs are particularly well-suited. The absence of predefined classes and the limited availability of labeled data for firearm-related incidents present significant challenges for training supervised machine learning models for firearm detection. Traditional binary classification for firearm detection relies on both positive and negative samples; however, obtaining images of positive cases in publicly monitored spaces is highly challenging due to strict legal restrictions on carrying and displaying firearms. Even possessing a replica gun in public can cause alarm and lead to legal consequences. In contrast, negative samples are readily available in abundance. Our goal is to develop an OCC-based firearm detection model that leverages skeletal representations of human actions and appearance-based gun features while achieving performance comparable to fully supervised methods. As far as the authors know, this is the first time that such approach is taken for the purpose of weapon detection. In summary, this paper makes the following contributions:  
1. **Unsupervised Firearm Detection:** We propose a fully unsupervised approach for detecting active firearms using a unified feature representation derived from a VAE and HPE. This method eliminates the need for prior labeling of anomalous samples with _handgun_ and instead exploits averaged latent sample representations for improved accuracy. 2. **Adaptive Patch Extraction:** We introduce an automatic variable patch size extraction technique based on estimating the distance between the subject and the camera using HPE.