Intelligent early warning method and system for scenic area congestion
By deploying a high-definition camera network and a density-guided spatiotemporal attention prediction model in scenic areas, the problems of insufficient perception accuracy and prediction bias in scenic area congestion management have been solved, achieving high-precision congestion prediction and dynamic diversion, and improving the overall effectiveness of scenic area congestion management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAZHONG NORMAL UNIV
- Filing Date
- 2026-01-27
- Publication Date
- 2026-05-01
AI Technical Summary
Existing scenic area congestion management technologies suffer from insufficient perception accuracy, mismatch between prediction models and scenarios, and system fragmentation, resulting in low perception accuracy, large prediction deviations, and rigid diversion strategies.
By deploying a network of high-definition cameras to collect real-time video streams, a multi-scale feature extraction and fusion network is constructed to generate a real-time crowd density map. Combined with a density-guided spatiotemporal attention prediction model, scene adaptive prediction and traffic diversion control are performed to build a closed-loop optimization mechanism.
It achieves high-precision congestion prediction and dynamic diversion suggestions, improves the robustness and accuracy of prediction, has self-evolution capabilities, and can adjust diversion strategies according to actual results.
Smart Images

Figure CN121963092A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart tourism and computer vision interdisciplinary technology, and in particular to a method and system for intelligent early warning of congestion in scenic areas. Background Technology
[0002] Current scenic area congestion management technologies suffer from three major flaws: First, insufficient perception accuracy: existing methods mostly use single general target detection or simple bounding box counting for people counting, resulting in a high rate of missed detections when crowds are dense or obstructed, and it is difficult to stably output continuous density distributions that can be used for grid-based aggregation; Second, mismatch between prediction models and scenarios: traditional prediction models do not fully consider the characteristics of scenic area crowd flow, which involves "coexistence of local high-density clustering and global sparse distribution, and nonlinear changes in spatiotemporal correlation," and use uniform modeling for different density areas, leading to large prediction biases; Third, system fragmentation: data collection, analysis, and execution modules operate independently, lacking a closed-loop optimization mechanism based on effect feedback, resulting in delayed early warnings and rigid diversion strategies. Summary of the Invention
[0003] The main objective of this invention is to provide a method and system for intelligent early warning of congestion in scenic areas that can sense and intelligently identify congestion scenarios and perform adaptive prediction and diversion control based on scenario cognition.
[0004] The technical solution adopted in this invention is: A method for intelligent early warning of traffic congestion in scenic areas is provided, including the following steps: S1. Deploy a network of high-definition cameras in the scenic area to collect real-time video streams; S2. Process the video frames, output the real-time crowd density map of each monitored area, and aggregate them into a regional density sequence containing the real-time crowd density values of each area based on the scenic area electronic map grid. S3. Cluster congestion patterns based on historical regional pedestrian density sequences to construct multiple scenario prototype libraries; and perform scenario identification on the regional density sequences of the most recent T time steps based on the multiple scenario prototype libraries, outputting scenario probability vectors. S4. Integrate real-time regional pedestrian density values into a standard spatiotemporal data matrix according to time and spatial location; S5. Based on the scene probability vector, the spatiotemporal data matrix is subjected to scene self-adaptive weighting, and combined with the density-guided spatiotemporal attention prediction model, the congestion risk heat map for multiple future moments is predicted and output. S6. Based on the congestion risk heat map, determine whether to trigger an early warning according to the preset risk assessment threshold; if triggered, combine real-time geographic information and road network, use path planning algorithm to generate recommended diversion routes, and generate early warning and diversion information; S7. After an early warning is triggered, the effectiveness of the diversion action following the previous warning is evaluated based on the real-time regional population density and actual tourist movement data, and the risk assessment threshold and diversion strategy are adjusted accordingly.
[0005] Following the above technical solution, a network of high-definition cameras is deployed in key locations within the scenic area, including entrances, popular tourist areas, main roads, bottleneck sections, and intersections.
[0006] Following the above technical solution, step S2 specifically includes: performing multi-scale feature extraction and fusion through a pre-built network model, and using a non-local attention module for contextual feature enhancement, ultimately outputting a real-time crowd density map. The value of each pixel in the real-time crowd density map is the probability density of heads at that location, and the integral of the entire image is the estimated number of people in that area of the image.
[0007] Following the above technical solution, step S2 further includes: based on the camera calibration parameters and the predefined scenic area electronic map area grid, aggregating and calculating the pixel-level density values of the real-time crowd density map onto each grid to obtain the real-time area crowd density value of each grid.
[0008] Following the above technical solution, step S3 specifically involves: constructing historical samples based on the historical population density sequence of the scenic area, with a fixed window length L, and extracting temporal features such as mean density, peak density, rate of change, and spatial concentration; using a clustering algorithm to divide the historical samples into three scenarios: sudden congestion, normalized congestion, and sparse flow, and forming a scenario prototype library; during online operation, performing scenario identification on the regional density sequence of the most recent T time steps, and outputting scenario labels or scenario probability vectors for subsequent scenario self-adaptive weighting in the prediction model.
[0009] Following the above technical solution, step S4 specifically involves: at fixed time intervals, arranging the density values obtained from all N regions at the current moment in regional order to form a multidimensional feature vector; continuously collecting the multidimensional feature vectors from the past T time steps and stacking them in chronological order to form a T·N spatiotemporal data matrix.
[0010] Following the above technical solution, step S5 specifically involves: predicting and outputting a heatmap of congestion risk at multiple future moments using a pre-built scenario-adaptive density-guided spatiotemporal prediction model. This prediction model specifically includes: The underlying encoder, consisting of multiple layers of LSTM or GRU units, is used to encode the historical density sequence of each region, capture its own temporal pattern, and output the hidden state. The scene-adaptive weight generation module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries. Based on the multiple scene prototype libraries, it performs scene identification on the regional density sequence of the most recent T time steps, outputs scene probability vectors, selects the weight generation subnetwork corresponding to the scene, generates time weight vectors for the past T time steps, and performs differential weighting on the hidden state sequence. The density-guided attention gating module is used to generate a spatial importance weight vector by passing the current or previous pedestrian density vector through a fully connected layer, where higher initial attention weights are assigned to high-density areas. The spatiotemporal attention fusion module is used to calculate the mutual attention between the states of each region in the current hidden state set through a spatial attention mechanism, based on the spatial importance weight vector; then, it dynamically adjusts the mutual attention between the states of each region at different historical moments through a temporal attention mechanism to obtain the spatiotemporal attention weight; finally, it weights and fuses the spatiotemporal attention weight with the hidden state to generate a context vector with enhanced density information. The decoder is used to input the context vector into the fully connected decoding network to predict the sequence of prediction density vectors for multiple future time steps and further generate a congestion risk heatmap.
[0011] Following the above technical solution, the training process of the spatiotemporal attention prediction model is as follows: training is performed using historical data of scenic spots and corresponding scene probabilities. During training, samples are sampled evenly according to scene categories or different weights are assigned to different scene samples in the loss function. The loss function adopts Huber loss or combines regional density weighted mean square error (MSE) to enable the model to maintain higher prediction accuracy in high-density areas and sudden congestion scenarios.
[0012] This invention also provides a smart early warning system for scenic area congestion, comprising: High-definition camera network, used to deploy high-definition camera networks in scenic areas to capture real-time video streams; The data processing module is used to process video frames and output real-time crowd density maps of each monitored area; it aggregates the data into a regional density sequence containing real-time crowd density values of each area based on the electronic map grid of the scenic area; and it integrates the real-time regional crowd density values into a standard spatiotemporal data matrix according to time and spatial location. The scene modeling module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries; and to identify the current scene based on the regional density sequence of the most recent T time steps according to the multiple scene prototype libraries, and output the current scene probability vector. The predictive model is used to perform scene-adaptive weighting on the spatiotemporal data matrix based on the scene probability vector, predict and output a heat map of congestion risk at multiple future moments; The early warning module and the diversion module are used to determine whether to trigger an early warning based on a congestion risk heat map and a preset risk assessment threshold. If triggered, they combine real-time geographic information and road network data to generate recommended diversion routes using a path planning algorithm, and generate early warning and diversion information. After the early warning is triggered, the module evaluates the effectiveness of the diversion action after the previous early warning based on real-time regional pedestrian density and actual tourist movement data, and adjusts the risk assessment threshold and diversion strategy accordingly.
[0013] Following the above technical solution, the spatiotemporal attention prediction model specifically includes: The underlying encoder, including multiple LSTM or GRU units, is used to independently encode the time series of each region in the real-time crowd density map, capture its own temporal pattern, and output the hidden state. The scene-adaptive weight generation module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries. Based on the multiple scene prototype libraries, it performs scene identification on the regional density sequence of the most recent T time steps, outputs scene probability vectors, selects the weight generation subnetwork corresponding to the scene, generates time weight vectors for the past T time steps, and performs differential weighting on the hidden state sequence. The density-guided attention gating module is used to generate a spatial importance weight vector by passing the current or previous pedestrian density vector through a fully connected layer, where higher initial attention weights are assigned to high-density areas. The spatiotemporal attention fusion module is used to calculate the mutual attention between the states of each region in the current hidden state set through a spatial attention mechanism, based on the spatial importance weight vector; then, it dynamically adjusts the mutual attention between the states of each region at different historical moments through a temporal attention mechanism to obtain the spatiotemporal attention weight; finally, it weights and fuses the spatiotemporal attention weight with the hidden state to generate a context vector with enhanced density information. The decoder is used to input the context vector into the fully connected decoding network to predict the sequence of prediction density vectors for multiple future time steps, and further generate a congestion risk heatmap.
[0014] The beneficial effects of this invention are as follows: This invention acquires and analyzes real-time video streams using high-definition cameras deployed at key locations in scenic areas to obtain real-time pedestrian density maps for each area. This data is then converted into a spatiotemporal data matrix, adaptively focusing on the temporal evolution and spatial propagation patterns of high-density risk areas to generate congestion risk heatmaps for multiple future moments, achieving high-precision congestion prediction for these moments. Based on the prediction results, the system automatically triggers and releases dynamic diversion suggestions through multiple channels. Finally, by evaluating the effectiveness of the diversion actions following the previous warning, the risk assessment threshold and diversion strategy are adjusted accordingly. The core innovation of this invention lies in constructing a complete closed loop of "high-precision perception → scene-adaptive prediction → dynamic execution → effect feedback optimization," which can accurately predict pedestrian density, and the prediction process has self-evolving capabilities.
[0015] Furthermore, a pre-built prediction model is used to predict and output a heatmap of congestion risk at multiple future moments. The prediction model mainly uses a density-guided attention gating mechanism to dynamically adjust the weight of different regions in spatiotemporal attention, which significantly improves the robustness and accuracy of the prediction.
[0016] Of course, any product implementing this invention does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart of the intelligent early warning method for scenic area congestion according to an embodiment of the present invention; Figure 2 This is a flowchart of the scene-adaptive density-guided spatiotemporal prediction model (SA-DA-STALSTM) according to an embodiment of the present invention; Figure 3 This is an overall architecture diagram of the scenic area congestion intelligent early warning system according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the superimposed crowd density in a scenic area according to an embodiment of the present invention; Figure 5 This is a radar diagram illustrating the scene recognition results according to an embodiment of the present invention; Figure 6 This is a schematic diagram of a heat map showing the congestion risk at multiple future times according to an embodiment of the present invention; Figure 7 The self-adaptive time weight of the scenario in the embodiment of the present invention Schematic diagram; Figure 8 This is a schematic diagram comparing time series prediction in embodiments of the present invention; Figure 9 This is a schematic diagram of the loss curve during the model training process in an embodiment of the present invention; Figure 10 This is a schematic diagram comparing the multi-step prediction errors in an embodiment of the present invention; Figure 11 This is a schematic diagram illustrating the R² fitting relationship between the predicted and true values in an embodiment of the present invention. Figure 12 This is a schematic diagram illustrating the generation and guidance of crowd diversion routes in scenic areas according to an embodiment of the present invention; Figure 13 It corresponds Figure 12 The text description. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0020] It should be noted that the illustrations provided in the embodiments of the present invention are only schematic representations of the basic concept of the present invention. Therefore, the illustrations only show the components related to the present invention and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0021] In this invention, it should also be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application. Furthermore, the terms "first" and "second" are used only for descriptive and distinguishing purposes and should not be construed as indicating or implying relative importance.
[0022] Furthermore, it should be noted that the features of the various embodiments of the present invention can be combined or integrated in whole or in part, and as those skilled in the art will understand, they can interact and operate in different ways. Each embodiment can be implemented independently of each other or in association with one another.
[0023] like Figure 1 As shown, the intelligent early warning method for scenic area congestion according to an embodiment of the present invention includes the following steps: S1. Deploy a network of high-definition cameras in the scenic area to collect real-time video streams; S2. Process the video frames, output the real-time crowd density map of each monitored area, and aggregate them into a regional density sequence containing the real-time crowd density values of each area based on the scenic area electronic map grid. S3. Cluster congestion patterns based on historical regional pedestrian density sequences to construct multiple scenario prototype libraries; and perform scenario identification on the regional density sequences of the most recent T time steps based on the multiple scenario prototype libraries, outputting scenario probability vectors. S4. Integrate real-time regional pedestrian density values into a standard spatiotemporal data matrix according to time and spatial location; S5. Based on the scene probability vector, the spatiotemporal data matrix is subjected to scene self-adaptive weighting, and combined with the density-guided spatiotemporal attention prediction model, the congestion risk heat map for multiple future moments is predicted and output. S6. Based on the congestion risk heat map, determine whether to trigger an early warning according to the preset risk assessment threshold; if triggered, combine real-time geographic information and road network, use path planning algorithm to generate recommended diversion routes, and generate early warning and diversion information; S7. After an early warning is triggered, the effectiveness of the diversion action following the previous warning is evaluated based on the real-time regional population density and actual tourist movement data, and the risk assessment threshold and diversion strategy are adjusted accordingly.
[0024] Specifically, in step S1, the high-definition camera network is deployed primarily in key locations within the scenic area, including entrances, popular tourist areas, main roads, bottleneck sections, and intersections. The deployment principle is to ensure no blind spots in key areas, while overlapping coverage is possible for important areas (such as entrances and core attractions). The cameras output RTSP or H.264 / H.265 encoded video streams with a resolution of at least 1920x1080 (1080P) and a frame rate of at least 15fps to accommodate the movement speed of people. The aim is to provide a stable raw visual data source for subsequent analysis of pedestrian flow. The video streams can be transmitted to a central server cluster via dedicated network lines or high-speed wireless networks.
[0025] Further, step S2 specifically includes: performing multi-scale feature extraction and fusion through a pre-built network model, and using a non-local attention module for contextual feature enhancement, ultimately outputting a real-time crowd density map. The value of each pixel in the real-time crowd density map is the probability density of heads at that location, and the integral of the entire image is the estimated number of people in that area of the image.
[0026] Specifically, step S2 mainly completes real-time crowd density perception and geographic mapping. In a preferred embodiment of the present invention, after receiving the video stream, the server can extract image frames I_t at a preset frequency (e.g., 1 frame per second) and send them to a pre-constructed crowd density estimation network. This network can use CSRNet (a dedicated algorithm for head counting based on density map regression) as the backbone, or it can be integrated with an auxiliary density estimation network based on object detection (YOLO series detection networks). Taking CSRNet as an example, the original CSRNet structure includes an encoder (the first 10 layers of VGG-16 convolutions are responsible for feature extraction) and a decoder (4 layers of deconvolution / upsampling are responsible for density map regression). In response to the characteristics of diverse perspectives, severe occlusion, and large scale variations in scenic areas, this invention makes three improvements on the baseline: (1) Backbone network replacement: The backbone encoder is replaced from VGG-16 to ResNet-50, and its residual structure is used to improve feature robustness; (2) Multi-scale fusion: The feature pyramid network (FPN) structure is used to replace the traditional deconvolution decoder. Through top-down path and lateral connection, feature maps from different stages of the encoder are fused, thereby capturing the features of small targets and large-scale crowds at the same time; (3) Context enhancement: A non-local attention module is added to the end of the encoder. Global context modeling is achieved through Q / K / V correlation and Softmax normalization, and features are written back in a residual manner to reduce missed detections and misjudgments caused by occlusion.
[0027] Further, in an optional embodiment, to balance real-time performance, interpretability, and robustness against anomaly detection in sparse flow scenarios, step S2 introduces a density estimation module based on target detection (YOLO series detection network). In one implementation, this detection module can directly serve as the backbone of pedestrian density estimation in step S2: the server performs detection on the extracted image frames to obtain a set of pedestrian candidate boxes and their confidence scores, and maps the detection results to a pixel-level density proxy map through a kernel function; in another implementation, when the system simultaneously deploys a density map regression network, this detection module can also serve as a "sparse scene assistance" branch, adaptively fusing with the density map regression output. Specifically, for each candidate box, its center point and scale are calculated, and the candidate boxes are shrunk to reduce the diffusion error caused by the box being too large; then, a two-dimensional Gaussian kernel is generated with the center point as the kernel, the standard deviation of which is related to the target scale, and a truncated kernel is used to limit its effective support range to obtain a single target density contribution map; all single target contribution maps are weighted and superimposed according to confidence scores to obtain the detection-derived density proxy map. Furthermore, the fusion weights can be adaptively determined based on the scene probability vector output in step S3 or the sparsity criterion of the current frame: when only the detection branch is used, the fused density map is the density proxy map derived from the detection; when both outputs are used simultaneously, the two density maps can be weighted and fused or switched according to the fusion weights. Finally, the fused density map is upsampled according to a predetermined process, and the pixel values are summed to obtain the estimated number of people in the frame. Based on the camera calibration and the scenic area electronic map grid, the pixel-level density is aggregated and mapped into a regional density sequence.
[0028] After the network forward propagation, its last layer outputs a low-resolution density map using a 1×1 convolution. This low-resolution density map is then upsampled using bilinear interpolation to restore it to the same resolution as the preprocessed area of the original image, resulting in the final real-time pedestrian density map. , where each pixel value This represents the probability density of a human head at image location (i,j). The estimated number of people in the image frame can be obtained by summing the pixel values of the entire density map. .like Figure 4The image shown is a schematic diagram of the overlay display of real-time crowd density perception results on a video frame. The system estimates crowd density after extracting frames from the video and overlays the density distribution onto the original image in a thermal format, where color intensity represents density strength, and high-density areas appear as more prominent heat zones. This image is used to display the output effect of the density map from step S2 or the density proxy map obtained by mapping the detection boxes using a kernel function, facilitating managers to quickly locate crowded areas and their spatial extent. To suppress jitter, the estimated number of people in consecutive frames is smoothed using an exponential moving average. Next, a geographic grid mapping of the density values is performed. First, based on the pre-calibrated images of each camera, a mapping relationship is established from image pixel coordinates (u,v) to the scenic area's geographic plane coordinates (X,Y). This relationship can typically be represented by a 3×3 homography matrix H. Simultaneously, N regular geographic grids are pre-divided on the scenic area's electronic map according to management needs. It has its actual ground area (Unit: square meters). For each grid Using homography matrix Project its boundary polygon onto the image The corresponding pixel region is obtained from the above. (A polygonal region can be converted into a pixel mask through rasterization.) Then, the pixel region needs to be calculated. Each pixel The corresponding actual ground area This can be achieved by calculating the homography transformation at the pixel level. The grid is approximated by the absolute value of the determinant of the Jacobian matrix, which represents the area proportion of a tiny pixel region on the image mapped onto the ground. Estimated crowd density at time t (Unit: person / square meter) Calculated using the following formula: Through the above steps, the original video frames are transformed into a set of regional density value sequences that are strictly aligned with geospatial data, providing accurate and consistent input for subsequent spatiotemporal analysis and prediction.
[0029] Further, step S3 specifically involves: historical congestion pattern clustering and online scene identification. First, historical regional density sequence data of the scenic area is collected. A time window length is set. (For example (If the data sampling interval is 1 minute, then there are 30 time steps). By sliding this window along the historical timeline, a large number of sample segments can be captured. Each sample... It can be represented as a two-dimensional matrix Each row represents a time series of a region, and each column represents a snapshot of the entire region at a given moment. For each historical sample... Extract a set of statistical features that can characterize its congestion pattern to form a feature vector. Key features include: (1) Density level features: global average density Peak density of all regions within the window at all time steps (2) Temporal variation characteristics: Calculate the average slope of the rising segment of the average density sequence of the entire panorama within the window. and the variance of the average density sequence. , used to measure volatility. (3) Spatial distribution characteristics: Calculate the spatial Gini coefficient or entropy value at each time point, and then take the average value within the time window to obtain , used to measure whether the flow of people is evenly distributed in space or highly concentrated in a few areas. (4) Persistent characteristics: statistics show that within the window, the average density of the entire area exceeds a certain empirical threshold (e.g. The duration percentage (per person / square meter) was calculated. All extracted features were z-score standardized to eliminate the influence of unit weight. Then, an unsupervised clustering algorithm (such as K-means) was used to analyze the feature vector set. Training is performed, and the number of clusters is set. The algorithm automatically divides the feature space of historical samples into three clusters and obtains the center point of each cluster. The numerical patterns of the feature vectors corresponding to each cluster center point are analyzed: clusters with high peak values, steep upward slopes, but potentially low persistence are labeled as sudden congestion scenarios, typically corresponding to sudden events such as the end of a performance or the arrival of a large number of shuttle buses; clusters with moderate peak values, gentle upward slopes, moderate variance, and high persistence are labeled as normalized congestion scenarios, corresponding to regular congestion such as the daily midday peak; and clusters with both low mean and peak values and small variance are labeled as sparse flow scenarios, corresponding to off-peak hours in scenic areas. This constructs a scenario prototype library containing three scenario prototypes. During real-time online operation, each time the latest T time-step regional density data is acquired, it constitutes the current sample. Following the exact same procedure as with historical data, extract the feature vector of the current sample. Then, calculate. To the three scene prototype centers Euclidean distance The output can be in two ways: one is hard labeling, selecting the scene label corresponding to the prototype with the smallest distance as the output; the better approach is to use soft probability output, converting distance into probability through the Softmax function. ,in The temperature parameter controls the smoothness of the probability distribution. The final output is a three-dimensional scene probability vector. It more flexibly reflects the probability that the current state belongs to various scenarios, providing richer prior information for subsequent prediction models. For example... Figure 5 The image shown is a visualization of the scene probability vector output by the online scene recognition module. Each dimension of the radar chart corresponds to a preset typical pedestrian flow scene type (e.g., sudden congestion, regular congestion, sparse flow, etc.), and the value of each dimension represents the probability weight of belonging to the corresponding scene at the current moment. This image is used to visually display the scene probability vector output in step S3. It also reflects the system's judgment of the current congestion mode, providing a priori basis for subsequent scenario self-adaptive weight generation and prediction strategy switching.
[0030] Further, step S4 specifically involves: at fixed time intervals, arranging the density values obtained from all N regions at the current time in the order of regions to form a multidimensional feature vector; continuously collecting the multidimensional feature vectors of the past T time steps and stacking them in chronological order to form a T·N spatiotemporal data matrix.
[0031] Step S5 specifically involves: predicting and outputting a heatmap of congestion risk at multiple future time points using a pre-built prediction model. This prediction model specifically includes: The underlying encoder, consisting of multiple layers of LSTM or GRU units, is used to encode the historical density sequence of each region, capture its own temporal pattern, and output the hidden state. The scene-adaptive weight generation module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries. Based on the multiple scene prototype libraries, it performs scene identification on the regional density sequence of the most recent T time steps, outputs scene probability vectors, selects the weight generation subnetwork corresponding to the scene, generates time weight vectors for the past T time steps, and performs differential weighting on the hidden state sequence. The density-guided attention gating module is used to generate a spatial importance weight vector by passing the current or previous pedestrian density vector through a fully connected layer, where higher initial attention weights are assigned to high-density areas. The spatiotemporal attention calculation module is used to calculate the mutual attention between the states of each region in the current hidden state set based on the spatial importance weight vector and through the spatial attention mechanism. Then, it dynamically adjusts the mutual attention between the states of each region at different historical moments through the temporal attention mechanism to obtain the spatiotemporal attention weight. Finally, the spatiotemporal attention weight is weighted and fused with the hidden state to generate a context vector with enhanced density information. The decoder takes the context vector as input to the fully connected decoding network, predicts the sequence of predicted density vectors for multiple future time steps, and further generates a congestion risk heatmap. For example... Figure 6 The image shows a heatmap of congestion risk at multiple future points in time. This heatmap displays the predicted density / risk level using spatial regions (e.g., grids R01–R12). It can be expanded into multiple columns or frames over time steps to reflect the spatial distribution evolution at different future points in time. High-risk areas can be highlighted using color or numerical labels, providing a basis for threshold determination, diversion strategy generation, and information dissemination, corresponding to the prediction output of step S5.
[0032] The steps S4 and S5 above together complete the construction of spatiotemporal data of pedestrian flow and congestion prediction. The core purpose is to organize discrete spatiotemporal density data into a continuous sequence and use innovative prediction models to explore its inherent patterns and accurately predict changes in pedestrian density in various regions over a period of time.
[0033] In a preferred embodiment of the present invention, such as Figure 2 As shown, the main steps to construct spatiotemporal data of pedestrian flow and predict congestion are as follows: 1. Spatiotemporal data cube construction: Operation: The system maintains a global spatiotemporal data buffer. Every fixed time interval Δt (e.g., 10 seconds), the current time is retrieved from all regions. The obtained density value Aggregate into N-dimensional feature vectors Where N is the number of geographic grids. Feature vectors from the past T time steps are continuously collected and stacked in chronological order to form a spatiotemporal data cube. Its dimensions are T×N×C (C=1 in this invention). Figure 2 middle" (To simplify the representation by ignoring the C dimension, the spatiotemporal data cube is consistently represented by S throughout the text.) Objective: To standardize multi-location, long-term data series into a tensor format that the model can process. Rows in the matrix represent temporal evolution, and columns represent spatial distribution.
[0034] 2. Scene-Adaptive Density-Guided Spatiotemporal Prediction Model (SA-DA-STALSTM) (1) Model input: spatiotemporal data matrix St and scene probability vector Pt.
[0035] (2) Model structure: ① Low-level encoder: Multi-layer GRU units are used to encode the time series of each region r, capture its temporal pattern, and output the hidden state matrix H. (a) H is the hidden state matrix, H∈R^(N×256), where N is the number of regions and 256 is the feature dimension; (b) h_r is the hidden state vector of a single region, h_r∈R^256, and H[r,:]=h_r.
[0036] ②Scene-Adaptive Weight Generation Module: This module contains three parallel weight generation sub-networks, corresponding to three scenarios: sudden congestion, normalized congestion, and sparse flow. Each sub-network is a multilayer perceptron (MLP), whose inputs are the statistical summary features of the current time window (such as global average density, peak value, and slope of change) and the scenario probability vector. Each expert network outputs an original weight score vector of length T, which is then normalized using Softmax to obtain the corresponding scene's temporal attention weight vector. Next, based on the current scene probability vector... =[ , , The three weight vectors are weighted and fused to obtain the final time weight vector: Through training, the three expert networks learned different attention patterns: the expert in sudden scenarios focused on recent time steps, the expert in normal scenarios had a more even weight distribution, and the expert in sparse scenarios suppressed noise and focused on the overall trend. For example... Figure 7 As shown, this is the scene self-adaptation time weight vector. The diagram illustrates this. The horizontal axis represents historical time steps, and the vertical axis represents weight magnitude. The distribution across historical moments reflects the difference in the model's focus on "recent changes" and "long-term trends"; if necessary, a cumulative weight curve can also be provided to illustrate which time ranges the main attention is concentrated on. This figure is used to explain the formation mechanism of temporal attention in step S5 and its relationship with scene priors.
[0037] ③ Density-guided attention gating module: This module introduces spatial prior knowledge. It takes the panoramic density vector V from the previous (or current) time step. t 1. A spatial importance weight vector β is generated by mapping through a fully connected layer and a sigmoid activation function. t This operation assigns higher weights to high-density areas, thus guiding the model to focus more on already congested or easily congested areas in subsequent calculations.
[0038] ④ Spatiotemporal attention fusion module: Spatial attention: Based on the spatial importance weight α_s, the feature vectors of each region in the hidden state matrix H are weighted and fused, and the attention between regions is calculated, thereby strengthening the influence of high-density regions on surrounding regions. Figure 2 (Edited) Temporal attention: The model's attention to the sequence of historical hidden state matrices. The model performs weighted aggregation and dynamically adjusts the level of attention given to different historical moments based on the current density weight α_s. For current high-density areas, the model pays more attention to their recent historical changes to improve the predictive sensitivity for short-term congestion outbreaks.
[0039] ⑤ Decoder and Output Layer: The context vector Ct is input into the fully connected decoding network, and the output is a sequence of predicted density vectors for the next P time steps. Each of them Let be an N-dimensional vector, and let its r-th dimension be denoted as . , representing the prediction density of region r at the p-th future time step. In implementation, two output branches can be set, one for the next 15 minutes and the other for 30 minutes.
[0040] (3) Training: The model is trained under supervision using historical data of the scenic area (spatiotemporal matrix, scene labels, and future true density). The loss function is mean squared error (MSE), and higher loss weights can be applied to high-density areas and different scenarios (such as sudden congestion) to force the model to improve the prediction accuracy of key areas. The Adam optimizer is used in the training process, and an early stopping strategy is applied to prevent overfitting.
[0041] In one optional embodiment, to verify the training stability and multi-step prediction effect of the prediction model described in this invention, historical data of the scenic area are used to train and evaluate the model. For example... Figure 8 The figure shows a time series comparison diagram of the multi-step prediction of scenic area crowd congestion indicators according to the present invention. The figure plots the actual observation curve and the model prediction curve with time as the horizontal axis and the target indicator value as the vertical axis. By comparing the consistency of the two curves in terms of peak occurrence time, peak amplitude, rising / falling slope, and inflection point position, the model's ability to track "trend changes and sudden increases / decreases" can be intuitively reflected, and it can be used to verify whether the prediction output meets the requirements of early warning lead time; for example... Figure 9 The figure shows a schematic diagram of the loss curves during model training. It illustrates the training and validation loss curves as the training epochs change, and marks the optimal epoch for the validation set or early stopping points to reflect the model's convergence and generalization trend. This figure is used to explain the stability and rationality of the prediction model training and provides a basis for model parameter selection and deployment; and as shown... Figure 10 The figure shows a comparison of errors in multi-step prediction under different prediction step sizes / prediction time intervals. The figure illustrates the changes in indicators such as MAE and MAPE as the prediction time interval increases, reflecting the error evolution patterns of short-term and long-term predictions. This figure is used to verify the model's performance in multi-timescale prediction tasks and provides a reference for selecting appropriate early warning lead times for the system; for example... Figure 11The diagram shows the scatter plot of the predicted and actual values. The scatter plot is drawn with the actual values on the horizontal axis and the predicted values on the vertical axis, and a reference line (e.g., a consistency reference for y=x) and the fitted regression line can be provided. The closer the scatter points are to the reference line, the more accurate the prediction and the smaller the systematic bias. Furthermore, statistical measures such as R² can be used to quantify the degree of fit, assessing the overall consistency of the model, whether there is systematic overestimation or underestimation, and the error distribution characteristics across different numerical intervals.
[0042] (4) The innovation of the SA-DA-STALSTM model lies in the fact that it does not uniformly model all traffic flow patterns. Instead, it first identifies the typical congestion scenario of the current state through a scenario-adaptive weight generation module, and then dynamically calls the time attention mode optimized for that scenario. Combined with density-guided spatial attention, it achieves "focusing on the correct spatial area at the correct time scale". This dual guidance mechanism, based on semantics (scenario) and numerical values (density), makes it more accurate and robust than traditional models in the complex and ever-changing environment of scenic spots. Therefore, this innovative model can be named SA-DA-STALSTM.
[0043] Step S6 primarily involves congestion risk assessment, threshold determination, and diversion strategy generation. The goal is to translate the predicted mathematical results into executable and understandable control instructions that reach tourists. Specifically: 1. Congestion risk assessment and threshold determination Operation: The system presets a base congestion density threshold Th_{base} for each area (e.g., 2.0 people / ㎡ in the core area, 1.5 people / ㎡ in the corridor). When _{t+p,r}( When the predicted density of region r at the p-th future time step in _{t+1:t+P} > Th_{base}, mark that region at time step as a risk point.
[0044] Dynamic threshold adjustment: Δ is an offset that is dynamically adjusted by the optimization layer to adapt to differences in tourist behavior under different seasons and activities.
[0045] 2. Generation of traffic splitting strategy Operation: For identified risk points, the system uses the risk area boundary as the starting point and the non-congested area as the ending point, and runs a multi-objective weighted Dijkstra algorithm on the scenic area's GIS road network map to generate candidate diversion paths. Compared with traditional shortest path algorithms that only consider distance, this invention introduces factors such as predicted congestion and scenic spot value to achieve multi-objective diversion such as "shortest time / most comfortable / considering scenic spot value".
[0046] Innovative Cost Function: The cost of route planning adopts a multi-objective weighted sum: Cost = w1·Distance + w2·Predicted_Congestion + w3·Scenic_Value. Where Distance is the total route length (meters), Predicted_Congestion is the average predicted density of the route, and Scenic_Value is the sum of the scenic spot ratings along the route (e.g., rated from 1 to 5). The weights satisfy w1 + w2 + w3 = 1, and the preferred value ranges are w1 ∈ [0.3, 0.5], w2 ∈ [0.3, 0.4], and w3 ∈ [0.2, 0.3], and are adjusted online by Q-Learning in the optimization layer.
[0047] Candidate route selection: Starting from the boundary of the congested area and ending in a non-congested area, the candidate route with the lowest cost is selected based on the aforementioned cost function. Route type classification: Three types of recommended routes are generated by adjusting (w1, w2, w3), such as: fastest exit (w1=0.5, w2=0.4, w3=0.1), most comfortable detour (w1=0.3, w2=0.3, w3=0.4), and route passing through suboptimal attractions (w1=0.3, w2=0.2, w3=0.5). If a candidate route crosses a potentially congested area, constraints can be imposed on the nodes in that area, and the route can be replanned. Figure 12 , 13 The diagram shown illustrates the generation and guidance of diversion routes. Predicted risk areas are marked on a grid area of the scenic area map, and the system-generated recommended diversion paths and guidance directions are provided. A visual information panel can be created by combining information such as risk level, scene type, threshold judgment results, and the availability of guideable areas. This diagram demonstrates the output of step S6, "Risk Identification—Route Planning—Information Dissemination," enabling managers and tourists to intuitively understand the diversion strategy and recommended routes.
[0048] 3. Information dissemination through multiple channels Operation: Package the warning information (risk area, estimated congestion time) and diversion suggestions (recommended route, navigation).
[0049] Push notifications to the scenic area's official app / mini-program: Send real-time pop-up alerts to tourists located near or traveling to the risk area.
[0050] Update the on-site electronic navigation screens: Highlight congested areas and recommended flow direction arrows on the large screens at relevant intersections.
[0051] Trigger voice broadcast: Repeated voice reminders will be broadcast from audio equipment near the risk area.
[0052] Objective: To achieve graded, categorized, and precise delivery of early warning information, guiding tourists to avoid congestion on their own.
[0053] Step S6 primarily involves feedback learning and strategy optimization. Its core objective is to automatically adjust model and strategy parameters using the "prediction-actual" bias generated during system operation and tourist behavior feedback data, making the system increasingly intelligent with use. Specifically, it includes the following steps: 1. Feedback Data Collection Operation: Continuously monitor two key signals: Prediction accuracy: compared to prediction density _{t,r} and the actual observed density Y_{t,r}.
[0054] Diversion compliance rate and effectiveness: By analyzing tourist movement trajectories (the overall flow of people can be indirectly inferred from continuous video), we estimate how many tourists followed the diversion recommendations, and whether the congestion in the target risk area was alleviated as expected after diversion, or whether it caused congestion in new areas.
[0055] 2. Multi-objective reinforcement learning optimization (1) Operation: The entire early warning and diversion system is regarded as an agent. Its state is the current spatiotemporal data cube S, its action is the issued early warning and diversion strategy, and its reward is determined by multiple objectives.
[0056] (2) Design of innovation reward function: R = β1 × (Improved prediction accuracy) + β2 × (Compliance rate with diversion suggestions) + β3 × (Decrease in congestion in high-risk areas) - β4 × (Penalty for newly generated congested areas) - β5 × (Penalty for excessive warnings) Where β1-β5 are the tradeoff coefficients. The terms in parentheses have the following meaning: Improvement in prediction accuracy = Current prediction accuracy Previous prediction accuracy; Diversion compliance rate = Number of tourists following diversion / Target number of tourists; Risk area congestion reduction rate = (Density before diversion) (Density after diversion) / Density before diversion; Penalty for newly generated congested areas = weighted penalty for the number of newly added congested areas; Penalty for excessive warnings = weighted penalty for unnecessary warnings.
[0057] (3) Optimization process: The system executes a complete "prediction-triage" action. After a period of time, feedback data is collected and the reward R obtained for this action is calculated. The Q-Learning algorithm is used to update the strategy. , where S is the current state of the spatiotemporal data cube, a is the warning / diversion action, S' is the new state after execution, η is the learning rate, and γ is the discount factor.
[0058] Based on the optimal action obtained from Q-Learning, the dynamic threshold Δ and the path cost function weights {w1,w2,w3} are adjusted online to achieve adaptive optimization of early warning sensitivity and diversion strategy.
[0059] (4) Objective: Through continuous trial and error and learning, the system will automatically find the optimal early warning sensitivity and diversion strategy that is most suitable for the scenic area, and achieve a leap from "rule-based" to "data-driven optimization", forming a true closed-loop intelligence.
[0060] In summary, the above-described specific method embodiments have the following advantages: 1. A precise crowd perception scheme based on improved density regression: This scheme abandons the general multi-target detection framework and adopts a head counting algorithm specifically designed for dense scenes as the core of perception. By optimizing the density map regression network and introducing a multi-scale context fusion module for scenic areas, it achieves stable and accurate estimation of the position and number of heads under different degrees of occlusion, providing a high-quality density map data foundation for subsequent predictions.
[0061] 2. Scene-Adaptive Density-Guided Spatiotemporal Prediction Model (SA-DA-STALSTM): This proposes an innovative spatiotemporal prediction model architecture. Building upon the traditional spatiotemporal attention LSTM, it introduces historical congestion pattern clustering and online scene recognition, and constructs a scene-adaptive weight generation module. This module dynamically generates differentiated temporal attention weights based on the identified three scene categories: "sudden congestion," "normal congestion," and "sparse flow." Combined with a density-guided spatial attention mechanism, the model can adaptively focus on the spatiotemporal evolution patterns of high-density areas under different scenes, achieving accurate and robust prediction of complex and ever-changing pedestrian flow patterns in scenic areas.
[0062] 3. "Prediction-Diversion-Feedback" Closed-Loop Optimization Mechanism: This mechanism integrates congestion prediction, diversion decisions, and effect evaluation into a unified framework. The system not only triggers diversion based on prediction results but also collects data on actual tourist movement trajectories and congestion mitigation. Utilizing multi-objective reinforcement learning algorithms, it optimizes the output threshold of the prediction model and the cost function weights of the diversion paths online, forming a continuously self-improving closed-loop control system that enhances the system's adaptability and effectiveness in long-term applications.
[0063] To implement the above method embodiments, the present invention also provides a scenic area congestion intelligent early warning system, comprising: High-definition camera network, used to deploy high-definition camera networks in scenic areas to capture real-time video streams; The data processing module is used to process video frames and output real-time crowd density maps of each monitored area; it aggregates the data into a regional density sequence containing real-time crowd density values of each area based on the electronic map grid of the scenic area; and it integrates the real-time regional crowd density values into a standard spatiotemporal data matrix according to time and spatial location. The scene modeling module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries; and to identify scenes based on the regional density sequences of the most recent T time steps according to the multiple scene prototype libraries, and output scene probability vectors. The predictive model is used to perform scene-adaptive weighting on the spatiotemporal data matrix based on the scene probability vector, predict and output a heat map of congestion risk at multiple future moments; The early warning and diversion module is used to determine whether to trigger an early warning based on a congestion risk heat map and a preset risk assessment threshold. If triggered, it combines real-time geographic information and road network data with a path planning algorithm to generate recommended diversion routes and generate early warning and diversion information. After the early warning is triggered, it evaluates the effectiveness of the diversion action after the previous warning based on real-time regional pedestrian density and actual tourist movement data, and adjusts the risk assessment threshold and diversion strategy accordingly.
[0064] Following the above technical solution, the prediction model specifically includes: The underlying encoder, including multiple LSTM or GRU units, is used to independently encode the time series of each region in the real-time crowd density map, capture its own temporal pattern, and output the hidden state. The scene-adaptive weight generation module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries. Based on the multiple scene prototype libraries, it performs scene identification on the regional density sequence of the most recent T time steps, outputs scene probability vectors, selects the weight generation subnetwork corresponding to the scene, generates time weight vectors for the past T time steps, and performs differential weighting on the hidden state sequence. The density-guided attention gating module is used to generate a spatial importance weight vector by passing the current or previous pedestrian density vector through a fully connected layer, where higher initial attention weights are assigned to high-density areas. The spatiotemporal attention fusion module is used to calculate the mutual attention between the states of each region in the current hidden state set through a spatial attention mechanism, based on the spatial importance weight vector; then, it dynamically adjusts the mutual attention between the states of each region at different historical moments through a temporal attention mechanism to obtain the spatiotemporal attention weight; finally, it weights and fuses the spatiotemporal attention weight with the hidden state to generate a context vector with enhanced density information. The decoder is used to input the context vector into the fully connected decoding network to predict the sequence of prediction density vectors for multiple future time steps and further generate a congestion risk heatmap.
[0065] The overall implementation framework of the system is as follows: Figure 3As shown, the system of this invention adopts a layered, closed-loop architecture design. Its core idea is to use high-quality video stream data as the sole input, perform in-depth processing and decision-making through interconnected intelligent modules, and utilize execution feedback to drive the system's self-evolution. The overall architecture comprises four logical layers: a perception layer, an intelligent analysis layer, a decision execution layer, and an optimization layer.
[0066] Specifically: Perception layer: Deploy a network of high-definition cameras in the scenic area to collect real-time video streams.
[0067] Analysis Layer: First, the pedestrian density estimation module performs pedestrian perception on video frames, generating real-time pedestrian density maps for each area and mapping them to geographic gridded density values. The pedestrian density estimation module can be a density map regression network and a target detection derived density proxy map module to balance accuracy and real-time performance in both dense occlusion and sparse flow scenarios. Then, cluster analysis is performed based on historical density sequences to identify online whether the current pedestrian flow state belongs to "sudden congestion," "normal congestion," or "sparse flow," and outputs a scenario probability vector. Finally, the real-time grid density sequence and scenario probabilities are input into the scene-adaptive density-guided spatiotemporal prediction model (SA-DA-STALSTM). This model uses a scene-adaptive weight generation module to differentially weight historical time steps and combines a density-guided spatiotemporal attention mechanism to output a congestion risk heatmap for the next 15-30 minutes.
[0068] Decision Execution Layer: Receives the predicted heatmap. The risk assessment module determines whether an early warning is triggered based on dynamically adjusted thresholds. If triggered, the diversion strategy generator combines a Geographic Information System (GIS) with real-time road network conditions, employing a multi-objective path planning algorithm that incorporates predicted congestion levels to generate multiple suggested diversion routes. The information dissemination module then disseminates early warning information and diversion guidance to tourists in the affected area through the scenic area's official app, electronic guide screens, and broadcast systems.
[0069] Optimization Layer: The feedback data collection module continuously analyzes the actual movement trajectory of tourists from the video stream and compares it with the prediction results and diversion instructions to obtain performance indicators such as prediction deviation, diversion compliance rate, and congestion relief degree. Based on this feedback data, the strategy optimizer uses a multi-objective reinforcement learning algorithm to dynamically adjust key parameters such as warning threshold and diversion path cost weight, and applies the optimized parameters to the next round of analysis and decision-making process, thereby achieving adaptive improvement of the overall system performance.
[0070] The entire system realizes the following in the method embodiment: raw video → density map → scene recognition → spatiotemporal data → risk prediction → diversion decision → information dissemination → tourist behavior → feedback data → model and strategy optimization → influencing the next round of prediction and decision-making.
[0071] The specific implementation processes of the perception layer, intelligent analysis layer, decision execution layer, and optimization layer can be referred to the steps of the above method embodiment, and will not be elaborated here.
[0072] In summary, this invention proposes a closed-loop early warning and diversion system that integrates scene cognition. It acquires real-time video streams using high-definition cameras deployed at key locations in scenic areas. First, an improved density map regression network is used to accurately obtain the real-time pedestrian density in each area and map it to geographic grid density values. Then, historical congestion pattern clustering and online scene recognition are introduced to classify pedestrian flow into three scenarios: "sudden congestion, normalized congestion, and sparse flow." Based on this, the density sequence is input into the innovative scene-adaptive density-guided spatiotemporal prediction model (SA-DA-STALSTM). This model uses a scene-adaptive weight generation module to differentially weight historical time steps and combines a density-guided attention mechanism to adaptively focus on the spatiotemporal evolution patterns of high-risk areas under different scenarios, thereby achieving high-precision congestion prediction for the next 15-30 minutes. Finally, based on the prediction results, the system automatically triggers and releases dynamic diversion suggestions through multiple channels. The core innovation of this system lies in constructing a complete intelligent closed loop of "high-precision perception → scene pattern recognition → scene adaptive prediction → dynamic diversion → feedback optimization." The SA-DA-STALSTM model, through a combination of scenario-driven differentiated temporal weight generation and density spatial gating, significantly improves the prediction accuracy and robustness under different congestion patterns. Simultaneously, the system introduces a reinforcement learning-based multi-objective policy optimizer to continuously fine-tune the warning threshold and diversion strategy parameters based on historical feedback of diversion effects, enabling the system to continuously self-evolve. This invention effectively solves the problems of imprecise perception, mismatch between prediction and scenario, and rigid response strategies in existing technologies, achieving scenario-based, refined, and intelligent management of tourist flow in scenic areas.
[0073] This application also provides a computer-readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, App application store, etc., which stores a computer program, and the program implements the corresponding function when executed by a processor. In this embodiment, the computer-readable storage medium, when executed by a processor, implements the scenic area congestion intelligent early warning method of the method embodiment.
[0074] It should be noted that, depending on the implementation needs, the various steps / components described in this application can be broken down into more steps / components, or two or more steps / components or parts of the operation of steps / components can be combined into new steps / components to achieve the purpose of this invention.
[0075] The order of the steps in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0076] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A method for intelligent early warning of traffic congestion in scenic areas, characterized in that, Includes the following steps: S1. Deploy a network of high-definition cameras in the scenic area to collect real-time video streams; S2. Process the video frames, output the real-time crowd density map of each monitored area, and aggregate them into a regional density sequence containing the real-time crowd density values of each area based on the scenic area electronic map grid. S3. Cluster congestion patterns based on historical regional pedestrian density sequences to construct multiple scenario prototype libraries; and perform scenario identification on the regional density sequences of the most recent T time steps based on the multiple scenario prototype libraries, outputting scenario probability vectors. S4. Integrate real-time regional pedestrian density values into a standard spatiotemporal data matrix according to time and spatial location; S5. Based on the scene probability vector, the spatiotemporal data matrix is subjected to scene self-adaptive weighting, and combined with the density-guided spatiotemporal attention prediction model, the congestion risk heat map for multiple future moments is predicted and output. S6. Based on the congestion risk heat map, determine whether to trigger an early warning according to the preset risk assessment threshold; If triggered, the system combines real-time geographic information and road network data, uses path planning algorithms to generate recommended diversion routes, and generates warnings and diversion information. S7. After an early warning is triggered, the effectiveness of the diversion action following the previous warning is evaluated based on the real-time regional population density and actual tourist movement data, and the risk assessment threshold and diversion strategy are adjusted accordingly.
2. The intelligent early warning method for scenic area congestion according to claim 1, characterized in that, High-definition camera networks are deployed in key locations within the scenic area, including entrances, popular tourist areas, main roads, bottleneck sections, and intersections.
3. The intelligent early warning method for scenic area congestion according to claim 1, characterized in that, Step S2 specifically includes: extracting and fusing multi-scale features from video frames using a pre-constructed crowd density estimation network, and enhancing features using a contextual feature enhancement module to output a real-time crowd density map; wherein, the real-time crowd density map can be directly output by a density map regression network, or output by a density proxy map generated by mapping pedestrian head candidate boxes obtained by an object detection network through a kernel function, and the value of each pixel in the real-time crowd density map is the probability density or density contribution of the crowd at that location, and the integral of the entire map is the estimated number of people in the image area; and according to the camera calibration parameters and the predefined scenic area electronic map area grid, the pixel-level density values of the real-time crowd density map are aggregated and calculated onto each grid to obtain the real-time regional crowd density value of each grid.
4. The intelligent early warning method for scenic area congestion according to claim 1, characterized in that, Step S3 further includes: based on the historical population density sequence of the scenic area, historical samples are truncated with a fixed window length L, and the mean density, peak density, rate of change, and spatial concentration of each sample are extracted as temporal feature vectors; the historical samples are divided into three types of congestion scenarios—sudden congestion, normal congestion, and sparse flow—using K-means or Gaussian mixture model clustering algorithms, and feature prototype centers for each type of scenario are obtained; during online operation, the most recent Extract the same features from the region density sequence at each time step, calculate the distance or posterior probability to the center of each scene prototype, and output the scene label or a three-dimensional scene probability vector.
5. The intelligent early warning method for scenic area congestion according to claim 1, characterized in that, Step S4 is as follows: at fixed time intervals, the density values obtained from all N regions at the current time are arranged in the order of regions to form a multidimensional feature vector. The multidimensional feature vectors of the past T time steps are continuously collected and stacked in chronological order to form a T·N spatiotemporal data matrix.
6. The intelligent early warning method for scenic area congestion according to claim 1, characterized in that, Step S5 specifically involves: using a pre-built scene-adaptive density-guided spatiotemporal prediction model to predict and output a heatmap of congestion risk at multiple future moments. This prediction model specifically includes: The underlying encoder, including multiple LSTM or GRU units, is used to independently encode the time series of each region in the real-time crowd density map, capture its own temporal pattern, and output the hidden state. The scene-adaptive weight generation module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries. Based on the multiple scene prototype libraries, it performs scene identification on the regional density sequence of the most recent T time steps, outputs scene probability vectors, selects the weight generation subnetwork corresponding to the scene, generates time weight vectors for the past T time steps, and performs differential weighting on the hidden state sequence. The density-guided attention gating module is used to generate a spatial importance weight vector by passing the current or previous pedestrian density vector through a fully connected layer, where higher initial attention weights are assigned to high-density areas. The spatiotemporal attention fusion module is used to calculate the mutual attention between the states of each region in the current hidden state set through a spatial attention mechanism, based on the spatial importance weight vector; then, it dynamically adjusts the mutual attention between the states of each region at different historical moments through a temporal attention mechanism to obtain the spatiotemporal attention weight; finally, it weights and fuses the spatiotemporal attention weight with the hidden state to generate a context vector with enhanced density information. The decoder is used to input the context vector into the fully connected decoding network to predict the sequence of prediction density vectors for multiple future time steps, and further generate a congestion risk heatmap.
7. The intelligent early warning method for scenic area congestion according to claim 6, characterized in that, The scenario-adaptive weight generation module includes three parallel weight generation subnetworks, corresponding to three scenarios: sudden congestion, normalized congestion, and sparse flow, respectively. Each subnetwork is a multilayer perceptron, taking the statistical features or scenario probability of the current time window as input and outputting a weight generation value of length [missing information]. The initial weight score vector is normalized by Softmax to obtain the time weight vector for this scenario; the final fused time weight vector is obtained by weighting the time weight vectors of the three scenarios according to their scenario probabilities; among them, the subnetwork of the sudden congestion scenario is trained to make its output weight biased towards the recent time step, the subnetwork of the normal congestion scenario has a relatively flat output weight distribution, and the subnetwork of the sparse flow scenario is used to suppress temporal fluctuations.
8. The intelligent early warning method for scenic area congestion according to claim 1, characterized in that, The training process of the spatiotemporal attention prediction model is as follows: historical data of scenic spots and corresponding scene probabilities are used for training. During training, samples are sampled equally according to scene categories or different weights are assigned to different scene samples in the loss function. The loss function adopts Huber loss or combines regional density weighted mean square error (MSE) to enable the model to maintain higher prediction accuracy in high-density areas and sudden congestion scenarios.
9. A smart early warning system for scenic area congestion, characterized in that, include: High-definition camera network, used to deploy high-definition camera networks in scenic areas to capture real-time video streams; The data processing module is used to process video frames and output real-time crowd density maps of each monitored area. Based on the scenic area's electronic map grid, it aggregates the data into a regional density sequence containing real-time crowd density values for each area. The module also integrates the real-time regional crowd density values into a standard spatiotemporal data matrix according to time and spatial location. The scene modeling module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries. Based on multiple scene prototype libraries, scene recognition is performed on the region density sequence of the most recent T time steps, and scene probability vectors are output. The predictive model is used to perform scene-adaptive weighting on the spatiotemporal data matrix based on the scene probability vector, predict and output a heat map of congestion risk at multiple future moments; The early warning and diversion module is used to determine whether to trigger an early warning based on a congestion risk heat map and a preset risk assessment threshold. If triggered, the system combines real-time geographic information and road network data, uses path planning algorithms to generate recommended diversion routes, and generates warnings and diversion information. After the warning is triggered, the system evaluates the effectiveness of the diversion action after the previous warning based on real-time regional pedestrian density and actual tourist movement data, and adjusts the risk assessment threshold and diversion strategy accordingly.
10. The intelligent early warning system for scenic area congestion according to claim 9, characterized in that, This spatiotemporal attention prediction model specifically includes: The underlying encoder, including multiple LSTM or GRU units, is used to independently encode the time series of each region in the real-time crowd density map, capture its own temporal pattern, and output the hidden state. The scene-adaptive weight generation module is used to cluster congestion patterns based on historical regional pedestrian density sequences and build multiple scene prototype libraries. Based on the multiple scene prototype libraries, it performs scene identification on the regional density sequence of the most recent T time steps, outputs scene probability vectors, selects the weight generation subnetwork corresponding to the scene, generates time weight vectors for the past T time steps, and performs differential weighting on the hidden state sequence. The density-guided attention gating module is used to generate a spatial importance weight vector by passing the current or previous pedestrian density vector through a fully connected layer, where higher initial attention weights are assigned to high-density areas. The spatiotemporal attention fusion module is used to calculate the mutual attention between the states of each region in the current hidden state set through a spatial attention mechanism, based on the spatial importance weight vector; then, it dynamically adjusts the mutual attention between the states of each region at different historical moments through a temporal attention mechanism to obtain the spatiotemporal attention weight; finally, it weights and fuses the spatiotemporal attention weight with the hidden state to generate a context vector with enhanced density information. The decoder is used to input the context vector into the fully connected decoding network to predict the sequence of prediction density vectors for multiple future time steps and further generate a congestion risk heatmap.