Spatial and temporal feature extraction method based on traffic data
By combining the spatiotemporal feature extraction model of convolutional neural network and long-term neural network, and the recurrent neural network optimized by genetic algorithm, the limitations of traditional methods when processing nonlinear traffic flow data are solved, and the accuracy of traffic flow prediction is improved. , help reduce traffic congestion.
Patent Information
- Application Number
- CN202411190399.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional vehicle flow prediction methods have limitations when processing complex nonlinear traffic flow data, and it is difficult to effectively extract the spatio-temporal characteristics of traffic flow, affecting the accuracy of prediction.
The spatiotemporal feature extraction method based on traffic data is adopted, and the spatiotemporal feature extraction model combining convolutional neural networks and long-term neural networks is constructed to capture the dynamic changes and trend characteristics of traffic flow, and use genetic algorithms. Optimize the recurrent neural network to build an initial traffic prediction model and make real-time predictions.
It improves the accuracy of traffic flow prediction, can better understand the space-time dynamics of traffic flow, guide urban traffic planning and management, and reduce traffic congestion.
Smart Images

Figure CN119091377A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of traffic flow analysis, and in particular relates to a method for extracting spatiotemporal features based on traffic data. Background Art
[0002] In intelligent transportation systems and urban traffic management, accurate traffic flow prediction is of great significance for alleviating traffic congestion, improving road utilization efficiency, and achieving reasonable allocation of traffic resources. Traditional traffic flow prediction methods mainly rely on time series analysis, statistical models, etc. These methods have certain limitations when dealing with complex nonlinear traffic flow data. With the development of technology, spatiotemporal feature extraction methods based on traffic data have become a research hotspot.
[0003] Traffic data has significant spatiotemporal characteristics, that is, traffic flow not only changes over time, but is also affected by spatial location. For example, there is a correlation between traffic flow changes in adjacent sections, and traffic flow in different time periods will also show periodic changes due to factors such as commuting and leisure. Therefore, how to effectively extract these dynamic changes and trend characteristics from historical traffic data is crucial to improving the accuracy of traffic flow prediction. Summary of the invention
[0004] In order to solve the above technical problems, the present invention proposes a spatiotemporal feature extraction method based on traffic data to solve the problems existing in the above prior art.
[0005] To achieve the above object, the present invention provides a method for extracting spatiotemporal features based on traffic data, comprising the following steps:
[0006] Obtain and pre-process the traffic data of previous years to obtain pre-processed data;
[0007] Constructing a spatiotemporal feature extraction model, and capturing dynamic changes and trend characteristics of traffic flow in preprocessed data based on the spatiotemporal feature extraction model;
[0008] Constructing an initial traffic flow prediction model, training the traffic flow prediction model based on dynamic changes and trend characteristics of traffic flow, and obtaining a traffic flow prediction model;
[0009] Traffic flow prediction is performed based on real-time traffic data and the traffic flow prediction model to obtain a traffic flow prediction result.
[0010] Preferably, the method for obtaining preprocessed data comprises:
[0011] Collecting traffic status images of previous years taken by traffic monitoring cameras, performing grayscale processing and filtering processing on the traffic status images of previous years to obtain filtered images;
[0012] The vehicles in the filtered image are marked based on the Canny operator to obtain a marked image.
[0013] Preferably, the filtering method includes:
[0014] The Gaussian noise of the grayscale images of traffic status over the years is removed by Gaussian filtering;
[0015] The salt and pepper noise of the traffic status images of previous years after Gaussian filtering is removed by median filtering.
[0016] Preferably, the method for marking a vehicle in a filtered image comprises:
[0017] Use the Canny operator to calculate pixel gradients;
[0018] The non-maximum pixel gradient suppression method is used to eliminate the stray effect;
[0019] Eliminate small gradient modulus points through threshold hysteresis processing;
[0020] The car outlines are filtered out and marked based on their shape and size.
[0021] Preferably, the method for capturing dynamic changes and trend characteristics of traffic flow in pre-processed data comprises:
[0022] A spatiotemporal feature extraction model combining a convolutional neural network and a long-short-time neural network model is constructed, the preprocessed data is input into the spatiotemporal feature extraction model, local features in the image are extracted through a convolution operation, and the size of the feature map is reduced through a pooling operation while retaining important feature information; the pooled feature map is input into the long-short-time neural network to process the time series data and obtain the spatiotemporal characteristics of the traffic flow.
[0023] Preferably, when constructing a spatiotemporal feature extraction model combining a convolutional neural network and a long short-term neural network model, it includes:
[0024] Constructing an SE module, and adjusting the weight learning process of the SE module in a timely manner through adaptive adaptation to obtain an SE module with generalization ability;
[0025] The SE module with generalization ability is inserted after the activation function of each convolution of the convolutional neural network of the spatiotemporal feature extraction model structure.
[0026] Preferably, the method for constructing an initial vehicle flow prediction model includes:
[0027] Construct a recurrent neural network and generate a recurrent neural network group based on the recurrent neural network;
[0028] The recurrent neural network group is iterated multiple times by a genetic algorithm until the optimal model is obtained and the iteration is terminated to obtain an optimized neural network, and an initial vehicle flow prediction model is constructed based on the optimized neural network.
[0029] Preferably, the method for obtaining an optimized neural network comprises:
[0030] Encode the structural parameters of the recurrent neural network group into the chromosome of the genetic algorithm to obtain the network chromosome structure;
[0031] Construct a fitness function based on prediction accuracy;
[0032] Randomly generate a set of initial recurrent neural network chromosome structures through the network chromosome structure;
[0033] The initial recurrent neural network chromosome structure is iterated based on the fitness function, and the recurrent neural network structure corresponding to the individual with the highest fitness is selected and decoded in the last generation of iteration to obtain the optimized neural network.
[0034] Compared with the prior art, the present invention has the following advantages and technical effects:
[0035] The present invention discloses a spatiotemporal feature extraction method based on traffic data, including: obtaining traffic data of previous years and preprocessing to obtain preprocessed data; constructing a spatiotemporal feature extraction model, capturing the dynamic changes and trend characteristics of traffic flow in the preprocessed data based on the spatiotemporal feature extraction model; constructing an initial vehicle flow prediction model, training the vehicle flow prediction model based on the dynamic changes and trend characteristics of traffic flow, and obtaining a vehicle flow prediction model; and predicting vehicle flow based on real-time traffic data and the vehicle flow prediction model to obtain a vehicle flow prediction result. The present invention extracts spatial features through a CNN layer, and then learns long-term dependencies in time series data through an LSTM layer. This structure can better understand the spatiotemporal dynamics of traffic flow, effectively extract the spatiotemporal features of traffic data, and improve the prediction accuracy of traffic flow, which has a significant effect on guiding urban traffic planning and management and reducing traffic congestion. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0037] Figure 1 This is a flow chart of a method for extracting spatiotemporal features based on traffic data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0038] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0039] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0040] Embodiment 1
[0041] like Figure 1 As shown, this embodiment provides a method for extracting spatiotemporal features based on traffic data, including the following steps:
[0042] Obtain and preprocess the traffic data of previous years to obtain preprocessed data. This step is to ensure the accuracy and reliability of the data and provide a basis for subsequent analysis and prediction.
[0043] Construct a spatiotemporal feature extraction model to capture the dynamic changes and trend characteristics of traffic flow in the preprocessed data based on the spatiotemporal feature extraction model. This step is to extract useful information from complex traffic data in order to better understand the changing laws of traffic flow.
[0044] Construct an initial traffic flow prediction model, train the traffic flow prediction model based on the dynamic changes and trend characteristics of traffic flow, and obtain a traffic flow prediction model. This step is to use existing data and features to build a model that can predict future traffic flow.
[0045] Based on real-time traffic data and the traffic flow prediction model, traffic flow prediction is performed to obtain traffic flow prediction results. This step is to apply the model to practical problems and achieve accurate prediction of traffic flow.
[0046] Furthermore, the method for obtaining preprocessed data includes: collecting traffic status images of previous years taken by traffic monitoring cameras, graying and filtering the traffic status images of previous years to obtain filtered images; marking vehicles in the filtered images based on the Canny operator to obtain marked images. These steps are to extract useful information from the original traffic status images and provide a basis for subsequent feature extraction and prediction.
[0047] Furthermore, the filtering method includes: removing Gaussian noise of the grayscale processed traffic status images through Gaussian filtering; removing salt and pepper noise of the traffic status images through Gaussian filtering. These steps are to eliminate noise interference in the image and improve the image quality.
[0048] 1. Gaussian filtering
[0049] The purpose of Gaussian filtering is to filter out Gaussian noise in the image. The principle is to use the isotropy and separability of the Gaussian kernel to create a suitable Gaussian kernel to perform weighted averaging on the pixel values in the image. Since the image is two-dimensional, it belongs to a two-dimensional Gaussian distribution, and the following equation can be listed:
[0050]
[0051] Considering that the image pixels exist in a discrete form in the matrix, discrete approximation is required. The Gaussian kernel set here is [2,4,5,4,2; 4,9,12,9,4; 5,12,15,12,5; 4,9,12,9,4; 2,4,5,4,2]. In actual operation, the convolution matrix is used to scan each pixel in the waterline image, and the weighted average of the pixels in the neighborhood determined by the convolution is used to replace the value of the convolution center pixel.
[0052] 2. Median Filter
[0053] After completing the Gaussian filter, the median filter is performed below to remove the salt and pepper noise in the image.
[0054] Furthermore, the method for marking the vehicle in the filtered image includes: using the Canny operator to calculate the pixel gradient; using the non-maximum pixel gradient suppression method to eliminate the stray effect; eliminating the small gradient modulus value points through threshold hysteresis processing; screening the outline of the car according to the shape and size of the outline and marking it. These steps are to accurately identify the vehicle in the image and provide accurate data for subsequent feature extraction and prediction. The specific steps are as follows:
[0055] 1. Use the Canny operator to calculate pixel gradients.
[0056] 2. In order to eliminate the stray effects caused by edge detection, non-maximum pixel gradient suppression came into being. Since the previously calculated gradient edge is multiple pixels wide, it needs to be optimized to an accurate point width. Therefore, it is necessary to compare the gradient strength of the current image pixel with the gradient strength of the adjacent image pixel in the positive and negative gradient directions. If the gradient strength of the current image pixel is the largest compared to the gradient strength of other pixels in the same direction, retain its value, otherwise suppress it and set it to zero. Considering the precise calculation, linear interpolation can be used between two adjacent image pixels to obtain the corresponding image pixel gradient.
[0057] 3. After shortening the edge width, there are still a large number of small gradient modulus points left, which require threshold hysteresis processing. Among them, a high threshold and a low threshold need to be set to distinguish edge pixels. After the edge pixels are screened, there will be three situations: 1). If the gradient value of the edge pixel is greater than the high threshold, it is considered a strong edge point; 2). If the gradient value of the edge pixel is between the low threshold and the high threshold, it is considered a weak edge point; 3). If the gradient value of the edge pixel is less than the low threshold, it is directly set to zero and deleted.
[0058] 4. Filter out the car outlines and mark them according to their shape and size.
[0059] Furthermore, the method for capturing the dynamic changes and trend characteristics of traffic flow in preprocessed data includes: constructing a spatiotemporal feature extraction model combining a convolutional neural network and a long-short-term neural network model, inputting the preprocessed data into the spatiotemporal feature extraction model, extracting local features in the image through a convolution operation, reducing the size of the feature map through a pooling operation, while retaining important feature information; inputting the pooled feature map into the long-short-term neural network, processing the time series data, and obtaining the spatiotemporal characteristics of the traffic flow. These steps are to extract useful information from complex traffic data in order to better understand the changing laws of traffic flow.
[0060] Furthermore, when constructing a spatiotemporal feature extraction model combining a convolutional neural network and a long-short time neural network model, it includes: constructing an SE module, adjusting the weight learning process of the SE module in a timely manner through adaptive adaptation, and obtaining an SE module with generalization ability; inserting the SE module with generalization ability after each convolution activation function of the convolutional neural network of the spatiotemporal feature extraction model structure. These steps are to improve the performance and generalization ability of the model so that it can better adapt to different data and scenarios.
[0061] Furthermore, the method for constructing the initial vehicle flow prediction model includes: constructing a recurrent neural network, and generating a recurrent neural network group based on the recurrent neural network; iterating the recurrent neural network group multiple times through a genetic algorithm until the optimal model is obtained, and then terminating the iteration to obtain an optimized neural network, and constructing an initial vehicle flow prediction model based on the optimized neural network. These steps are to use existing data and features to establish a model that can predict future vehicle flow.
[0062] Furthermore, the method for obtaining an optimized neural network includes: encoding the structural parameters of the recurrent neural network group into chromosomes of a genetic algorithm to obtain a network chromosome structure; constructing a fitness function based on prediction accuracy; randomly generating a set of initial recurrent neural network chromosome structures through the network chromosome structure; iterating the initial recurrent neural network chromosome structure based on the fitness function, selecting the recurrent neural network structure corresponding to the individual with the highest fitness in the last generation of iteration and decoding it to obtain an optimized neural network. These steps are to optimize the structural parameters of the model through a genetic algorithm, thereby improving the performance and prediction accuracy of the model.
[0063] The present invention also provides an electronic device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, a spatiotemporal feature extraction method based on traffic data is implemented.
[0064] The present invention also provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, a method for extracting spatiotemporal features based on traffic data is implemented.
[0065] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for extracting spatiotemporal features based on traffic data, characterized in that: The following steps are involved: Obtain and pre-process the traffic data of previous years to obtain pre-processed data; Constructing a spatiotemporal feature extraction model, and capturing dynamic changes and trend characteristics of traffic flow in preprocessed data based on the spatiotemporal feature extraction model; Constructing an initial traffic flow prediction model, training the traffic flow prediction model based on dynamic changes and trend characteristics of traffic flow, and obtaining a traffic flow prediction model; Traffic flow prediction is performed based on real-time traffic data and the traffic flow prediction model to obtain a traffic flow prediction result.
2. The method for extracting spatiotemporal features based on traffic data according to claim 1, characterized in that: The method for obtaining preprocessed data comprises: Collecting traffic status images of previous years taken by traffic monitoring cameras, performing grayscale processing and filtering processing on the traffic status images of previous years to obtain filtered images; The vehicles in the filtered image are marked based on the Canny operator to obtain a marked image.
3. The method for extracting spatiotemporal features based on traffic data according to claim 2, characterized in that: The filtering method comprises: The Gaussian noise of the grayscale images of traffic status over the years is removed by Gaussian filtering; The salt and pepper noise of the traffic status images of previous years after Gaussian filtering is removed by median filtering.
4. The method for extracting spatiotemporal features based on traffic data according to claim 2, characterized in that: The method for marking a vehicle in a filtered image comprises: Use the Canny operator to calculate pixel gradients; The non-maximum pixel gradient suppression method is used to eliminate the stray effect; Eliminate small gradient modulus points through threshold hysteresis processing; The car outlines are filtered out and marked based on their shape and size.
5. The method for extracting spatiotemporal features based on traffic data according to claim 1, characterized in that: The method for capturing dynamic changes and trend characteristics of traffic flow in pre-processed data includes: A spatiotemporal feature extraction model combining a convolutional neural network and a long-short-time neural network model is constructed, the preprocessed data is input into the spatiotemporal feature extraction model, local features in the image are extracted through convolution operations, and the size of the feature map is reduced through pooling operations while retaining important feature information; the pooled feature map is input into the long-short-time neural network to process the time series data and obtain the spatiotemporal characteristics of the traffic flow.
6. The method for extracting spatiotemporal features based on traffic data according to claim 5, characterized in that: When building a spatiotemporal feature extraction model that combines a convolutional neural network and a long short-term neural network model, it includes: Constructing an SE module, and adjusting the weight learning process of the SE module in a timely manner through adaptive adaptation to obtain an SE module with generalization ability; The SE module with generalization ability is inserted after the activation function of each convolution of the convolutional neural network of the spatiotemporal feature extraction model structure.
7. The method for extracting spatiotemporal features based on traffic data according to claim 1, characterized in that: The method for constructing the initial vehicle flow prediction model comprises: Construct a recurrent neural network and generate a recurrent neural network group based on the recurrent neural network; The recurrent neural network group is iterated multiple times by a genetic algorithm until the optimal model is obtained and the iteration is terminated to obtain an optimized neural network, and an initial vehicle flow prediction model is constructed based on the optimized neural network.
8. The method for extracting spatiotemporal features based on traffic data according to claim 7, characterized in that: The method for obtaining an optimized neural network comprises: Encode the structural parameters of the recurrent neural network group into the chromosome of the genetic algorithm to obtain the network chromosome structure; Construct a fitness function based on prediction accuracy; Randomly generate a set of initial recurrent neural network chromosome structures through the network chromosome structure; The initial recurrent neural network chromosome structure is iterated based on the fitness function, and the recurrent neural network structure corresponding to the individual with the highest fitness is selected and decoded in the last generation of iteration to obtain the optimized neural network.
