Pedestrian flow density and flow prediction system and method based on convolutional neural network
Through the sequence-to-sequence architecture model based on the convolutional neural network, combined with the multi-layer perceptron and the Voronoi diagram method, the existing technology solves the problems of high computing resource consumption and neglect of individual behavioral diversity, and achieves the optimization of pedestrian flow density and flow. Real-time and accurate prediction improves the real-time and preventive capabilities of traffic management.
Patent Information
- Application Number
- CN202410810113.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-06-21
AI Technical Summary
Existing pedestrian flow density and traffic prediction methods consume large amounts of computing resources when processing large-scale complex scenes, and are difficult to accurately capture global traffic dynamics. Moreover, methods based on historical data ignore the diversity of individual behaviors and cannot effectively predict emergencies.
A sequence-to-sequence architecture model based on convolutional neural networks is used to predict pedestrian trajectories and traffic in real time through coordinate transformation, sampling, trajectory embedding, encoding, decoding and density flow calculation modules, combined with multi-layer perceptron and Voronoi diagram methods.
It realizes real-time monitoring and early warning, dynamic traffic management, improves prediction efficiency and accuracy, can quickly respond to traffic management needs, and improves the real-time nature of traffic management and accident prevention capabilities.
Smart Images

Figure CN118397842B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent transportation technology, and in particular to a pedestrian flow density and flow prediction system and method based on convolutional neural network. Background Art
[0002] As the global urbanization process continues to accelerate, the scale and complexity of urban transportation networks are increasing. As an important part of the urban transportation system, the safety and efficiency of pedestrian traffic are directly related to the overall operation of urban traffic. With the increase in urban population density, pedestrian traffic flow has also shown a rapid growth trend, and crowded stampede accidents occur frequently. Therefore, accurate prediction of pedestrian flow density and flow has become an important topic in the field of pedestrian traffic research. The prediction of pedestrian flow density and flow not only helps to identify potential traffic conflicts and safety hazards in advance, so as to take effective measures to prevent and intervene, but also provides key data support for the design and optimization of intelligent transportation systems. It can predict the flow of pedestrians in key areas to reduce overcrowding and prevent stampede accidents. It helps to prevent dangerous incidents before the incident escalates, and provides real-time situational awareness for security personnel, allowing security personnel to make real-time adjustments to optimize pedestrian flow and safety, and help guide evacuation work in emergency situations.
[0003] Social force model and cellular automaton model are two traditional knowledge-driven methods for simulating and predicting pedestrian mobility. The social force model predicts the movement behavior of pedestrians in a certain social environment by simulating the interaction forces between individual pedestrians, which is similar to the forces between particles in physics. This model can simulate pedestrian avoidance behavior, goal pursuit behavior and other social behaviors to a certain extent, and is often used to describe and predict the movement of pedestrians in crowded environments. The cellular automaton model divides the space into discrete grids, each of which represents a cell. Each cell interacts with its neighbors according to a set of simple rules, resulting in complex patterns. In pedestrian flow models, this method is often used to simulate the movement and interaction of pedestrians, as well as their reactions to the surrounding environment.
[0004] At present, some deep learning methods are also used in the field of pedestrian dynamics, but for pedestrian flow density and flow, these methods are mostly used to detect the flow and density at the current time, rather than predicting the situation in the future. Most of the methods that use deep learning to predict pedestrian density and flow are based on historical flow data as training samples for prediction, rather than based on the historical positions of pedestrians.
[0005] Traditional knowledge-driven pedestrian density and flow prediction methods, such as those based on social force models and cellular automata models, can provide reasonable predictions in some scenarios, but they also have some limitations. Social force models focus on simulating individual behaviors and interactions, and simulate the movement of pedestrians in social environments through mechanical principles. However, this method often requires a lot of computing resources when dealing with large-scale complex scenarios, and it is difficult to accurately capture the global flow dynamics in complex traffic networks. Similarly, although the cellular automata model simulates pedestrian flow in discrete time and space, simplifying the calculation process, the model shows its inherent limitations when dealing with behaviors in continuous space. It usually assumes that pedestrians move uniformly and regularly, which ignores the diversity and randomness of pedestrian behavior in the real world. In addition, these models are difficult to adapt to environmental changes, such as flow changes and temporary events in different time periods, which may lead to insufficient prediction accuracy.
[0006] Existing deep learning-based methods do use historical pedestrian flow data as training samples to directly train models to predict future pedestrian density and flow. Although this method can provide useful predictions to a certain extent, it usually faces limitations such as large changes in data distribution, real-time differences, and inability to effectively capture changes in individual behavior. In addition, relying solely on historical pedestrian flow data for prediction is unreasonable in practical applications because this method ignores the uncertainty of pedestrian behavior and cannot fully capture the diversity of individual behavior. These limitations reduce the prediction accuracy and robustness of the model when facing emergencies or non-standard flow patterns. Among the existing methods, most use graph convolution (GCN), recurrent neural network (RNN) and long short-term memory network (LSTM) methods to analyze time series data. These networks can effectively identify temporal dependencies in data. However, when faced with complex urban scenes, especially in environments with dense pedestrian flow or significant changes in traffic mobility, these networks often require long computing times and have high demands on computing resources due to their high structural complexity. Therefore, although they have demonstrated their ability to extract and learn temporal correlations, there is still room for improvement in the real-time and accuracy of predictions. In practical applications, this may constrain instant traffic decision-making and emergency response. Summary of the invention
[0007] In order to solve the problems existing in the prior art, the present invention provides a pedestrian flow density and flow prediction system and method based on convolutional neural network, which is a sequence-to-sequence architecture model. The model consists of seven key modules: coordinate transformation module, sampling module, trajectory embedding module, encoding module, decoding module, trajectory output module and density flow calculation module; first, the data is transformed and sampled through the coordinate transformation module and sampling module, and then the input pedestrian trajectory is embedded into a vector with richer information through the trajectory embedding module based on the multi-layer perceptron, providing more detailed feature information for subsequent modules. Then, the encoder in the encoding module uses a convolutional neural network structure to encode and extract features from the trajectory vector, and gradually increases the number of channels to further enrich the feature information. After receiving the feature information, the decoder in the decoding module performs tensor reshape and dimensionality reduction operations, and then decodes through convolution operations. Subsequently, the trajectory output module converts the feature tensor into trajectory coordinate output in the opposite way to the coordinate embedding module. Finally, the density flow calculation module uses these predicted trajectories to calculate the instantaneous speed of pedestrians and the crowd density at a certain moment through the Voronoi diagram method, and then calculates the flow of pedestrians, solving the problems mentioned in the above background technology.
[0008] To achieve the above object, the present invention provides the following technical solution: a pedestrian flow density and flow prediction system based on convolutional neural network, the system comprising:
[0009] Coordinate transformation module: obtain data set data, and use the coordinate transformation module to perform coordinate transformation on the data set data;
[0010] Sampling module: samples the coordinates processed by the coordinate transformation module, and then aggregates the sampled data into trajectory data suitable for deep learning model input;
[0011] Trajectory embedding module: embeds the trajectory data into a trajectory vector with richer information through a trajectory embedding module based on a multi-layer perceptron.
[0012] Encoding module: The encoder uses a convolutional neural network to encode and extract features from the trajectory vector to obtain a feature vector with higher dimensions and richer information;
[0013] Decoding module: The decoder is used to reshape and reduce the dimension of the feature vector output by the encoder, and then the decoding process is performed to obtain the decoded vector;
[0014] Trajectory output module: Input the decoded vector output by the decoder into the trajectory output module to obtain the predicted trajectory information;
[0015] Density flow calculation module: The speed, density and flow of pedestrians are calculated using the trajectory predicted in the trajectory output module through the Voronoi diagram method.
[0016] Preferably, in the coordinate transformation sampling module, the step of acquiring data set data specifically includes the following:
[0017] S111, obtain the pedestrian number of the data set, the corresponding frame number and the three-dimensional coordinates of the pedestrian in the real world ( X , Y , Z );
[0018] S112, obtain the internal parameters of the camera ( f x , f y ,c x , c y ),in f x , f y is the focal length of the camera, c x , c y is the offset of the principal point;
[0019] S113. Obtain the external parameters of the camera, including the rotation matrix of the camera R and translation vector T ;
[0020] The coordinate transformation specifically includes the following:
[0021] S121, the three-dimensional coordinates of the real world ( X , Y , Z ) is converted to the three-dimensional coordinates in the camera coordinate system ( X c , Y c , Z c ), the conversion formula is expressed as follows:
[0022] ;
[0023] S122, using the perspective method, the three-dimensional coordinates in the camera coordinate system ( X c , Y c , Z c ) is converted to the three-dimensional coordinates in the normalized device coordinate system ( Xn , Y n , 1 ),in X n = X c / Z c , Y n = Y c / Z c ;
[0024] S123, normalize the three-dimensional coordinates in the device coordinate system ( X n , Y n , 1 ), mapped to the two-dimensional image plane and converted into image pixel coordinates ( x 0 , y 0 ), using the camera's parameters ( f x , f y ,c x , c y ) is converted by the following formula:
[0025] .
[0026] Preferably, in the sampling module, the sampling process specifically includes the following:
[0027] S21, from t 1 Start to t obs Every Observe the trajectory coordinates of a pedestrian once, for each pedestrian i , In time t ∈{ t 1 , t 1 +Δt, ... , t obs}, observe its position coordinates , t obs represents the moment when the observation is cut off;
[0028] S22, aggregate the discrete coordinates of pedestrians into a shapeN × D 0 × T obs Track information Among them N Represents the number of pedestrians or vector channels, T obs The observation length expressed as the total sampling time step, dimension D 0 =2 represents the horizontal coordinate of the trajectory and the vertical coordinate , the specific formula is as follows:
[0029] .
[0030] Preferably, in the trajectory embedding module, the following are specifically included:
[0031] S31. Set up a multi-layer perceptron MLP As the basic structure of the trajectory embedding module, MLP There are several hidden layers in it, and the formula for each hidden layer is as follows:
[0032] ;
[0033] in x, y Respectively MLP The input and output, n represents the number of hidden layers, represents the weight of each layer, b It is expressed as bias;
[0034] S32, use an exponential linear unit after each hidden layer ELU Activation function, the formula is as follows:
[0035] ;
[0036] in, represents the output of the activation function, α It is an adjustable parameter; Represents a constant The exponential function with base , Approximately equal to 2.7;
[0037] S33. Implement forward propagation: transform trajectory data Input to MLP For each time step, the input data is MLP After computing the corresponding embedding output, apply ELU The activation function transforms the embedding result into a higher-dimensional shape. N × C 0× D × T obs Vector h In N channels, each containing C 0 feature matrices, each of which has the shape D × T obs ; The vector h The second dimension is changed from the original D 0 Expanded into a larger D , the process is as follows:
[0038] ;
[0039] in, , , are the embedding weights.
[0040] Preferably, in the encoding module, the encoding and feature extraction specifically include the following:
[0041] S41, tensor input: Get the shape of the output from the trajectory embedding module N × C 0 × D × T obs Vector h , which is interpreted as having N Channels, each channel contains C 0 feature matrices, each of which has the shape D × T obs ;
[0042] S42, 2D convolution operation: Apply 2D convolution layer to the feature matrix for feature extraction. In this process, in order to expand the feature information of the trajectory, the number of feature matrices is increased by C 0 Increased to C , C Represents the number of feature matrices after the two-dimensional convolution operation to enhance the model's ability to express data. The output of the two-dimensional convolution layer can be calculated as:
[0043] ;
[0044] in, O is the output of the convolutional layer, k , l represents the index of the output, M c and N c is the height and width of the convolution kernel, m, n Represented as the index of the convolution kernel, H [ m, n ] represents the weight of the convolution kernel, I is the input feature matrix, in the first convolutional layer of the decoder I The value of h , P is the size of the padding;
[0045] S43, ELU activation operation: used after each two-dimensional convolution ELU Perform nonlinear activation;
[0046] S44, batch normalization operation: Batch normalization operation is introduced after the activation function. For the output of each convolutional layer, the features of each channel are normalized to make its mean close to 0 and standard deviation close to 1; the formula for batch normalization is as follows:
[0047] ;
[0048] in represents the output features of batch normalization, θ represents the input features, μ represents the mean of the feature matrix, σ represents the standard deviation of the current feature matrix, γ Denotes the scaling parameter learned during training, β is the shift parameter learned during training.
[0049] Preferably, in the decoding module, the decoding process specifically includes the following:
[0050] S51. Use upsampling layers to reshape the feature matrix: Use upsampling layers to reshape the feature matrix from D × T obs Expand into D ×T pred , T pred Represents the length of the predicted trajectory to output a trajectory that meets the predicted length. Here, bilinear interpolation is used to implement this process. The formula is as follows:
[0051] ;
[0052] in, represents the input feature matrix, p, q is the index of the input matrix, Upsample ( X ) represents the feature matrix after upsampling, u, v is the index of the feature matrix after upsampling, is the kernel function of bidirectional interpolation, is the input of the kernel function;
[0053] S52, two-dimensional convolution decoding: Two-dimensional convolution decodes the feature matrix and converts the number of feature matrices from C Drop back ;
[0054] S53, ELU Activation and batch normalization operations: Use ELU Activation function and batch normalization operations are performed to process the feature vector after each two-dimensional convolution layer, and finally the decoded feature vector is output. h o .
[0055] Preferably, in the trajectory output module, the following are specifically included:
[0056] S61, input feature vector: the feature vector output by the decoder h o As input data;
[0057] S62. Set up a multi-layer perceptron with a completely opposite structure to the trajectory embedding module MLP 2 as the basic structure of the trajectory output module;
[0058] S63, use ELU As an activation function to introduce nonlinearity and generate the final output trajectory coordinates;
[0059] S64: Output predicted trajectory information , the output of the trajectory output module can be calculated as:
[0060] ;
[0061] in, , represents the feature vector output by the decoder, W o is the output weight.
[0062] Preferably, in the density flow calculation module, the calculation of the speed, density and flow of the pedestrian flow using the trajectory predicted in the trajectory output module by the Voronoi diagram method specifically includes the following:
[0063] S71, constructing a Voronoi diagram: constructing a Voronoi diagram using the pedestrian coordinate position points of the predicted trajectory information in the trajectory output module. This process includes the following steps:
[0064] S711, defining points of each pedestrian position in the observation area, and constructing a Voronoi diagram based on these points, each point is surrounded by a series of polygons, namely Voronoi diagram cells, and the boundaries of these polygons are composed of lines equidistant from two or more nearest points;
[0065] S712, for each pair of generated points, find their perpendicular bisectors, where any point on the bisector is equidistant from the two generated points, and a portion of the perpendicular bisector will become the boundary between adjacent Voronoi diagram units; by performing this operation on all pairs of generated points, the boundaries of all Voronoi diagram units can be determined, and connecting all boundaries forms a complete Voronoi diagram;
[0066] S72, calculating the area of the Voronoi diagram unit: The area of the Voronoi diagram unit reflects the amount of available space around the corresponding pedestrian, and the calculation includes the following steps:
[0067] S721, sorting fixed points: In order to accurately calculate the area of a polygon, its vertices must be sorted in clockwise or counterclockwise order;
[0068] S722. Application area formula: The area of a polygon is calculated using the following formula:
[0069] ;
[0070] in, s is the number of polygon vertices, x i and y i They are i The horizontal and vertical coordinates of the vertices;
[0071] S73. Calculate Voronoi diagram speed: pedestrian speed of each Voronoi diagram unit v xy (t) is calculated from the trajectory of two consecutive time steps:
[0072] ;
[0073] in Indicates that pedestrians are The location at the moment, represents the relaxation time of the interval;
[0074] Voronoi diagram speed of the entire observation area v v The pedestrian speed in this area is integrated to get:
[0075] ;
[0076] in is the double integral symbol,dx , dy represents differential;
[0077] S74. Calculate the density of the Voronoi graph: For each Voronoi graph unit, its corresponding pedestrian density ρ xy It is calculated by the unit area of the Voronoi diagram calculated in S722, that is:
[0078] ;
[0079] On this basis, the Voronoi diagram density of the entire observation area ρ v The pedestrian density of the area is integrated to obtain:
[0080] ;
[0081] S75, Pedestrian flow Js The product of the Voronoi density and velocity is:
[0082] .
[0083] On the other hand, to achieve the above-mentioned purpose, the present invention also provides the following technical solution: a prediction method of a pedestrian flow density and flow prediction system based on a convolutional neural network, comprising the following steps:
[0084] S1, coordinate transformation: obtain data set data, and use the coordinate transformation module to perform coordinate transformation processing on the data set data;
[0085] S2, sampling: sampling the coordinates after coordinate transformation, and then aggregating the sampled data into trajectory data suitable for deep learning model input;
[0086] S3, trajectory embedding: embed the trajectory data. Through the trajectory embedding module based on the multi-layer perceptron, the input pedestrian trajectory data is embedded into a trajectory vector with richer information.
[0087] S4, encoding: The encoder uses a convolutional neural network to encode and extract features from the trajectory vector to obtain a feature vector with higher dimensions and richer information;
[0088] S5, decoding: using the decoder to reshape and reduce the dimension of the feature vector output by the encoder, and then perform the decoding process to obtain a decoded vector;
[0089] S6, trajectory output: input the decoding vector output by the decoder into the trajectory output module to obtain the predicted trajectory information;
[0090] S7. Density flow calculation: The speed, density and flow of pedestrians are calculated using the trajectory predicted in the trajectory output module through the Voronoi diagram method.
[0091] The beneficial effects of the present invention are:
[0092] 1) Real-time monitoring and early warning: The present invention establishes a pedestrian congestion early warning system through real-time data collection and analysis, and uses convolutional neural networks to accurately predict pedestrian flow, which can timely identify congestion risks and issue early warning signals, so as to take measures in advance to prevent congestion;
[0093] 2) Dynamic traffic management: The system monitors pedestrian flow in real time and dynamically adjusts traffic signals and signs to effectively guide pedestrian flow and avoid overcrowding in specific areas. This management method helps balance the density of pedestrian flow in various areas and reduce the occurrence of congestion;
[0094] 3) Improve prediction efficiency: The present invention significantly improves prediction efficiency by introducing highly parallelizable fully connected layers and convolutional layers, combined with efficient prediction algorithms. This method can simultaneously predict the trajectories of up to 128 pedestrians in a very short time, i.e., less than 5 milliseconds. In practical applications, this method can quickly respond to traffic management needs and provide real-time and accurate density and prediction for pedestrians, thereby improving the real-time nature of traffic management and the timeliness of accident prevention. It has important practical value and application prospects.
[0095] 4) Emergency evacuation planning: When potential crowding or stampede risks are predicted, the present invention helps managers quickly formulate emergency evacuation plans. Through accurate pedestrian flow prediction and simulation, effective evacuation routes are formulated to quickly and safely guide people to evacuate high-risk areas.
[0096] 5) Versatility and adaptability: The present invention benefits from the powerful capabilities of deep learning models and demonstrates excellent versatility and adaptability. Deep learning models can automatically learn and extract the intrinsic characteristics of data without relying too much on manually set rules and parameters. This enables the model to perform well in different scenarios and types of pedestrian density and flow tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0097] Figure 1 It is a schematic diagram of the pedestrian flow density and flow prediction system module based on convolutional neural network of the present invention;
[0098] Figure 2 A schematic diagram of a Voronoi diagram of the present invention;
[0099] Figure 3 This is a technical flow chart of the pedestrian flow density and flow prediction method based on convolutional neural network of the present invention;
[0100] Figure 4 The present invention is a flowchart of the steps of the pedestrian flow density and flow prediction method based on convolutional neural network;
[0101] In the figure, 110 is a coordinate transformation module; 120 is a sampling module; 130 is a trajectory embedding module; 140 is an encoding module; 150 is a decoding module; 160 is a trajectory output module; and 170 is a density flow calculation module. DETAILED DESCRIPTION
[0102] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0103] The present invention provides a technical solution: a pedestrian flow density and flow prediction system based on convolutional neural network, such as Figure 1 As shown, a convolutional neural network (CNN) combined with a Voronoi diagram algorithm is used to predict the density and flow of pedestrians. This method is mainly used in intelligent transportation systems, accident prevention, and crowd management. The system includes:
[0104] Coordinate transformation module 110: obtains data set data, and uses the coordinate transformation module to perform coordinate transformation processing on the data set data;
[0105] Sampling module 120: performs sampling processing on the coordinates processed by the coordinate transformation module 110, and then aggregates the sampled data into trajectory data suitable for deep learning model input;
[0106] Trajectory embedding module 130: performs an embedding operation on the trajectory data, and embeds the input pedestrian trajectory data into a trajectory vector with richer information through a trajectory embedding module based on a multi-layer perceptron;
[0107] Encoding module 140: The encoder uses a convolutional neural network to encode and extract features from the trajectory vector to obtain a feature vector with higher dimensions and richer information;
[0108] Decoding module 150: using the decoder to reshape and reduce the dimension of the feature vector output by the encoder, and then perform a decoding process to obtain a decoded vector;
[0109] Trajectory output module 160: inputs the decoded vector output by the decoder into the trajectory output module to obtain predicted trajectory information;
[0110] The density flow calculation module 170 calculates the speed, density and flow of the pedestrian flow using the trajectory predicted in the trajectory output module 160 through the Voronoi diagram method.
[0111] Furthermore, in the coordinate transformation sampling module 110, the step of acquiring data set data specifically includes the following:
[0112] S111, obtain the pedestrian number of the data set, the corresponding frame number and the three-dimensional coordinates of the pedestrian in the real world ( X , Y , Z );
[0113] S112, obtain the internal parameters of the camera ( f x , f y ,c x , c y ),in f x , f y is the focal length of the camera, c x , c y is the offset of the principal point;
[0114] S113. Obtain the external parameters of the camera, including the rotation matrix of the camera R and translation vector T , which describe the position and orientation of the camera in real-world coordinates.
[0115] Furthermore, in the coordinate transformation module 110, the coordinate transformation specifically includes the following:
[0116] S121, the three-dimensional coordinates of the real world ( X , Y , Z ) is converted to the three-dimensional coordinates in the camera coordinate system ( X c , Y c , Z c ), which uses the camera's rotation matrix R and translation vector T , the conversion formula is expressed as follows:
[0117] ;
[0118] S122, using the perspective method, the three-dimensional coordinates in the camera coordinate system ( Xc , Y c , Z c ) is converted to the three-dimensional coordinates in the normalized device coordinate system ( X n , Y n , 1 ),in X n = X c / Z c , Y n = Y c / Z c ;
[0119] S123, normalize the three-dimensional coordinates in the device coordinate system ( X n , Y n , 1 ), mapped to the two-dimensional image plane and converted into image pixel coordinates ( x 0 , y 0 ), using the camera's parameters ( f x , f y ,c x , c y ) is converted by the following formula:
[0120] .
[0121] Furthermore, in the sampling module 120, the transformed coordinates are sampled and then the sampled data are integrated into a trajectory format suitable for deep learning model input.
[0122] The sampling process specifically includes the following:
[0123] S21. For the pedestrian position coordinates obtained in the data set, observe and sample them every 0.2 s, for a total of 8 times, with a total duration of 1.6 s. Specifically, assuming that time is discretized, t 1 Start to t obs Every Observe the trajectory coordinates of a pedestrian once, for each pedestrian i ,In time t ∈{ t 1 , t 1 +Δt, ... , t obs}, observe its position coordinates , here ; t obs Indicates the time when the observation is cut off;
[0124] S22, will N The discrete coordinates of pedestrians are aggregated into the shape of N × D 0 × T obs Track information Among them N Represents the number of pedestrians or vector channels, T obs It is expressed as the observation length of the total sampling time step (8 time steps in this example), and the dimension D 0 =2 represents the horizontal coordinate of the trajectory and the vertical coordinate , the specific formula is as follows:
[0125] .
[0126] Furthermore, the trajectory embedding module 130 is used to embed the trajectory data, so as to obtain more detailed features.
[0127] In the trajectory embedding module 130, the following is specifically included:
[0128] S31. Set up a multi-layer perceptron MLP As the basic structure of the trajectory embedding module, MLP There are several hidden layers in it, and the formula for each hidden layer is as follows:
[0129] ;
[0130] in x, y Respectively MLP The input and output, n represents the number of hidden layers, represents the weight of each layer, b It is expressed as bias;
[0131] S32, ELU Activation: Use an exponential linear unit after each hidden layerELU Activation function, the formula is as follows:
[0132] ;
[0133] in, represents the output of the activation function, α It is an adjustable parameter; Represents a constant e The exponential function with base , e Approximately equal to 2.7;
[0134] S33. Implement forward propagation: transform trajectory data Input to MLP For each time step, the input data is MLP After computing the corresponding embedding output, apply ELU The activation function transforms the embedding result into a higher-dimensional shape. N × C 0 × D × T obs Vector h In N channels, each containing C 0 feature matrices, each of which has the shape D × T obs ; The vector h The second dimension is changed from the original D 0 Expanded into a larger D To obtain more detailed features, the process is as follows:
[0135] ;
[0136] in, , , are the embedding weights.
[0137] Furthermore, the feature information output by the trajectory embedding module is encoded and further feature extracted through the encoder, thereby obtaining a feature vector with higher dimension and richer information.
[0138] In the encoding module 140, the encoding and feature extraction specifically include the following:
[0139] S41, tensor input: Get the shape of the output from the trajectory embedding module N × C 0 × D × T obs Vector h , which is interpreted as having N Channels, each channel containsC 0 feature matrices, each of which has the shape D × T obs ;
[0140] S42, 2D convolution operation: Apply 2D convolution layer to the feature matrix for feature extraction. In this process, in order to expand the feature information of the trajectory, the number of feature matrices is increased by C 0 Increased to C , C Represents the number of feature matrices after the two-dimensional convolution operation to enhance the model's ability to express data, and uses padding to keep the shape of the output and input feature matrices unchanged. The padding operation allows more convolutional layers to be used, further enhancing the effect of data feature extraction. The output of the two-dimensional convolutional layer can be calculated as:
[0141] ;
[0142] in, O is the output of the convolutional layer, k , l represents the index of the output, M c and N c is the height and width of the convolution kernel, m , n Represented as the index of the convolution kernel, H [ m, n ] represents the weight of the convolution kernel, I is the input feature matrix, in the first convolutional layer of the decoder I The value of h , P is the size of the padding;
[0143] S43, ELU activation operation: used after each two-dimensional convolution ELU Perform nonlinear activation;
[0144] S44, batch normalization operation: Batch normalization operation is introduced after the activation function. For the output of each convolutional layer, the features of each channel are normalized to make its mean close to 0 and standard deviation close to 1; this helps to alleviate the gradient vanishing problem, improve the convergence speed of the model, and enhance the robustness of the model to the input data. The formula for batch normalization is as follows:
[0145] ;
[0146] in represents the output features of batch normalization, θ represents the input features, μrepresents the mean of the feature matrix, σ represents the standard deviation of the current feature matrix, γ Denotes the scaling parameter learned during training, β is the shift parameter learned during training.
[0147] Furthermore, the decoder is used to reshape and reduce the dimension of the feature vector output by the encoder, and then perform the decoding process.
[0148] In the decoding module 150, the decoding process specifically includes the following:
[0149] S51. Use upsampling layers to reshape the feature matrix: Use upsampling layers to reshape the feature matrix from D × T obs Expand into D ×T pred (in T pred Represents the length of the predicted trajectory), in order to output a trajectory that meets the predicted length. Bilinear interpolation is used to implement this process, and its formula is as follows:
[0150] ;
[0151] in, represents the input feature matrix, p, q is the index of the input matrix, Upsample ( X ) represents the feature matrix after upsampling, u, v is the index of the feature matrix after upsampling, is the kernel function of bidirectional interpolation, is the input of the kernel function;
[0152] S52, two-dimensional convolution decoding: The two-dimensional convolution similar to the encoder decodes the feature matrix and converts the number of feature matrices from C Drop back ;
[0153] S53, ELU Activation and batch normalization operations: Use ELU Activation function and batch normalization operations are performed to process the feature vector after each two-dimensional convolution layer, and finally the decoded feature vector is output. h o .
[0154] Furthermore, the decoded vector output by the decoder is input into the trajectory output module, and the predicted trajectory information is finally obtained through processing by the module, thereby completing the entire trajectory prediction process.
[0155] The trajectory output module 160 specifically includes the following:
[0156] S61, input feature vector: the feature vector output by the decoder h o As input data;
[0157] S62. Set up a multi-layer perceptron with a completely opposite structure to the trajectory embedding module MLP 2 as the basic structure of the trajectory output module;
[0158] S63, use ELU (Exponential Linear Unit) as the activation function to introduce nonlinearity and generate the final output trajectory coordinates;
[0159] S64: Output predicted trajectory information , containing the pedestrian coordinates of 12 time steps (2.4 s), the output of the trajectory output module can be calculated as:
[0160] ;
[0161] in, , represents the feature vector output by the decoder, W o is the output weight.
[0162] Furthermore, the predicted trajectories are used to calculate the speed, density and flow of pedestrians through the Voronoi diagram method.
[0163] In the density flow calculation module 170, the Voronoi diagram method is used to calculate the speed, density and flow of the pedestrian flow using the trajectory predicted in the trajectory output module 160, which specifically includes the following:
[0164] S71, constructing a Voronoi diagram: constructing a Voronoi diagram using the pedestrian coordinate position points of the predicted trajectory information in the trajectory output module, such as Figure 2 As shown, this process includes the following steps:
[0165] S711, defining points for each pedestrian position in the observation area, and constructing a Voronoi diagram based on these points, each point being surrounded by a series of polygons (Voronoi diagram cells), and the boundaries of these polygons are composed of lines equidistant from the nearest two or more points;
[0166] S712, for each pair of generated points, find their perpendicular bisectors, where any point on the bisector is equidistant from the two generated points, and a portion of the perpendicular bisector will become the boundary between adjacent Voronoi diagram units; by performing this operation on all pairs of generated points, the boundaries of all Voronoi diagram units can be determined, and connecting all boundaries forms a complete Voronoi diagram;
[0167] S72, calculating the area of the Voronoi diagram unit: The area of the Voronoi diagram unit reflects the amount of available space around the corresponding pedestrian, and the calculation includes the following steps:
[0168] S721, sorting fixed points: In order to accurately calculate the area of a polygon, its vertices must be sorted in clockwise or counterclockwise order;
[0169] S722. Application area formula: The area of a polygon is calculated using the following formula:
[0170] ;
[0171] in, s is the number of polygon vertices, x i and y i They are i The horizontal and vertical coordinates of the vertices;
[0172] S73. Calculate Voronoi diagram speed: pedestrian speed of each Voronoi diagram unit v xy (t) is calculated from the trajectory of two consecutive time steps:
[0173] ;
[0174] in Indicates that pedestrians are The location at the moment, represents the relaxation time of the interval.
[0175] Voronoi diagram speed of the entire observation area v v The pedestrian speed in this area is integrated to get:
[0176] ;
[0177] in is the double integral symbol, dx , dy represents differential;
[0178] S74. Calculate the density of the Voronoi graph: For each Voronoi graph unit, its corresponding pedestrian density ρ xyIt is calculated by the unit area of the Voronoi diagram calculated in S722, that is:
[0179] ;
[0180] On this basis, the Voronoi diagram density of the entire observation area ρ v The pedestrian density of the area is integrated to obtain:
[0181] ;
[0182] S75, Pedestrian flow Js The product of the Voronoi density and velocity is:
[0183] .
[0184] A prediction method using the above-mentioned pedestrian flow density and flow prediction system based on convolutional neural network, the technical process and steps are as follows Figure 3 and Figure 4 As shown, the following steps are included:
[0185] S1, coordinate transformation: obtain data set data, and use the coordinate transformation module to perform coordinate transformation processing on the data set data;
[0186] S2, sampling: sampling the coordinates after coordinate transformation, and then aggregating the sampled data into trajectory data suitable for deep learning model input;
[0187] S3, trajectory embedding: embed the trajectory data. Through the trajectory embedding module based on the multi-layer perceptron, the input pedestrian trajectory data is embedded into a trajectory vector with richer information.
[0188] S4, encoding: The encoder uses a convolutional neural network to encode and extract features from the trajectory vector to obtain a feature vector with higher dimensions and richer information;
[0189] S5, decoding: using the decoder to reshape and reduce the dimension of the feature vector output by the encoder, and then perform the decoding process to obtain a decoded vector;
[0190] S6, trajectory output: input the decoding vector output by the decoder into the trajectory output module to obtain the predicted trajectory information;
[0191] S7. Density flow calculation: The speed, density and flow of pedestrians are calculated using the trajectory predicted in the trajectory output module through the Voronoi diagram method.
[0192] The present invention significantly improves the prediction efficiency by introducing highly parallelizable fully connected layers and convolutional layers, combined with efficient prediction algorithms. The method can simultaneously predict the trajectories of up to 128 pedestrians in a very short time, i.e., less than 5 milliseconds. In practical applications, the method can quickly respond to traffic management needs and provide real-time and accurate density and prediction for pedestrians, thereby improving the real-time nature of traffic management and the timeliness of accident prevention, and has important practical value and application prospects.
[0193] Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A pedestrian flow density and flow prediction system based on convolutional neural network, characterized in that: The system comprises: Coordinate transformation module (110): obtains data of a data set, and uses the coordinate transformation module to perform coordinate transformation processing on the data of the data set; A sampling module (120): performs sampling processing on the coordinates processed by the coordinate transformation module (110), and then aggregates the sampled data into trajectory data suitable for input into a deep learning model; A trajectory embedding module (130): performs an embedding operation on the trajectory data, and embeds the input pedestrian trajectory data into a trajectory vector with richer information through a trajectory embedding module based on a multi-layer perceptron; In the trajectory embedding module (130), the following are specifically included: S31. Set a multi-layer perceptron MLP as the basic structure of the trajectory embedding module. The MLP contains several hidden layers. The formula of each hidden layer is as follows: Where x and y represent the input and output of MLP respectively, n represents the number of hidden layers, and w i represents the weight of each layer, and b represents the bias; S32. Use an exponential linear unit ELU activation function after each hidden layer. The formula is as follows: Among them, ELU(x) represents the output of the activation function, α is an adjustable parameter; e x represents an exponential function with a constant e as the base, which is approximately equal to 2.7; S33. Implement forward propagation: transform trajectory data Input to MLP, for each time step of input data, the corresponding embedding output is calculated by MLP and then the ELU activation function is applied to convert the embedding result into a higher dimensional shape of N×C0×D×T obs In the vector h, that is, N channels, each channel contains C0 feature matrices, and the shape of each feature matrix is D×T obs ; Expand the second dimension of vector h from the original D0 to a larger D, the process is as follows: in, W e is the embedding weight; Encoding module (140): The encoder uses a convolutional neural network to encode and extract features from the trajectory vector to obtain a feature vector with higher dimension and richer information; In the encoding module (140), the encoding and feature extraction specifically include the following: S41, tensor input: Get the shape of N×C0×D×T output from the trajectory embedding module obs The vector h is interpreted as having N channels, each channel contains C0 feature matrices, and each feature matrix has a shape of D×T obs ; S42, two-dimensional convolution operation: Apply a two-dimensional convolution layer to the feature matrix for feature extraction. In this process, in order to expand the feature information of the trajectory, the number of feature matrices is increased from C0 to C, where C represents the number of feature matrices after the two-dimensional convolution operation to enhance the model's ability to express data. The output of the two-dimensional convolution layer can be calculated as: Among them, O is the output of the convolutional layer, k and l represent the index of the output, and M c and N c is the height and width of the convolution kernel, m and n represent the index of the convolution kernel, H[m,n] represents the weight of the convolution kernel, I is the input feature matrix, the value of I in the first convolution layer of the decoder is h, and P is the padding size; S43, ELU activation operation: Use ELU for nonlinear activation after each two-dimensional convolution; S44, batch normalization operation: Batch normalization operation is introduced after the activation function. For the output of each convolutional layer, the features of each channel are normalized to make its mean close to 0 and standard deviation close to 1; the formula for batch normalization is as follows: Where BN(θ) represents the output features of batch normalization, θ represents the input features, μ represents the mean of the feature matrix, σ represents the standard deviation of the current feature matrix, γ represents the scaling parameter learned in training, and β represents the shift parameter learned in training; Decoding module (150): using a decoder to reshape and reduce the dimension of the feature vector output by the encoder, and then performing a decoding process to obtain a decoded vector; Trajectory output module (160): inputting the decoding vector output by the decoder into the trajectory output module to obtain predicted trajectory information; Density flow calculation module (170): using the trajectory predicted in the trajectory output module (160) to calculate the speed, density and flow of the pedestrian flow through the Voronoi diagram method; In the density flow calculation module (170), the calculation of the speed, density and flow of the pedestrian flow using the trajectory predicted in the trajectory output module by the Voronoi diagram method specifically includes the following: S71, constructing a Voronoi diagram: constructing a Voronoi diagram using the pedestrian coordinate position points of the predicted trajectory information in the trajectory output module. This process includes the following steps: S711, defining points of each pedestrian position in the observation area, and constructing a Voronoi diagram based on these points, each point is surrounded by a series of polygons, namely Voronoi diagram cells, and the boundaries of these polygons are composed of lines equidistant from two or more nearest points; S712, for each pair of generated points, find their perpendicular bisectors, where any point on the bisector is equidistant from the two generated points, and a portion of the perpendicular bisector will become the boundary between adjacent Voronoi diagram units; by performing this operation on all pairs of generated points, the boundaries of all Voronoi diagram units can be determined, and connecting all boundaries forms a complete Voronoi diagram; S72, calculating the area of the Voronoi diagram unit: The area of the Voronoi diagram unit reflects the amount of available space around the corresponding pedestrian, and the calculation includes the following steps: S721, sorting fixed points: In order to accurately calculate the area of a polygon, its vertices must be sorted in clockwise or counterclockwise order; S722. Application area formula: The area of a polygon is calculated using the following formula: Where s is the number of polygon vertices, x i and i are the horizontal and vertical coordinates of the i-th vertex respectively; S73. Calculate the Voronoi diagram speed: the pedestrian speed v of each Voronoi diagram unit xy (t) is calculated from the trajectory of two consecutive time steps: in Indicates that pedestrians are The position at the moment, Δt0 represents the relaxation time of the interval; Voronoi diagram velocity v of the entire observation area v The pedestrian speed in the area is integrated to get: Where ∫∫ is the double integral symbol, dx, dy represent differentials; S74. Calculate the Voronoi map density: For each Voronoi map unit, its corresponding pedestrian density ρ xy It is calculated by the unit area of the Voronoi diagram calculated in S722, that is: On this basis, the Voronoi map density ρv of the entire observation area is obtained by integrating the pedestrian density in the area: S75. Pedestrian flow Js is obtained by multiplying the Voronoi diagram density and speed: Js=ρ v ·v v 。 2. The pedestrian flow density and flow prediction system based on convolutional neural network according to claim 1, characterized in that: In the coordinate transformation module (110), the step of obtaining data set data specifically includes the following: S111, obtaining the pedestrian number, corresponding frame number, and three-dimensional coordinates (X, Y, Z) of the pedestrian in the real world; S112, obtain the internal parameters of the camera (f x ,f y ,c x ,c y ), where f x ,f y is the focal length of the camera, c x ,c y is the offset of the principal point; S113, obtaining the external parameters of the camera, including the rotation matrix R and the translation vector T of the camera; The coordinate transformation specifically includes the following: S121, convert the three-dimensional coordinates (X, Y, Z) of the real world into the three-dimensional coordinates (X c ,Y c ,Z c ), the conversion formula is expressed as follows: S122, using the perspective method, the three-dimensional coordinates (X c ,Y c ,Z c ) is converted to the three-dimensional coordinates (X n ,Y n ,1), where X n =X c / Z c ,Y n =Y c / Z c ; S123, normalize the three-dimensional coordinates (X n ,Y n ,1), mapped to the two-dimensional image plane, converted into image pixel coordinates (x0, y0), using the camera parameters (f x ,f y ,c x ,c y ) is converted using the following formula:
3. The pedestrian flow density and flow prediction system based on convolutional neural network according to claim 1, characterized in that: In the sampling module (120), the sampling process specifically includes the following: S21, from t1 to t obs The trajectory coordinates of pedestrians are observed every Δt. For each pedestrian i, at time t∈{t1,t1+Δt,...,t obs }, observe its position coordinates t obs represents the moment when the observation is cut off; S22. Aggregate the pedestrian's discrete coordinates into a shape of N×D0×T obs Track information Where N represents the number of pedestrians or vector channels, T obs It is expressed as the observation length of the total sampling time step, and the dimension D0=2 represents the horizontal coordinate of the trajectory and the vertical coordinate The specific formula is as follows:
4. The pedestrian flow density and flow prediction system based on convolutional neural network according to claim 1, characterized in that: In the decoding module (150), the decoding process specifically includes the following: S51. Use the upsampling layer to reshape the feature matrix: Use the upsampling layer to reshape the feature matrix from D×T obs Expanded to D×T pred , T pred Represents the length of the predicted trajectory to output a trajectory that meets the predicted length. Here, bilinear interpolation is used to implement this process. The formula is as follows: in, represents the input feature matrix, p and q are the indices of the input matrix, represents the feature matrix after upsampling, u and v are the indexes of the feature matrix after upsampling, is the kernel function of bidirectional interpolation, is the input of the kernel function; S52, two-dimensional convolution decoding: two-dimensional convolution decodes the feature matrix, reducing the number of feature matrices from C to C0; S53, ELU activation and batch normalization operation: Use the ELU activation function and batch normalization operation to process the feature vector after each two-dimensional convolution layer, and finally output the decoded feature vector h o .
5. The pedestrian flow density and flow prediction system based on convolutional neural network according to claim 1, characterized in that: In the trajectory output module (160), the following are specifically included: S61, input feature vector: the feature vector h output by the decoder o As input data; S62, setting a multi-layer perceptron MLP2 having a structure completely opposite to that of the trajectory embedding module as the basic structure of the trajectory output module; S63, using ELU as an activation function to introduce nonlinearity and generate the final output trajectory coordinates; S64: Output predicted trajectory information The output of the trajectory output module can be calculated as: in, Represents the feature vector output by the decoder, W o is the output weight.
6. A prediction method using the pedestrian flow density and flow prediction system based on a convolutional neural network according to any one of claims 1 to 5, characterized in that: The steps include: S1, coordinate transformation: obtain data set data, and use the coordinate transformation module to perform coordinate transformation processing on the data set data; S2, sampling: sampling the coordinates after coordinate transformation, and then aggregating the sampled data into trajectory data suitable for deep learning model input; S3, trajectory embedding: embed the trajectory data. Through the trajectory embedding module based on the multi-layer perceptron, the input pedestrian trajectory data is embedded into a trajectory vector with richer information. S4, encoding: The encoder uses a convolutional neural network to encode and extract features from the trajectory vector to obtain a feature vector with higher dimensions and richer information; S5, decoding: using the decoder to reshape and reduce the dimension of the feature vector output by the encoder, and then perform the decoding process to obtain a decoded vector; S6, trajectory output: input the decoding vector output by the decoder into the trajectory output module to obtain the predicted trajectory information; S7. Density flow calculation: The speed, density and flow of pedestrians are calculated using the trajectory predicted in the trajectory output module through the Voronoi diagram method.
