# Efficient Crowd Anomaly Detection Using Sparse Feature Tracking and Neural Network
## 3 Materials and Methods
### Crowd Representation and Behaviour Descriptors
#### 3.1.4 Visual Descriptors
\[D^{\text{conf}}\left(V_{i}^{k}\right)=\frac{1}{\left|c\left(V_{i}^{k}\right) \right|}\sum_{V_{i}^{k}\in C^{\prime}\left(V_{i}^{k}\right)}\frac{d_{\theta} \left(\overline{V_{i}^{k-\tau_{1}}V_{i}^{k}},\overline{V_{j}^{k-\tau_{1}}V_{j} ^{k}}\right)}{\left\|V_{i}^{k}V_{j}^{k}\right\|_{2}}\] (15)
* Local Density The local density descriptor focuses solely on the spatial aspect of the model, distinguishing it from the previous interactive descriptors. It captures a critical characteristic of crowd behaviour, specifically how individuals are distributed within the scene. An approximate measure of the local density can be obtained by assessing the proximity of nearby features, as defined in [15]. This is based on the observation that when nearby features move closer together, it indicates a higher likelihood of a larger crowd gathering in that area. After removing static tracklets, the remaining raw tracklets are utilised for this purpose. Each vertex's local density, denoted as \(V_{i}^{k}\), is estimated by applying a kernel density function to the relative positions of the vertices within their respective neighbourhood sets. Instead of using a clique as in [15], a clique from the Delaunay graph is employed to define the neighbourhood set [37]. The calculation of the local density descriptor is shown in Equation (16) as follows:  
\[D^{\text{dens}}\left(V_{i}^{k}\right)=\frac{1}{\sqrt{2\pi\sigma}}\sum_{V_{j}^{k} \in C_{n}\left(V_{i}^{k}\right)}\exp-\frac{\left\|V_{i}^{k}V_{j}^{k}\right\|_{2 }}{2\sigma^{2}} \tag{16}\]  
The contribution of each neighbouring point to the density calculation is determined by the bandwidth of the 2D Gaussian kernel, represented as \(\sigma\). It is crucial to select an appropriate value for \(\sigma\) to ensure that feature points in close proximity to \(V_{i}^{k}\) are adequately considered in the density estimation. A larger \(\sigma\) is required for objects that are closer together due to the influence of perspective distortions on the detected feature points. A normalisation process is applied to the perspective map to address this issue, and the Euclidean distances between vertices are adjusted accordingly. This normalisation guarantees that the computation of the local density remains consistent regardless of the scale or resolution used, providing reliable and comparable results. * Uniformity The uniformity descriptor is employed to assess the coherence of the spatial distribution of regional features. It indicates whether a group exhibits a tendency to cluster together (uniform) or to fragment into smaller subgroups (nonuniform), as described in [14]. This descriptor operates at a semi-local level, focusing on the characteristics of groups rather than individual points. To achieve this, a clustering algorithm is applied to visually distinguish different types of people. Distance-based clustering, which identifies clusters based on the proximity of points, is a suitable approach as it does not require prior knowledge of the number of clusters [37]. Subsequently, for a set of p clusters denoted as clusters \(\mathcal{N}=\left\{\mathcal{N}_{1},\ldots,\mathcal{N}_{p}\right\}\), the modularity function is computed for each cluster to quantify its consistency. This evaluation considers both internal and external relationships within the clusters, providing insights into the level of coherence exhibited by the group. It is calculated as in Equation (17) given below: \[D^{\text{unif}}\left(N_{i}\right)=\frac{A(N_{i},N_{i})}{A(N,N)}-\left(\frac{A( N_{i},N)}{A(N,N)}\right)\] (17) The computation of the uniformity descriptor involves graph-based calculations. After applying the clustering procedure, each vertex \(V_{i}^{k}\) is assigned to a specific cluster. The distances between connected points are considered to determine the inter-cluster and intra-cluster relationships. If a connected point belongs to the same cluster as the seed point, the distance is used to enhance the intra-cluster weight.