Skip to main content
Scientific Reports logoLink to Scientific Reports
. 2026 Apr 10;16:16155. doi: 10.1038/s41598-026-45262-1

Stampede detection and crowd analysis using CNN-LSTM and farneback optical flow

Geetanjali Bhola 1, Sumit Srivastava 2,✉,#, Hith Rahil Nidhan 3, Sanyam Kathed 4,#
PMCID: PMC13201541  PMID: 41963403

Abstract

Stampede incidents in densely populated environments remain a critical challenge for public safety, resulting in severe casualties and significant disruption. This paper presents a novel, data-driven framework for automated stampede detection and crowd risk classification, leveraging the integration of Farneback optical-flow computation with a hybrid CNN-LSTM architecture. Two complementary datasets, UCSD Anomaly detection dataset and Agoraset dataset, were combined to capture a broad spectrum of crowd behaviors and densities. The proposed system classifies crowd states into four distinct risk levels: normal, moderate, dense, and risky, thereby offering a more granular assessment than traditional binary models. The model was trained and evaluated on a balanced dataset of 10,000 annotated frames, with rigorous preprocessing and augmentation to ensure robustness. Experimental results demonstrate an accuracy of 99.75%, further cross-dataset evaluation on the UMN benchmark assesses the robustness under domain shift conditions. While the approach shows strong potential for real-time deployment in public event management and emergency response, current limitations include computational latency and challenges in ultra-dense, occluded scenarios.

Keywords: Stampede detection, Crowd analysis, Optical flow, CNN–LSTM, Spatio-temporal, Deep learning, Abnormal crowd behavior

Subject terms: Engineering, Mathematics and computing

Introduction

The catastrophic nature of crowd disasters has emerged as one of the most pressing challenges in contemporary public safety management, with stampede incidents representing the most devastating manifestation of crowd-related emergencies1 Historical records document numerous tragic events where dense human gatherings have resulted in mass casualties, from the 1954 Kumbh Mela tragedy claiming over 400 lives to more recent incidents such as the 2013 Prayagraj crush and the 2021 Astroworld Festival disaster. Further, implementations have been tested to detect such incidents and anomalies using various methods2. These events underscore a fundamental reality: as global urbanization accelerates and mega-events proliferate, traditional crowd management methodologies prove increasingly inadequate to address the complex dynamics of large-scale human assemblies3,4 . The transition from reactive disaster response to proactive prevention has become imperative, driving the evolution of sophisticated technological solutions that can anticipate, detect, and mitigate potential stampede conditions before they escalate into catastrophic events5.

The technological landscape of stampede detection has undergone a remarkable transformation over the past decade and a half, evolving from rudimentary surveillance systems to sophisticated artificial intelligence-driven platforms capable of real-time crowd behavior analysis. This evolution reflects broader advancements in computer vision, machine learning, and sensor technologies, which have collectively enabled the development of systems that can process vast amounts of visual and sensor data to identify patterns indicative of dangerous crowd conditions4,6. The urgency of this technological advancement is particularly evident in the context of mega-events such as the Maha Kumbh Mela 2025, which anticipates over 400 million attendees, representing a scale of human gathering that demands unprecedented precision in crowd monitoring and management 1.

Fig. 1.

Fig. 1

Evolution of stampede detection technologies (2009-2025).

The fundamental challenge in stampede detection lies in the complex, nonlinear nature of crowd dynamics, where individual behaviors aggregate into collective phenomena that can rapidly transition from stable to chaotic states6,7. Understanding these dynamics requires sophisticated analytical frameworks that can capture both the physical and psychological aspects of crowd behavior, integrating insights from fluid dynamics, social psychology, and computational modeling8,9. The social force model10, first introduced by Helbing and colleagues, provided a foundational framework for understanding how individual pedestrian movements are influenced by repulsive and attractive forces from other individuals and environmental obstacles. This physics-based approach laid the groundwork for subsequent developments in computational crowd analysis, establishing the conceptual foundation upon which modern detection systems are built.

The paper contains 8 sections, where Section 1 with a brief discussion of the evolution and the current state-of-the-art techniques. Section 2 focuses on the literature review and further defining the problem statement and existing methods. Section 3 further discuses few key innovations and their limitations as well as issues related to the formulation of a robust solution. Sections 4 explains the methodology and a detailed explanation of Dataset, the Optical flow method and the features selection. It also explains the mathematical foundations involved behind them. Section 5 deals with the experimental training setup of the model and the environment configuration. Section 6 shows the results of the proposed work including accuracy and inference metrics. Section 7 contains discussion and future work while, section 8 concludes this proposed work.

Evolution of stampede detection technologies

The technological evolution of stampede detection systems can be categorized into three distinct eras, each characterized by fundamental shifts in methodological approaches and computational capabilities2,6 . The Traditional Computer Vision Era (2009-2015) was dominated by classical image processing techniques, including optical flow analysis, background subtraction, and particle advection methods. These approaches, while computationally efficient, were limited by their reliance on handcrafted features and threshold-based detection mechanisms that struggled to adapt to the variability inherent in real-world scenarios1,8.

The Deep Learning Era (2016-2020) marked a paradigmatic shift toward data-driven approaches, with convolutional neural networks (CNNs)11 and recurrent architectures demonstrating superior performance in crowd density estimation and behavior classification tasks12,13. This period witnessed the emergence of sophisticated architectures capable of learning complex feature representations directly from raw video data, significantly improving detection accuracy while reducing the need for manual parameter tuning9,14. The integration of temporal modeling through Long Short-Term Memory (LSTM) networks15 enabled systems to capture dynamic patterns in crowd behavior, moving beyond static density estimation to dynamic behavior prediction.

The current AI Integration Era (2021-2025) represents the convergence of multiple technological streams, including transformer architectures, edge computing, Internet of Things (IoT) sensors, and multimodal data fusion6,16. This era is characterized by the deployment of large-scale, real-world systems capable of processing multiple data streams simultaneously while maintaining real-time performance requirements. The integration of edge computing has enabled distributed processing architectures that can handle the computational demands of modern AI algorithms while addressing privacy and latency concerns17.

Previous studies report high accuracy for different datasets of isolated data, however, the requirements for operational stampede prevention include all of the following: (a) A graded risk output instead of binary anomaly flags; (b) Robustness to occlusion and lighting changes; (c) Inference strategies that can be deployed in near real-time on constrained hardware. The focus of this paper is to answer the following research questions:

  1. Can a multi-channel dense optical flow feature set combined with compact scalar motion descriptors improve the effectiveness of discrimination between the intermediate state of crowds compared to the use of single stream models?

  2. Will a hybrid CNN-LSTM network that fuses the per-frame spatial features and short term temporal features maintain a high level of detected performance while allowing for unimpeded inference latency?

  3. What is the total time required (optical flow extraction + feature extraction + model inference) on commercially available hardware, and are these times applicable to practical early-warning windows?

These research questions form the basis for the future work regarding method, evaluation, and experiment design found later in this paper. This paper enhances the idea of classification into four classes of normal, moderate, dense and risky. The four-class taxonomy was chosen to support progressive intervention strategies (notification Inline graphic crowd direction Inline graphic partial evacuation) against a single signalling option. A dense crowd with a dense occlusion may not be detected by traditional object detection methods, and motion-centric indicators (flow acceleration, flow divergence, flow entropy) provide a simple means of measuring the global dynamics of the crowd prior to experiencing a physical collapse. A rich combination of multi-channel dense optical flow, a lightweight CNN encoder, and short LSTM temporal context is designed to (i) take advantage of the spatial motion structure per-frame, (ii) utilize short-term temporal coherence without incurring the cost of tracking individuals, and (iii) facilitate batch processing to permit greater efficiency of model size and inference processing time. To assess cross-domain robustness, the trained CNN-LSTM model is also cross-validated against the UMN crowd dataset15. This external validation serves to confirm whether the learned optical-flow and scalar descriptor will generalize to scenes that were not present in the Agoraset/UCSD training set and provides measures of the performance degradation due to domain shifting effects on early warning.

Literature review

The foundational work which introduced the application of social force models to abnormal crowd behavior detection, establishing a physics-based framework that remains influential in contemporary research10. Their approach utilized optical flow computation to estimate interaction forces between virtual particles representing crowd members, enabling the detection of abnormal behaviors through force flow analysis15. This seminal work demonstrated that crowd anomalies could be detected without explicit object tracking, avoiding the computational complexity associated with individual trajectory analysis in dense crowd scenarios15. Building upon these foundations, Cob-Parro et al. (2015) developed a threshold-free stampede detection system that combined optical flow entropy analysis with machine learning classifiers. Their methodology employed a stacking classifier approach, integrating Random Forest and Support Vector Classification (SVC) algorithms to achieve 88% real-time detection accuracy on the UMN and PETS-2009 datasets. The significance of this work lies in its elimination of environment-specific threshold requirements, enabling more generalizable deployment across diverse crowd scenarios1. The particle advection approach represented another significant advancement in holistic crowd analysis methodologies16. By treating crowd flow as a fluid dynamic system, their framework enabled the segmentation of high-density crowds based on coherent structures, providing insights into crowd instabilities without requiring individual tracking. This approach demonstrated the potential for borrowing concepts from fluid dynamics to understand crowd behavior at macroscopic scales.

The application of deep learning to crowd analysis marked a revolutionary advancement in detection capabilities, with CNN-based architectures demonstrating superior performance in density estimation and behavior classification tasks6,16. Rafi Haque et al. (2017) demonstrated that CNN-based crowd counting models outperformed traditional erosion methods by 34% in high-density scenarios, utilizing pixel analysis and head/torso detection for accurate population estimation. Their work established the superiority of learned feature representations over handcrafted descriptors in complex crowd environments. The introduction of transformer architectures to crowd analysis represented another significant breakthrough, with Sun et al. (2019) developing Deformable DETR systems specifically designed to address small target detection challenges in crowded environments. Their enhanced model achieved 34% improvement in small-target detection accuracy while maintaining real-time processing speeds through SwiGLU activation function optimization6. This work addressed a critical limitation in existing systems: the detection of individuals in heavily occluded scenarios typical of dense crowds 2.

Fig. 2.

Fig. 2

Performance comparison of stampede detection methods.

The integration of temporal modeling through LSTM networks has enabled more sophisticated behavior analysis capabilities, with Altowairqi et al. (2023) achieving 97.84% accuracy through combined Fully Convolutional Network (FCN) and LSTM architectures8. Their approach demonstrated the importance of temporal context in distinguishing normal from abnormal crowd behaviors, moving beyond static density analysis to dynamic pattern recognition. The significance of this work extends beyond accuracy improvements to include enhanced localization capabilities for suspicious activities.

Contemporary research increasingly emphasizes multimodal approaches that integrate diverse data sources to achieve comprehensive crowd monitoring capabilities6. Chang et al. (2022) developed a comprehensive risk prediction framework that combined Point-to-Point Networks (P2PNet), YOLO object detection, and DBSCAN clustering algorithms to classify crowd risk levels into distinct categories: Crowd Crush, Crowd Wave, and Crowd Collapse9. Their multi-algorithmic approach demonstrated the feasibility of real-time detection using ensemble methods, moving away from single-algorithm solutions toward integrated frameworks.

In their work, Cob-Parro and colleagues (2025)18 developed a novel framework using dense optical flow (DOF) as input to a deep learning algorithm to identify stampedes, achieving superior classification accuracy through utilizing pixel-level motion continuity as opposed to individual feature-based tracking. They also demonstrated that DOF representations hold significant potential to be used for tracking group movement behaviours, particularly in densely populated environments where it is difficult to track individual objects accurately. However, the focus of their study was primarily on binary abnormality detection and did not provide the ability to perform fine-grained risk stratification, as required for progressive intervention systems.

Altowairqi, et al. (2026)19 developed an architecture combining C3D and LSTMs, augmented by attention modules, to address the limitations of previous works on spatiotemporal anomaly detection (STAD). Their models were able to improve temporal representation learning by integrating volumetric convolutional networks with sequence modelling, providing strong results on publicly available benchmark datasets. However, the high computational requirements for implementing 3D convolutional and attention layer modules impose limitations on the scalability of these methods for large-scale or edge-based implementation under multi-camera observation environments. On the other hand, Altowairqi et al. (2024)20 proposed a method to track sparse features by using a neural network to classify those features with the help of hand-crafted feature descriptors such as SIFT, FAST and AKAZE and dimension reduction methods for Retinex. This method had high accuracy on the datasets that were evaluated, however, as the method relied on stable keypoints being extracted from images, it demonstrated a high level of sensitivity to occlusion and the variation of crowd density in real life environments that are susceptible to stampedes 3.

Fig. 3.

Fig. 3

Data sources distribution in modern stampede detection systems.

The emergence of edge computing solutions has addressed critical limitations related to latency and privacy in crowd monitoring systems17. These distributed architectures enable local processing of sensitive crowd data while maintaining real-time performance requirements, addressing growing concerns about privacy and data sovereignty in public surveillance applications.

Contemporary research trends and innovations

Recent developments in stampede detection research reflect increasing sophistication in both algorithmic approaches and real-world deployment strategies7. Ma et al. (2024) introduced multimodal large language models (MLLMs) for disaster assessment, demonstrating strong correlation with ground-truth seismic data while integrating image-text signals from social media sources21. This work represents a significant advancement in leveraging crowdsourced data for emergency response applications.

The development of attention mechanisms has significantly enhanced detection performance in challenging scenarios, with recent implementations of Convolutional Block Attention Modules (CBAM) in YOLO architectures achieving improved accuracy for middle and far-distance crowd recognition16. These advances address fundamental limitations in existing systems related to scale variation and occlusion handling.

The real-world deployment of AI-powered crowd management systems at the Maha Kumbh Mela 2025 represents a landmark achievement in large-scale stampede prevention technology7. The implementation utilized over 2,760 CCTV cameras with 500 AI-powered units capable of real-time crowd density analysis and predictive analytics. This deployment demonstrated the practical viability of computer vision-based crowd management at unprecedented scales, providing valuable insights for future implementations.

Challenges and limitations in current research

Despite significant technological advances, contemporary stampede detection systems continue to face fundamental challenges that limit their effectiveness and deployment scope17,22. Occlusion remains the most frequently cited limitation, with dense crowd scenarios creating significant challenges for individual detection and tracking algorithms6,22. This challenge is particularly acute in high-density gatherings where traditional computer vision approaches fail to maintain acceptable accuracy levels6.

Computational complexity represents another significant barrier to widespread deployment, with advanced deep learning systems requiring substantial processing resources that may not be available in many deployment scenarios6,12. The tension between accuracy requirements and computational constraints continues to drive research toward more efficient architectures and edge computing solutions17.

Real-time processing requirements create additional constraints, particularly for systems that must analyze multiple video streams simultaneously while maintaining low latency for emergency response applications5,22. Many current systems struggle to balance processing depth with speed requirements, leading to compromises in either detection accuracy or response time5.

Methodology

Dataset preparation and preprocessing

This research integrates two complementary crowd surveillance datasets, the UCSD Pedestrian Dataset23 and the Agoraset Dataset24 to establish a comprehensive analysis framework. The UCSD dataset contributes diverse real-world scenarios captured in academic environments, while Agoraset provides specialized high-density scenarios from complex public spaces. Both the datasets are standardized and have been implemented to academically evaluate crowd anomalies and analysis as well as stampede detection. These datasets lay a viable impact in theoretically determining the aftermath of these models. Sample frames have been displayed in fig. 4 and fig. 5 to visually depict the dataset. The Agoraset dataset tries to mimic the realistic crowd behaviour and movement. The video sequences from both sources underwent systematic frame extraction using FFmpeg 5.0, implementing a temporal sampling rate of 60 Hz to capture nuanced motion patterns. FFmpeg is a collection of libraries Each extracted RGB frame is then resized to 224Inline graphic224 pixels using bilinear interpolation, balancing computational efficiency with preservation of critical crowd features.

Fig. 4.

Fig. 4

Key challenges in stampede detection research.

Fig. 5.

Fig. 5

Sample frames from agoraset dataset [27].

A critical preprocessing transformation involved converting all RGB frames to grayscale using the luminosity method (Y = 0.299R + 0.587G + 0.114B). This conversion optimizes subsequent optical flow computation by eliminating chromatic variations that may introduce noise in motion analysis. The grayscale frames then underwent the Farneback optical flow algorithm25 implementation, which computes dense displacement fields between consecutive frames using polynomial expansion. This approach models the neighborhood of each pixel with quadratic polynomials, enabling robust motion estimation even in low-texture regions common in crowd scenarios. The optical flow computation is explained in section 4.2 in detail.

The resulting optical flow fields were stored as two-channel matrices the horizontal and vertical displacement components with equivalent 224Inline graphic224 resolution to maintain spatial correspondence with input frames. This optical flow dataset is the primary input to the model for subsequent feature extraction and temporal modeling. To ensure balanced representation across crowd density states, the combined dataset of 10,000 frames was manually annotated by according to a four-tier classification system. The four classes are: normal (low density, free movement), moderate (medium density, slight congestion), dense (high density, restricted movement), and risky (critical density, potential stampede conditions). Each classification tier was populated with roughly 2,500 individual frames, systematically aggregated from multiple distinct spatial scenarios. The final preprocessed dataset incorporated the optical flow sequences, organized into 16-frame temporal segments. To evaluate the model with new datasets, in addition to the training & validation datasets, cross-dataset evaluation was done with publicly available UMN dataset, which has several scene sequences depicting sudden, abnormal crowd dispersal. To rigorously test the model’s zero-shot generalization capabilities, it was evaluated on the UMN dataset without any domain-specific fine-tuning or retraining.. Therefore, scene sequences from the UMN dataset were used for cross-dataset evaluation and has been discussed in detail in section 6.6.

Enhanced optical flow extraction

The proposed methodology employs a multi-channel optical flow extraction approach that processes individual RGB channels separately before combining them for enhanced motion representation. Initially dense Farneback flow on all 3 RGB channels is computed and then take the average of these 3 per-channel motion estimates to obtain v_avg, which provides a stronger value than just computing on luminance or one channel. This averaging process helps reduce noise due to channel-specific lighting changes (e.g., highlight glare, shadow), resulting in one solid yet reliable motion estimate in both magnitude/direction statistics that has been averaged over different lighting conditions. The optical flow extraction enables the model to determine the magnitude of movement in each frame. This helps in evaluating the motion of the crowd or the associated flow of pattern. For consecutive frames It and It+1, optical flow is computed using the Dense Farneback method across each color channel. Equation (1) tells how this is calculated for each channel of the frame.

graphic file with name d33e613.gif 1

where c in R,G,B represents the color channels, and uc denote the horizontal and vertical flow components respectively. The final optical flow field is obtained by averaging across all the three channels. The average optical flow is depicted in equation (2).

graphic file with name d33e618.gif 2

This multi-channel approach enhances motion detection robustness by leveraging complementary information from different color channels, particularly beneficial in scenarios with varying illumination conditions. Fig. 6 shows three sample frames after optical flow is extracted for them.

Fig. 6.

Fig. 6

sample frames extracted by Farneback optical flow [28] method.

In this work, Dense Farneback method is used instead of Lucas Kanade technique26. Although, most of the notable work around crowd anomaly and stampedes uses Lucas-Kanade method as the pixel movement in these types of work is sparse. The Lucas Kanade optical flow assumes that the displacement of the image contents between two nearby frames is small and approximately constant within a region of that point under consideration. It works on Shi-Tomasi algorithm27 which detects the corner points. Farneback computes per-pixel displacement fields across the entire frame, which: (a) better captures collective motion patterns in ultra-dense scenes where individual keypoints are unavailable or occluded; (b) provides rich local motion distributions enabling computation of flow-derived descriptors (acceleration, divergence, entropy) that correlate with crowd instability; and (c) simplifies the pipeline by avoiding explicit tracking of individuals.

Advanced feature extraction framework

After implementing optical flow from each frame, four features are calculated for each frame. These feature vectors extract the necessary information which is further used to train and validate the stampede. The features have been selected based on actual chance of stampede. The model was given features for all the scenarios. It learns that how each vector range leads to riskier chances of stampede. The four features are flow acceleration, flow divergence, scene change and motion entropy. In the following subsections, the four features have been discussed.

Flow acceleration analysis

Flow acceleration captures sudden changes in crowd movement patterns by computing frame-wise differences in Farneback optical flow. Equation (3) explains how acceleration is calculated for each pixel in the frame.

graphic file with name d33e651.gif 3

Here, vt(x, y) and vt1(x, y) are the velocity field for time t and t-1. The velocity is calculated by determining optical flow gradient for frame at time t and t-1. Equation (4) describes how flow gradient is calculated. Where, vc(x,y) is the optical flow for a frame.

graphic file with name d33e656.gif 4

The mean acceleration for each frame is calculated as shown in equation (5).

graphic file with name d33e661.gif 5

Here, H and W are height and width of the frame which calculates acceleration for all the particles in that frame.

Flow divergence computation

The spatial divergence quantifies crowd expansion or contraction patterns using gradient operations. Equation (6) explains how the divergence is calculated. The optical flow is differentiated with x–axis and y-axis for a time t and the corresponding gradients are added.

graphic file with name d33e670.gif 6

In equation (6), partial derivatives are computed using Sobel operators with kernel size 3Inline graphic3. In equation (6), ut is the flow component in x-direction and vt is the flow component in the y-direction.

Scene change detection via SSIM

Structural Similarity Index Measure (SSIM) detects abrupt scene changes that may indicate emergency situations. Equation (7) describes SSIM’s formulation in brief. Here, It and It+1 are the grayscale frames for a time t and t+1.

graphic file with name d33e683.gif 7

The Inline graphic is the mean intensity or the average pixel value in that frame as shown in equation (8).

graphic file with name d33e692.gif 8

The Inline graphic is the variance of intensities between two successive frames as shown in equation (9).

graphic file with name d33e701.gif 9

The Inline graphic is the covariance between frames as given in equation (10).

graphic file with name d33e711.gif 10

The Inline graphic and Inline graphic constants are introduced to stabilize the division and avoid instability when denominators are near zero.

graphic file with name d33e724.gif 11
graphic file with name d33e728.gif 12

Finally, the scene change metric is calculated by implementing SSIM between two successive frames and then subtracting the value from one. Equation (13) depicts how the change is calculated.

graphic file with name d33e734.gif 13

4.3.4 Motion Entropy Calculation

Motion entropy measures the randomness and chaos in crowd movement patterns as given in equation (14).

graphic file with name d33e742.gif 14

where Inline graphic represents the probability distribution of optical flow magnitudes obtained through histogram normalization with 32 bins.

Network architecture design

The hybrid CNN-LSTM architecture combines the advantages of spatial feature extraction with time-series modeling. Time distributed convolutional layers learn local motion textures from a flow map, while LSTM layers operate as a Temporal aggregation to identify short-term patterns that can help to distinguish between coherent, chaotic and stampede prone motion. This design avoids developing end to end 3D-CNN’s or transformer networks that, while still powerful, require far greater amounts of compute and memory that can restrict edge ability to deploy. The scalar features are quantized and concatenated as an additional means of creating lower dimensional complementary signals, thus improving model interpretability and lessening the pressure on sequence modeling requirements. To provide empirical support for the design decisions discussed above, there will be a set of ablation studies applied in order to compare both (i) CNN-LSTM with scalar descriptors, (ii) CNN-LSTM without scalar descriptors and (iii) a baseline of a lightweight 3D CNN.

Optical flow processing branch

The optical flow input branch processes sequences of shape (T, H, W, 2) where Inline graphic represents the temporal sequence length. The H and W are the height and width of the frame. The use of 16 frames with 12 frames of overlap creates a compact amount of temporal context that (1) captures small bursts of acceleration and divergence that occur before structural collapse, and (2) allows for the density of the temporal context to be maximized with overlapping frames without increasing the number of sequences that need to be processed during inference. Time-distributed convolutional layers extract spatial features from each frame as shown in Table 1. These layers are responsible for extracting the feature vectors and then passing them to the LSTM branch after feature processing. ReLU activation has been applied over each layer of the network.

Table 1.

Layer-wise architecture of CNN branch.

Layer type Parameters / details Output shape
Conv2D 32 Filters, Inline graphic kernel, ReLU activation (224, 224, 32)
BatchNormalization – (224, 224, 32)
MaxPooling2D Inline graphic pooling (112, 112, 32)
Conv2D 64 Filters, Inline graphic kernel, ReLU activation (112, 112, 64)
MaxPooling2D Inline graphic pooling (56, 56, 64)
Conv2D 128 Filters, Inline graphic kernel, ReLU activation (56, 56, 128)
BatchNormalization – (56, 56, 128)
MaxPooling2D Inline graphic pooling (28, 28, 128)
Flatten Converts spatial features to 1D vectors Inline graphic

Scalar feature processing branch

The four computed scalar features undergo quantization and binarization. The first three features, flow acceleration, flow divergence, and the scene changes (SSIM), are quantized from the range 0–1 decimal points to 8-bit values. Whereas the fourth feature, motion entropy, is quantized from 0–4 to 8-bit values. This was done after the range of these features was determined from the combined dataset. Each of these 8-bit values is converted to binary representation, resulting in 32-bit feature vectors per frame. The main objective of this is to provide a low-bandwidth alternative to feature vectors, by making it easy to create binary codes for feature vectors, and (2) to provide a compact representation for the scalar motion features while still providing enough resolution to discriminate between the different threshold values required

Temporal processing and classification

The concatenated features from both branches are processed through LSTM layers 2.

Table 2.

Layer-wise architecture of CNN branch.

Layer type Parameters / details Output shape
LSTM layer 1 256 units, return sequences = True (16, 256)
Dropout 0.3 dropout rate (16, 256)
LSTM layer 2 128 units, return sequences = False (128)
Dropout 0.3 dropout rate (128)
Dense layer 64 units, ReLU activation (64)
BatchNormalization – (64)
Output layer 4 units, softmax activation (4)

Experimental setup

Training configuration and hardware specifications

The model was implemented using the TensorFlow framework with Keras high-level API. The training was conducted using the following hyperparameters as shown in Table 3.

Table 3.

Parametric configuration.

Parameter Value / description
Batch size 8 Sequences
Learning rate 0.001 (Adam optimizer 28)
Sequence length 16 Frames
Loss function Categorical cross-entropy
Evaluation metric Classification accuracy

Training was performed on a system equipped with GPU configuration comprising an NVIDIA RTX 4070 12 GB RAM with memory growth enabled. The framework implemented is TensorFlow 2.x with CUDA support. While implementing, memory management has been integrated with dynamic GPU memory allocation to prevent OOM errors.

The optical flow sequences were normalized to Inline graphic range to ensure stable training convergence. The scalar features underwent quantization and binarization to create compact binary representations suitable for neural network processing. These binary values were then sent as an input to the model architecture. This further reduces computational complexity while preventing overfitting of the model.

Results

The following section is divided into 5 segments. The training performance has been fed with the preprocessed optical flow frames. While during testing, test video of were directly given to the model which preprocessed it, extracted optical flow and tested the model.

Training performance

The proposed enhanced CNN–LSTM model demonstrated convergent learning behavior across 10 training epochs. The training and validation metrics are summarized in Table 4. It should be noted that all the other parameters were unchanged and these are the results over the configurations as previously explained in Table 3.

Table 4.

Model results.

Metrics Performance
Training accuracy 99.751%
Validation accuracy 99.231%
Training loss 0.0443
Validation loss 0.0073

In Figure  7, it can be seen how the CNN-LSTM model’s training progression is shown regarding two values - loss and accuracy. The figure shows that the trained loss does not decrease; therefore, the network’s parameters’ optimization is stable. The validation loss shows a similar downward movement as seen in the losses, but exhibits small fluctuations at epoch 20-22. The cause of the small deviation can be attributed to the dense optical flow based motion features’ sensitivity to localized changes in crowd dynamics - particularly near the class transition boundaries from moderation to density. These fluctuations, however, are not sustained across epochs and are not an indication of systematic overfitting.

Fig. 7.

Fig. 7

Training and validation loss and accuracy curves for the proposed CNN–LSTM model across epochs.

In addition, the accuracy curves presented in Figure  7 support this finding. As the training accuracy increases over time, it remains stable at greater than 95% accuracy. On the other hand, the validation accuracy peaks at close to 99.23% after a number of intermediate epochs where small fluctuations in validation accuracy occur. However, these small fluctuations in the validation accuracy during these intermediate epochs were addressed through early stopping. Early stopping automatically stops the training of a model when the performance has stopped improving and restores model weights to the epoch with the highest performance. The approach of using early stopping ensures that all reported results are from a model that has the ability to generalize effectively and not overfit.

Taken together, the patterns shown by the accuracy curves in Figure  7 indicate that the suggested model is capable of achieving reliable convergence and effective generalization performance while accounting for the variability of motion patterns found within a crowd. As such, concerns regarding the stability and robustness of training have been successfully addressed.

The CNN–LSTM model’s key training statistics can be found in Table 5. Strong performance characteristics included overall good and stable convergence behaviour during training, with early stopping set to epoch 30 for optimum model selection, achieving both high accuracy for train and validation data, with lower training losses.

Table 5.

Training Summary of the Proposed CNN–LSTM Model.

Metric Value
Best epoch (early stopping) 30
Total epochs trained 40
Training accuracy 99.75%
Validation accuracy 99.23%
Training loss 0.044
Validation loss 0.007
Optimizer Adam
Learning rate 0.001

An early stop with a patience of 10 epochs was utilized regarding validating accuracy to determine when to stop training. The stopping point reached was at epoch 40 where model weights returned from epoch 30 shown to have had the highest validating accuracy for the across subsequent evaluations.

this work utilized a random seed that remains constant for all experiments to provide a predictable outcome when initializing weights or shuffling data. The repetition of the experiments resulted in similar convergence trends, suggesting that the results are robust with regard to random initialisation.

Classification performance

The model’s performance on the test dataset yielded the following detailed results as shown in Table 6. The sample frames in the test sequence are given in Fig. 8. The crowd flow in the test dataset was risky, indicating that it was not normal. Since there are two small channels through which the crowd is passing but the movement is slow and nearly coherent, the overall predictions were risky.

Table 6.

Predictive results over the test dataset as in Fig. 8.

Classifiers Probabilistic percentage
Normal 0.19%
Moderate 0.01%
Dense 0.05%
Risky 99.75%

Fig. 8.

Fig. 8

Sample frames of the test dataset.

The final classification, as shown in Table 6, indicates a risky crowd condition with an estimated confidence of 99.75%, suggesting a clear predominance of moderate-risk features in the analyzed sequence.

In Figure  9, it can be seen that the results from the validation set (260 samples) evenly divided over the four crowd risk classifications. The proposed model correctly predicted a total of 258 of the 260 samples, resulting in 2 misclassifications. Both of these misclassifications occurred on the boundary between the moderate crowd and risky crowd classification levels, hence the gradual transitions between the different risk categories are representative of the fact that risk categories can evolve gradually.

Fig. 9.

Fig. 9

Confusion matrix for the validation set across four crowd risk classes (normal, moderate, dense, risky).

Importantly, none of the misclassifications between normal and risky crowds occurred. This is a significant benefit for applications that focus on safety since it ensures that low-risk events will not be classified as high risk, and vice versa. By maintaining this characteristic, there is a reduced likelihood of false alarms and missed critical events. Both of these factors are of paramount importance in the context of real-world stampede prevention systems.

Performance across all classes is shown to be equally balanced by the confusion matrix with no systematic discrimination towards a specific risk level. The model’s ability to learn discriminative spatio-temporal movement patterns is demonstrated by the strong diagonal dominance of the confusion matrix, which indicates that the model does not depend solely on the frequency of occurrence of instances in each class or on surface visual characteristics. Generally, the low amount of confusion and the types of confusion detected indicate that the proposed framework is a robust and trustworthy solution for the assessment of crowd risks across multiple levels.

In Figure  10, the Receiver Operating Characteristic (ROC) curve representing the one-versus-all classification of each risk profile shows results for the 4 crowd risk classifications using the validation dataset. AUC values for the normal, moderate, and dense classes are 1.000, and for the risky class, 0.9994, indicating excellent separation between all classes based on learned spatiotemporal representations derived from dense optical flow, plus temporal modelling. Therefore, the study confirms that the model successfully identifies high-risk crowd conditions, and low-risk crowd conditions that exhibit both visually and behaviourally identical characteristics.

Fig. 10.

Fig. 10

One-vs-rest ROC curves for the four crowd risk classes on the validation set.

A particularly noteworthy result regarding the AUC for the risky class is its significance regarding safety, as it clearly demonstrates the effectiveness of the model’s ability to separate conditions of risk from those of lower-risk (i.e., normal, moderate, or dense) using the same information set employed for both classes. In addition, the exceptionally high performance of the ROC curves supports the finding that the model is capable of producing positive predictive values across the entire spectrum of decision threshold levels and, thus, have a high probability of correctly detecting situations that represent extreme crowd risk while simultaneously minimising the number of false positives.

Finally, ROC-AUC analysis supports the robustness of the proposed framework and strong separability was observed in in-domain validation experiments. Cross-dataset testing on UMN revealed performance degradation due to domain shift effects, highlighting the importance of threshold calibration and domain adaptation strategies for real-world deployment.

As presented in Table  7, the model demonstrates consistently high levels of precision, recall, and F1-scores across crowds classified as low, medium, high or very high risk, and nearly perfect recall for both the dense and the risky classes (which are of utmost importance in preventing stampedes).

Table 7.

Class-wise Classification Performance on the Validation Set.

Class Precision Recall F1-score Support
Normal 1.00 1.00 1.00 37
Moderate 1.00 0.99 0.99 73
Dense 0.99 1.00 0.99 71
Risky 0.99 0.99 0.99 79
Accuracy 0.99 260
Macro Avg 0.99 0.99 0.99 260
Weighted Avg 0.99 0.99 0.99 260

Inference latency metrics

While validating classification accuracy is very important, computational efficiency must also be taken into account for any stampede detection systems that will likely be deployed in a “real-world” environment. This subsection discusses and evaluates inference latency and run-time profiles of the proposed model under realistic conditions of use, including optical FLOW calculations, feature extraction and CNN-LSTM inference.

All of the inference experiments were conducted on a CPU/GPU system; all inference experiments used a temporal window of 16 frames, which corresponds with the training configuration described in Section 5, and a batch size of 8 frames. This means that a temporal window of 16 frames is used and processed the frames in batches of eight. Run-time statistics for all inference experiments were obtained directly from logs generated by the system so that it can be easily verified and reproduced by others.

The table  8 shows the end-to-end inference latency of our proposed framework. The time taken to process a 16-frame sequence was an average of 0.173 seconds. This means that on average, it took 0.078 seconds for each frame to be processed, resulting in an effective throughput of approximately 12.77 FPS. In addition to taking into account the time spent processing the frames with dense farneback optical flow extraction, the study also included time spent on the inference process performed by the neural network, allowing us to estimate what could be expected from a deployed product versus a product that is being run in isolation.

Table 8.

Inference Latency and Throughput of the Proposed Framework.

Metric Value
Average time per 16-frame sequence 0.173 s
Average time per frame 0.078 s
Effective throughput (FPS) 12.77
Processing scope Optical flow + inference
Execution device CPU

The provided terminal screenshot in Figure  11 allows for verification that all reported latency values were obtained via actual execution, rather than from post-processing or estimates. As seen in the screenshot, it contains the runtime configuration (including batch size, execution device, per-sequence inference time, and effective throughput). The screenshot serves to confirm that all performance metrics reported are authentic.

Fig. 11.

Fig. 11

System-generated terminal output showing end-to-end inference execution and latency measurements and real-life testing results. The screenshot reports batch size, temporal window length, execution device, processing time per sequence, and effective throughput on a CPU-only setup.

Figure  12 presents a terminal snapshot of the execution of inference in batches and the flow through in pipelines. It has been demonstrated that the optical flow extraction, scalar feature computation, and CNN-LSTM inference are performed serially in one cohesive pipeline with no manual input required. The latency measurements reported therefore represent the entire pipeline execution rather than just a portion of model inference.

Fig. 12.

Fig. 12

Terminal snapshot illustrating batch-wise execution of the complete inference pipeline, including optical flow extraction, feature computation, and CNN–LSTM inference.

The measured corresponds to an end-to-end processing latency of 0.173 seconds per 16-frame temporal window. Since crowd instability patterns evolve over multi-second intervals rather than single-frame timescales, the system satisfies practical early-warning latency requirements even without GPU acceleration. Furthermore, the measured throughput incorporates the very intensive and time consuming optical flow extraction process which is determined to be the major computational bottleneck. Moreover, the inference part of the model alone runs at a much faster speed; therefore if the optical flow extraction part of the model runs via GPU accelerated or faster than real-time processing, then this model will operate at full realtime performance (25–30 frames per second).

Additional improvements to inference latency can be realized using GPU acceleration, techniques for approximating optical flow, and edge optimizations when deploying the proposed framework. Distributed inference can also be achieved in multi-camera systems, whereby inference may be parallelized between two or more cameras, or between cameras and edge devices, thus allowing scalable implementation in real world environments without the necessity of centralizing all computation.

Qualitative and real-world video evaluation

Along with conducting quantitative validation of the system, qualitative evaluations were performed utilizing actual video samples that were not previously used in the training phase of the project in order to assess the performance of the framework on previously unused real-world video input data. This evaluation process was run to investigate whether or not the spatiotemporal representations learned by this method, when evaluated on real-world test data not included in the training process of the project, would generalize to produce reasonable and understandable outputs while working under realistic crowd monitoring conditions.

To do this, a previously unseen test video, which consisted of a total of 129 frames captured at 30 frames per second (FPS), was used for the performance evaluation. After preprocessing, 120 frames were kept for the evaluations. In total, there were 119 optical flow frames and 20 temporal sequences of 16 frames each that were analysed as input data to the framework. The complete inference pipeline (optical flow extraction, feature extraction, and the subsequent CNN–LSTM inference phase) for this evaluation was run automatically and without any user intervention, as can be seen in the system-generated outputs created in the terminal window of the system.

As indicated in Figure  11, the qualitative results of the testing of the framework on the previously unseen video sample are shared. Overall, the results from the model conclude that the general state of the crowd was determined to be unsafe based on the high level of confidence of 99.75% associated with this classification, along with very low confidence (low probabilities of classification) for the normal, moderate, and dense states of the crowd. The predictions are consistent with observed motion instability, high degrees of flow divergence, and increasing amounts of motion entropy seen in the actual video, which may indicate a potential risk to the crowds being observed.

To improve transparency, predictions generated by the framework are overlaid on top of the isotropic space and separated into folders depending on whether they were predicted correctly or incorrectly. By visually examining these predictions, it is evident there is a strong relationship between the predictions made and how crowds move through space. Most of the misclassifications observed in this study were due to the subject’s transition from being in an exploratory state to another (i.e., the misclassification occurred during the transition).

To clarify, while the study was designed to be a qualitative case study, the fact that the framework produced stable high-confidence predictions that do not use dataset-specific features indicates the robustness of this predictive model when applied to real-world video recordings. Additionally, these qualitative results support the findings in Sections 6.1 through 6.3, adding further evidence to support the use of this framework in real-time monitoring of crowds and early warning systems for potential crowd disasters.

Comparative analysis

The proposed framework in this study outperforms and has a higher degree of deployment feasibility than other recent methods as shown in table  9. This model incorporates a four-tiered crowd risk assessment in a way that provides a gradual assessment and enables early stage intervention versus suddenly triggering an alarm in reaction to a detected event. This characteristic makes this configuration useful to large scale public monitoring systems, where crowd dynamics rapidly change.

Table 9.

Comparative Analysis of Crowd Anomaly and Stampede Detection Methods.

Method (Ref) Architecture Dataset(s) Acc. (%)
Dense optical flow DL model18 CNN + Dense Optical Flow Multi-crowd Stampede Datasets 99.53
C3D-LSTM with attention19 C3D (3D CNN) + LSTM + Attention Benchmark Crowd Datasets 99.4
Sparse feature tracking + NN20 SIFT/FAST/AKAZE + Sparse Tracking + PCA/Autoencoder + NN UMN Scene 1 99.5
Sparse feature tracking + NN20 Same as above UMN Scene 2 96.1
Sparse feature tracking + NN20 Same as above UMN Scene 3 99.0
Sparse feature tracking + NN20 Same as above Violence in Crowds 88.5
Our approach CNN+LSTM and Farneback Optical Flow UCSD and AGORASET 99.75

Compared to existing models that utilise dense optical flow combined with deep learning, the framework developed here has a very good classification accuracy but expands the risk categorisation to three tiers. By providing more than a single tier for abnormality classification, the framework improves the ability to accurately interpret transitional states of crowds and provides a better opportunity to make appropriate interventions earlier. Compared to volumetric 3D CNN architectures that incorporate attention mechanisms, both of which are very computationally intensive, the CNN-LSTM architecture used in the current framework utilises a hybrid spatiotemporal representation that enables efficient operation even on devices with limited processing power.

Cross-dataset validation on UMN dataset

In order to assess the proposed network’s ability to generalize across different domains, additional validation experiments were performed with an external dataset from the UMN crowd. The proposed model had no training or fine-tuning on any of the UMN data. The dataset was used for out-of-distribution testing only. The UMN sequences used for validation purposes were run through the same preprocessing pipeline outlined in Section 4.1. To ensure optimal decision boundary selection under domain shift conditions, ROC analysis was performed on the UMN predictions. The optimal threshold was selected using Youden’s J statistic29, resulting in a best threshold value of 0.5512 as mentioned in figure 13.

Fig. 13.

Fig. 13

ROC analysis over UMN predictions to determine the best threshold value.

After threshold optimization, the model achieved the following performance as shown in figure 14.

Fig. 14.

Fig. 14

Terminal snapshot depicting the results over the UMN dataset.

The model was able to correctly identify 4 out of 5 abnormal sequences, as well as 3 out of 5 normal sequences. For cross-dataset evaluation, all available frames from the UMN crowd dataset were utilized to construct 10 temporal sequences. Since the UMN dataset primarily depicts sudden crowd dispersal events rather than gradual high-density buildup, the original four-class taxonomy was mapped into a binary formulation for external testing. Sequences corresponding to the risky class were grouped as abnormal, while normal and moderate sequences were grouped as normal. The performance has decreased compared to IN-domain validation results, but the model still has sufficient discriminative power without the need to retrain. The drop in AUC suggests that there is domain shift because of variations caused by difference in audience, scene structure, camera angles, crowd dispersal, and lighting between the tests. The optimized threshold successfully prioritized safety-critical events, achieving an 80% recall for abnormal sequences. However, the model demonstrates its ability to detect abnormal dispersal behaviour on a dataset that included only a subset of UML specific patterns not used during training, and demonstrates that the learned spatiotemporal representations of optical flow reflect general dynamics of instability in crowds rather than particularities of any given dataset.

Discussion

The experimental results demonstrate the effectiveness of the proposed multi-modal approach for crowd density classification. The model’s ability to achieve convergent training while maintaining reasonable validation performance indicates successful integration of optical flow features with scalar motion characteristics. The classification results reveal interesting patterns in crowd behavior recognition. The predominant classification suggests that the model has learned to identify intermediate crowd states effectively. The distribution across risk categories indicates the model’s capability to distinguish between different crowd density levels.

While in-domain validation results indicate near-perfect separability across the four risk classes, cross-dataset evaluation on the UMN dataset reveals a measurable performance degradation under domain shift conditions. The observed reduction in AUC suggests that although the model captures general motion instability dynamics, its decision boundary is partially dataset-dependent. The contrast between near-perfect in-domain ROC curves and moderate cross-domain AUC highlights the sensitivity of spatiotemporal crowd representations to camera geometry and scene semantics. This highlights the intrinsic challenge of transferring crowd behavior models across heterogeneous environments characterized by differing camera perspectives, density distributions, and illumination conditions. The cross-validation process for the UMN dataset, although limited to ten temporal sequences, acts as an initial, qualitative assessment of the out-of-distribution behavior for the model. The results demonstrate that the global decision boundaries remain sensitive to camera angle and behavioral changes, while the underlying motion instability features retain the capability to detect high-risk anomalies without any pre-existing domain knowledge.

The system sends risk labels or alerts to the cloud, reducing the need for high bandwidth and low latency as frames can be processed locally via edge devices. The model can also be deployed as an inference-optimized container at the surveillance fleet hubs, thus decreasing reliance on the cloud for functioning. In a typical configuration of the model workflow, live feeds from cameras would go through a lightweight pre-processing module that continuously buffers short-duration sequences of video, and subsequently extracts flow and scalar feature sets from the frame batches before forwarding the resultant inference-ready batches to the model for analysis.

The system processes on a 16-frame temporal window, taking approximately 0.173 seconds to process and delivering an effective throughput of 12.77 FPS on CPU-only hardware. This, while not delivering true frame-level real-time processing at 30 FPS, is more than sufficient to deliver on the latency requirements of a true decision-level early warning system, where risk estimation is performed on short temporal windows rather than individual frames. A detection latency of less than one second is more than sufficient for many safety-critical applications of crowd monitoring systems.

Although these results were generated using an twenty four-thread CPU with a batch size of eight, the pipeline has a modular architecture that allows for the easy parallelization of the pipeline across many camera streams. Each video feed can be assigned to a unique process. As such, simultaneous inference can be conducted on many video feeds. NVIDIA GPUs such as the NVIDIA RTX 4070 will also provide support for the simultaneous inference of eight to eleven video feeds at near real-time speed if the proper system to optimize the use of shared queues, and batch scheduling is used, as stated above. As future work will demonstrate this configuration, and demonstrate distributed inference across edge devices for scalable, low-latency collection of risk information about crowds.

This research introduces some novel contributions to the field of automated crowd analysis.

  1. Four-Class Density Classification: Unlike existing binary classification approaches which mainly focus on normal or abnormal sequences, this study introduces a comprehensive four-class taxonomy that provides granular risk assessment capabilities.

  2. Multi-Channel Optical Flow Integration: The proposed RGB channel-wise optical flow computation followed by averaging provides enhanced motion detection robustness compared to traditional single-channel approaches.

  3. Hybrid Feature Fusion: The integration of spatial optical flow features with temporal scalar features through dual-input architecture enables comprehensive crowd behavior analysis.

  4. Quantized Binary Feature Representation: The novel quantization and binarization scheme for scalar features creates efficient compact representations suitable for real-time processing applications.

Limitations and future directions

The model’s execution time was significantly high, and for complete processing indicates computational complexity that may require optimization for real-time deployment. In the future, research should focus on architecture-level strategies for optimizations. These include pruning, quantization, and operator fusion. Additionally, hardware-aware neural design may be optimized to minimize latency and memory. Other methods such as weight sharing in the form of parameter hashing, low-rank factorization of weight matrices, parallel inference, and knowledge distillation can be used. Concurrently, light-weight architectures such as GhostNet30 and ShuffleNet31 can be adopted. GhostNet produces additional feature maps using cheap linear transformations, while ShuffleNet uses grouped 1Inline graphic1 convolutions followed by a channel-shuffle step. parallel inference computations can be divided across devices such as CPUs or cloud configurations, and runtimes such as ONNX Runtime distribute computations to GPUs and other accelerators, taking advantage of multi-core parallelism. Edge-focused deployment options are also viable such as on-device inference, model partitioning, and asynchronous stream processing. Other additional leverage points may include being able to robustly handle occlusion and domain shifts through semi-/self-supervised adaptation, establishing calibrated early-warning thresholds through uncertainty estimation, and privacy-preserving analytics that facilitate reliable, real-time operation within multi-camera, bandwidth-constrained environments.

There are a few other aspects which warrant consideration to make it more robust and scalable. The first aspect is scaling the dataset. While 10,000 frames provide substantial training data and fulfilling validation needs, larger-scale datasets could improve generalization capabilities. Apart from this the real-time processing can be further optimized. Current processing speeds may not meet real-time requirements for critical applications. The current data is limited to Environmental Variations; Testing the model across diverse environmental conditions like lighting, weather, camera angles would strengthen robustness validation of the model.

The model does not directly detect individuals or track them; therefore, it does not impose a privacy risk associated with surveillance techniques; however, visual data will contain sensitive context and the deployment of anonymization strategies such as on-device processing or using only flow-based inference (e.g., not reconstructing images) should be considered to ensure the protection of privacy. Federated learning for local training and fine-tuning of models at different locations at the same time without transferring raw video also has the potential to meet user privacy and regulatory requirements; future studies should investigate combining differential privacy with encrypted inference pipelines. The future of stampede detection technology lies in the convergence of multiple technological paradigms, including artificial intelligence, Internet of Things, augmented reality, and advanced sensor networks28,32. The integration of these technologies promises to create comprehensive crowd management ecosystems capable of addressing the full spectrum of crowd safety challenges33. Although the model demonstrates reasonable performance on the UMN dataset without retraining, the reduced AUC score suggests that spatiotemporal representations remain partially domain-specific. The UMN evaluation was conducted on a limited number of abnormal sequences, and future work should incorporate larger, more diverse external benchmarks to better quantify generalization robustness. Domain adaptation strategies such as CORAL alignment, adversarial feature adaptation, or self-supervised fine-tuning may further improve cross-environment transferability. The proposed methodology establishes a foundation for advanced crowd safety systems with potential applications in public event management, transportation hubs, and emergency response planning.

Conclusion

The proposed work presents a hybrid CNN-LSTM approach for multi-tiered risk assessment of crowds using dense Farneback optical flow and other scalar motion descriptors to produce a four-category taxonomy (normal, moderate, dense, and risky) that will allow for progressive risk stratification useful for early intervention. By leveraging multiple optical flow channels, compact scalar features, and LSTM layers, the system captures both the spatial structure of motion and the short-term dynamics of instability without having to track individuals explicitly. Through testing on both UCSD and Agoraset datasets, our results have been validated in-domain with overall training classification accuracy of 99.75%, validation classification accuracy of 99.23%, and very good area under the receiver operating characteristic curve (AUC) separability across all categories. The system processes on a 16-frame temporal window, taking approximately 0.173 seconds to process and delivering an effective throughput of 12.77 FPS on CPU-only hardware. This, while not delivering true frame-level real-time processing at 30 FPS, is more than sufficient to deliver on the latency requirements of a true decision-level early warning system, where risk estimation is performed on short temporal windows rather than individual frames. A detection latency of less than one second is more than sufficient for many safety-critical applications of crowd monitoring systems.

Using the UMN benchmark for cross-dataset assessments provides additional information on the overall performance of the model when it is transferred from one data set to another. The model was able to provide reasonable results without retraining on new datasets but after using a ROC Curve and Youden’s J on the developed thresholds, determined that a significant proportion of abnormal events were also detected correctly. The validation showed the model is still performing worse than previous validation trials conducted with the model using only within-domain data but validates that the learned representation of motion for this model captures patterns of instability in crowds that are able to transfer to different data sets instead of being data-set specific artifacts. Continued research will focus on reducing the computational bottleneck of developing dense flow fields at run-time while mitigating the influence of the heterogeneous characteristics of data from a diverse population on models learned based on merging multiple sources of data. Future studies will also explore the use of light-weight approximations of motion, adapting datasets from different domains, and validating developed thresholds using uncertainty methods as well as using large-scale multi-domain validations to develop a practical methodology for providing an early warning of predictive risk through a combination of graduated risk assessments and computationally efficient spatiotemporal modeling in dense crowds through scalable and deliverable systems.

Author contributions

G.B. and S.S. conceptualized the study and designed the overall methodology. G.B. and H.R.N. performed dataset preparation, preprocessing, and optical flow extraction. H.R.N. and S.K. implemented the CNN–LSTM architecture and conducted the experimental analysis. S.K. assisted with feature extraction, quantization, and result validation. S.S. supervised the research, contributed to model design, and guided the experimental framework. G.B. and S.S. wrote the initial draft of the manuscript. All authors contributed to result interpretation, reviewed the manuscript, and approved the final version.

Funding

Open access funding provided by Manipal University Jaipur. The authors received no financial support for the current research.

Data Availability

The datasets used and/or analyzed during the current study are available from the corresponding author on reasonable request.

Declarations

Competing interests

The authors declare no competing interests.

Footnotes

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

These authors contributed equally to this work.

References

  • 1.Cob-Parro, A.C., Losada-Gutiérrez, C., Marrón-Romera, M., Gardel-Vicente, A., Bravo-Muñoz, I. & Sarker, M.I. A proposal on stampede detection in real environments. In: Proceedings of the IPIN 2021 WiP, Lloret de Mar, Spain (2021). https://ceur-ws.org/Vol-3097/paper29.pdf
  • 2.Sharif, M. H. & Djeraba, C. An entropy approach for abnormal activities detection in video streams. Pattern Recogn.45(7), 2543–2561. 10.1016/j.patcog.2011.11.023 (2012). [Google Scholar]
  • 3.Duives, D. C., Oijen, T. & Hoogendoorn, S. P. Enhancing crowd monitoring system functionality through data fusion. Sensors20(20), 6032. 10.3390/s20216032 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Lalit, R. & Purwar, R. Crowd abnormality detection using optical flow and glcm-based texture features. J. Inf. Techn. Res.15 (2022) 10.4018/JITR.2022010110
  • 5.Jadhav, C., Ramteke, R. & Somkunwar, R. K. Smart crowd monitoring and suspicious behavior detection using deep learning. Revue d’Intelligence Artificielle37(4), 955–962. 10.18280/ria.370416 (2023). [Google Scholar]
  • 6.Sun, M., Wang, Y. & Zhao, Z. Stampede alert clustering algorithmic system based on tiny-scale strengthened detr. arXiv (2024)
  • 7.Obbo, A., Ariho, P. & Nabaasa, E. Towards people crowd detection using wireless sensor networks. European J. Techn.6, 32–48. 10.47672/ejt.1071 (2022). [Google Scholar]
  • 8.Altowairqi, S., Luo, S. & Greer, P. A review of the recent progress on crowd anomaly detection. International Journal of Advanced Computer Science and Applications (2023)
  • 9.Choi, J.-H., Kim, J.-H., Nasridinov, A. & Kim, Y.-S. Three-dimensional atrous inception module for crowd behavior classification. Sci. Rep.14(1), 14390. 10.1038/s41598-024-65003-6 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Helbing, D., Farkas, I. & Vicsek, T. Simulating dynamical features of escape panic. Nature407(6803), 487–490. 10.1038/35035023 (2000). [DOI] [PubMed] [Google Scholar]
  • 11.Zhang, Y., Zhou, D., Chen, S., Gao, S. & Ma, Y. Single-image crowd counting via multi-column convolutional neural network. In: IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 589–597 (2016). 10.1109/CVPR.2016.70
  • 12.Xiang, J. & Liu, N. Crowd density estimation method using deep learning for passenger flow detection system in exhibition center. Scientific Programming 2022, 1990951 (2022) 10.1155/2022/1990951
  • 13.Benmoussa, N., Elyamami, A., Mansouri, K., Qbadou, M. & Illoussamen, E. A multi-criteria decision making approach for enhancing university accreditation process. Engineering, Technology & Applied Science Research9(1), 3726–3733 (2019). [Google Scholar]
  • 14.Li, Y., Zhang, X. & Chen, D. Csrnet: Dilated convolutional neural networks for understanding highly congested scenes. In: IEEE/CVF Conference on Computer Vision and Pattern Recognition, 1091–1100 (2018). 10.1109/CVPR.2018.00120
  • 15.Mehran, R., Oyama, A. & Shah, M. Abnormal crowd behavior detection using social force model. In: IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 935–942 (2009). 10.1109/CVPR.2009.5206641
  • 16.Yan, D. et al. Enhanced crowd dynamics simulation with deep learning and improved social force model. Electronics13(5), 934. 10.3390/electronics13050934 (2024). [Google Scholar]
  • 17.Juvekar, A., Bhadgaonkar, S., Ghadge, A. & Wakode, M. Anomaly detection in crowd surveillance using edge computing: A comprehensive survey. Journal of Ambient Intelligence and Humanized Computing (2023). Survey article
  • 18.Cob-Parro, A. C., Losada-Gutiérrez, C. & Marrón-Romera, M. Stampede detector based on deep learning models using dense optical flow. Eng. Appl. Artif. Intell.142, 109940. 10.1016/j.engappai.2024.109940 (2025). [Google Scholar]
  • 19.Altowairqi, S., Luo, S., Greer, P. & Chen, S. Efficient crowd anomaly detection using c3d-lstm networks with enhanced attention mechanisms. Array29, 100625. 10.1016/j.array.2025.100625 (2026). [Google Scholar]
  • 20.Altowairqi, S., Luo, S., Greer, P. & Chen, S. Efficient crowd anomaly detection using sparse feature tracking and neural network. Applied Sciences 14(9) (2024) 10.3390/app14093928
  • 21.Ma, Z., Li, L., Li, J., Hua, W., Liu, J., Feng, Q. & Miura, Y. A multimodal, multilingual, and multidimensional pipeline for fine-grained crowdsourcing earthquake damage evaluation. IEEE Transactions on Multimedia (2023)
  • 22.Pothireddy, S. R. Ai-powered copilots are revolutionizing low-code development in the power platform. International Journal of Communication Networks and Information Security17(2), 86–115 (2025). [Google Scholar]
  • 23.Mahadevan, V., Li, W., Bhalodia, V. & Vasconcelos, N. Anomaly detection in crowded scenes. In: IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 1975–1981 (2010)
  • 24.Calgary Stampede: Calgary Stampede 2012 Centennial Highlights. https://www.youtube.com/watch?v=kLm0eC4hOEA. YouTube video, accessed March 2025 (2012)
  • 25.Farnebäck, G. Two-frame motion estimation based on polynomial expansion. In: Bigun, J., Gustavsson, T. (eds.) Image Analysis. Lecture Notes in Computer Science, 2749, 363–370. Springer, Berlin, Heidelberg (2003). 10.1007/3-540-45103-X_50
  • 26.Lucas, B.D. & Kanade, T. An iterative image registration technique with an application to stereo vision. In: Proceedings of the 7th International Joint Conference on Artificial Intelligence (IJCAI), Vancouver, Canada, 674–679 (1981)
  • 27.Shi, J., Tomasi, C. Good features to track. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Seattle, WA, USA, pp. 593–600 (1994). 10.1109/CVPR.1994.323794
  • 28.Kingma, D.P., Ba, J. Adam: A method for stochastic optimization. arXiv (2017)
  • 29.Youden, W. J. Index for rating diagnostic tests. Cancer3(1), 32–35. (1950). [DOI] [PubMed] [Google Scholar]
  • 30.Liu, Z., Hao, Z., Han, K., Tang, Y. & Wang, Y. GhostNetV3: Exploring the Training Strategies for Compact Models (2024). https://arxiv.org/abs/2404.11202
  • 31.Zhang, X., Zhou, X., Lin, M. & Sun, J. Shufflenet: An extremely efficient convolutional neural network for mobile devices. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (2018)
  • 32.Chen, K. F. It is time to modernize disaster preparedness with crowd analysis. JACME13(1), 1–3. 10.6705/j.jacme.202303_13(1).0001 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Mansouri, W., Alohali, M., Alqahtani, H., Alruwais, N., Alshammeri, M. & Mahmud, A. Deep convolutional neural network-based enhanced crowd density monitoring for intelligent urban planning on smart cities. Scientific Reports 15 (2025) 10.1038/s41598-025-90430-4 [DOI] [PMC free article] [PubMed]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

The datasets used and/or analyzed during the current study are available from the corresponding author on reasonable request.


Articles from Scientific Reports are provided here courtesy of Nature Publishing Group

RESOURCES