A method and system for counting multi-turn vehicles at an intersection
Through the multi-angle detection network and the stack length short-term recurrent neural network, drone videos are used to count multi-turn vehicles, which solves the problem of counting turning vehicles at intersections, achieves accurate counting of multi-turn vehicles, and improves the efficiency of traffic management. and security.
Patent Information
- Application Number
- CN202111205143.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-15
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-10-15
AI Technical Summary
The existing technology is difficult to effectively solve the problem of counting turning vehicles at intersections, affecting the accuracy of traffic signal optimization and traffic management.
Multi-angle detection network and stack length short-term recurrent neural network are used to count multi-turn vehicles through traffic videos captured by drones, extract the turning spatio-temporal counting features, and combine the relationship between tilt detection frames and counting lines to achieve accurate multi-turn vehicle counting. count.
It achieves high-precision counting of multi-turn vehicles at intersections, provides basic data for traffic signal optimization and traffic management, and improves traffic flow management efficiency and traffic safety.
Smart Images

Figure CN113936255B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of vehicle counting, and in particular relates to a method and system for counting vehicles with multiple turns at an intersection. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] In recent years, there has been an increase in video surveillance of road traffic. These traffic video-based traffic monitoring systems are often developed using computer vision methods because the video has high information content and is smarter than traditional sensors such as magnetic coils, microwaves or ultrasonic detectors. For example, through visual technology, flow, speed, vehicle classification and anomaly detection can be provided. With the rapid development of aircraft technology and aerial photography technology, it has become easier to obtain high-resolution aerial images, and drone monitoring has also begun to be used in intelligent transportation.
[0004] In intelligent transportation, traffic flow parameters are the basic data of various intelligent models, and the acquisition of traffic flow parameters is usually based on vehicle counting. Counting vehicles on traffic roads and estimating traffic volume is of great significance to optimizing traffic and realizing smart cities. Vision-based traffic volume estimation methods have a high cost-effectiveness. In traffic vehicle counting, traffic flow data can be obtained by counting vehicles passing through a certain traffic section, while most vehicle counting is to count vehicles that are stationary at a certain moment, or to count the number of vehicles passing along the road.
[0005] Turn counting plays an important role in intersection analysis, including traffic operation analysis, intersection design, and traffic planning applications. In addition, turn counting is needed to develop optimized traffic signal timings, which leads to various benefits such as improved travel times, reduced fuel consumption, and fewer vehicle crashes. However, few works explicitly address turn counting at intersections. Summary of the invention
[0006] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides a method and system for counting vehicles with multiple turns at an intersection, which realizes counting of vehicles turning at an intersection to obtain the number of vehicles passing through each turn.
[0007] In order to achieve the above object, the present invention adopts the following technical solution:
[0008] A first aspect of the present invention provides a method for counting vehicles with multiple turns at an intersection, comprising:
[0009] Get intersection traffic video;
[0010] Perform multi-angle detection on the vehicle in each frame of the intersection traffic video to obtain the vehicle tilt detection frame of each frame;
[0011] Determine the tilt count line of each frame of image, extract the spatial features of each frame of image for each tilt count line, and select the spatial features of multiple frames of image before and after each frame of image to form the spatiotemporal count features of each frame of image;
[0012] Based on the spatiotemporal counting characteristics of each tilted counting line, the relationship between the vehicle and each counting line in each frame image is detected, and the vehicles on multiple turns are counted by combining the detection result and the vehicle tilt detection frame of the selected multiple frames of images.
[0013] Furthermore, the multi-angle detection adopts a multi-angle detection network, and the multi-angle detection network includes:
[0014] ResNet is used as the backbone network to extract the features of the input image and obtain four pyramid feature maps;
[0015] Normalize the four pyramid feature maps, add the normalized feature maps together, and obtain the added features;
[0016] Process the added features to obtain a foreground enhancement feature map;
[0017] The four pyramid feature maps are respectively added to the foreground enhancement feature map to obtain four enhanced pyramid feature maps;
[0018] After regional feature aggregation, the four enhanced pyramid feature maps are obtained to obtain four pooled feature maps, and the four pooled feature maps are merged along the channel dimension to obtain a merged feature map.
[0019] Furthermore, the multi-angle detection network also includes:
[0020] The merged feature map is sequentially subjected to global average pooling, convolution operation and S function to obtain a channel attention weight map;
[0021] Divide the channel attention weight map into four blocks and multiply them with four pooling feature maps at the channel level to obtain the multiplied feature map;
[0022] The multiplied feature maps are summed to obtain the final feature map;
[0023] The final feature map will be divided into two channels for full connection to predict the horizontal box and the tilted box respectively.
[0024] Furthermore, the specific steps of processing the added features are:
[0025] Taking the added features as input, first obtain the text information through a 3*3 convolution, and then obtain a single-channel feature weight map through a 1*1 convolution operation;
[0026] The single-channel feature weight map is multiplied with the binary image with the target area as the foreground at the pixel level, and the dot product result is added to the added features to obtain a foreground enhancement feature map.
[0027] Furthermore, the objective function of the multi-angle detection network consists of three parts, namely: the target segmentation loss between the feature weight map of the single channel and the binary image with the target area as the foreground, the classification loss of the horizontal box and the position loss of the inclined box.
[0028] Furthermore, the specific method for detecting the relationship between the vehicle and each counting line in each frame of image is:
[0029] The spatiotemporal counting features of a counting line are input into the stack length based short-time recurrent neural network. After the time series information in the spatiotemporal counting features is processed by the stack length based short-time recurrent neural network, the relationship between the vehicle and the counting line is obtained.
[0030] The relationship between the vehicle and the counting line includes: a vehicle passes through the counting line in an entering manner, a vehicle passes through the counting line in an exiting manner, and no vehicle passes through the counting line.
[0031] Furthermore, the specific steps of counting vehicles on multiple turns are:
[0032] For each inclined count line, determine the relationship between the vehicle and the count line;
[0033] If the relationship between the vehicle and the counting line is that no vehicle passes through the counting line, it is not counted;
[0034] If the relationship between the vehicle and the counting line is that the vehicle passes the counting line in an exiting manner or the vehicle passes the counting line in an entering manner, the vehicle turning is determined based on the vehicle tilt detection frame of the selected multiple frames of images, and the passing vehicles in the turning direction are accumulated.
[0035] A second aspect of the present invention provides a multi-turn vehicle counting system at an intersection, comprising:
[0036] A data acquisition unit is configured to: acquire a traffic video at an intersection;
[0037] A tilt frame detection unit is configured to: perform multi-angle detection on the vehicle in each frame of the intersection traffic video to obtain a vehicle tilt detection frame for each frame;
[0038] The spatiotemporal counting feature extraction unit is configured to: determine the tilted counting line of each frame image, extract the spatial feature of each frame image for each tilted counting line, and select the spatial features of multiple frames of images before and after each frame image to form the spatiotemporal counting feature of each frame image;
[0039] The vehicle counting unit is configured to detect the relationship between the vehicle and each counting line in each frame image based on the spatiotemporal counting characteristics of each tilted counting line, and count the vehicles on multiple turns by combining the detection results with the vehicle tilt detection frames of the selected multiple frames of images.
[0040] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the method for counting vehicles with multiple turns at an intersection as described above.
[0041] The fourth aspect of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the method for counting multi-turn vehicles at an intersection as described above are implemented.
[0042] Compared with the prior art, the present invention has the following beneficial effects:
[0043] The present invention provides a method for counting vehicles at multi-turn intersections, which proposes a multi-angle detection deep network (SCAM) with spatial and channel attention, to detect vehicle targets at intersections photographed by drones. The obtained detection frame is at any angle, and the direction of the vehicle can be obtained while locating the vehicle.
[0044] The present invention provides a method for counting multi-turn vehicles at an intersection, which proposes a turning spatiotemporal counting feature tSTCF based on a tilt detection frame to extract the spatiotemporal information of turning vehicles crossing the line. This feature can effectively characterize the spatiotemporal position characteristics of the vehicle relative to the counting line.
[0045] The present invention provides a method for counting vehicles with multiple turns at an intersection. A stacked long short-time recurrent neural network sLSTM is designed to process tSTCF, and the spatiotemporal features contained in tSTCF are processed and classified, and the vehicles with multiple turns are counted simultaneously based on the classification results and position information. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0047] Figure 1This is an overall flow chart of a method for counting multi-turn vehicles at an intersection according to a first embodiment of the present invention;
[0048] Figure 2 is a SCAM network structure diagram of the first embodiment of the present invention;
[0049] Figure 3 is a counting line and turning definition diagram of the first embodiment of the present invention;
[0050] Figure 4 This is a turning vehicle counting model diagram of the first embodiment of the present invention;
[0051] Figure 5 This is a flowchart of the stacked LSTM processing tSTCF features in the first embodiment of the present invention. DETAILED DESCRIPTION
[0052] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0053] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0054] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0055] Embodiment 1
[0056] like Figure 1 As shown, this embodiment provides a method for counting vehicles with multiple turns at an intersection to locate turning vehicles, and at the same time proposes a stacked short-time recursive neural network sLSTM based on the detection results to count the vehicles turning at the intersection to obtain the number of vehicles passing through each turn.
[0057] This embodiment provides a method for counting multi-turn vehicles at an intersection. Based on the intersection traffic video, a multi-turn vehicle counting model based on a deep network is studied. Figure 1 As shown in the figure, it is mainly divided into three parts: tilt frame detection, turning spatiotemporal counting feature extraction, and multi-turn vehicle counting at intersections based on sLSTM.
[0058] Step 1: Obtain intersection traffic video.
[0059] Cameras fixed on roads usually do not have a wide enough coverage for shooting at road intersections, making it difficult to obtain high-quality traffic condition videos at four intersections. However, intersection traffic videos shot by cameras based on drones can obtain a wider coverage. Therefore, the present invention counts vehicle turns at intersections based on large-scene road intersection videos shot by drones.
[0060] Preferably, a traffic scene video of an intersection taken from a high altitude by a drone is used as the traffic video data to be processed. The traffic video data is 25 frames per second. For each frame of data, a 1024*1024 pixel image is first cropped with the center of the intersection as the center point as the intersection traffic image to be processed.
[0061] Step 2: Perform multi-angle detection on the vehicle in each frame of the intersection traffic video to obtain a vehicle tilt detection frame at the intersection of each frame. Specifically, a multi-angle detection network SCAM is used when performing multi-angle detection on the vehicle in each frame.
[0062] Among them, Figure 2 As shown, the structure of the SCAM network is:
[0063] ResNet is used as the backbone network to extract the features of the input image. The forward propagation calculation of ResNet is implemented through a bottom-up path. After obtaining the {P2, P3, P4, P5} feature pyramid, the four pyramid feature maps are normalized to the size of P4, and the four layers of normalized feature maps are added together to obtain the added feature Fp.
[0064] The added features are processed to obtain a foreground enhancement feature map. Specifically, the feature Fp is further suppressed by a spatial attention module SAM based on target binary segmentation. The SAM module takes Fp as input, first obtains text information through a 3*3 convolution, and then obtains a single-channel feature weight map F1 through a 1*1 convolution operation. The single-channel feature weight map will be supervised with the binary image Fb with the target area as the foreground for learning to enhance the weight representation. The loss loss1 between F1 and the binary image Fb is used as part of the loss function of the entire detection network. F1 and Fp are pixel-level dot multiplied, and the dot multiplication result is added to Fp to obtain a foreground enhancement feature map Fs based on spatial attention.
[0065] The four pyramid feature maps {P2, P3, P4, P5} are added to Fs to obtain four enhanced pyramid feature maps {S2, S3, S4, S5} (i.e., pyramid feature maps for foreground enhancement and background suppression). The four enhanced pyramid feature maps are then aggregated by regional features (RoI Align), four pooled feature maps {L2, L3, L4, L5} are obtained, and these feature maps are merged along the channel dimension to obtain the merged feature map Ld, which is input into the channel adaptive attention module CAM. CAM first performs global average pooling, and then performs two 1*1 convolution operations to obtain the channel correlation between features, and then obtains the channel attention weight map Fc through the S function. This weight map Fc is divided into four blocks and multiplied with the four pooled feature maps {L2, L3, L4, L5} at the channel level to obtain the multiplied feature maps {Lc2, Lc3, Lc4, Lc5}, and then the sum is obtained to obtain the final feature map Fd after multi-scale, spatial attention and channel attention operations, which will be used for tilted frame detection.
[0066] The final feature map Fd obtained after the above feature extraction process is used as the input of the tilt detection module (ODM), which will be divided into two channels for full connection, and Fh is obtained to predict the four parameters (x, y, w, h) of the horizontal detection box HBB, and Fo is obtained to predict the five parameters (x, y, w, h, θ) of the tilted box OBB. The losses loss2 and loss3 generated by HBB and OBB are used as part of the loss function during network training.
[0067] The loss function L(p, c, c) of the entire network model * , v) consists of three parts, namely, loss1 target segmentation loss L1 (i.e., target segmentation loss between the feature weight map of a single channel and the binary image with the target area as the foreground), loss2 horizontal box classification loss L2, and loss3 tilted box position loss L3:
[0068] L(p,c,c * ,v)=λ1L1(A * ,A)+λ2L2(p,c)+λ3L3(v * ,v)
[0069]
[0070] L2(p,c)=-log(p)
[0071]
[0072] Among them, A is a binary image, “*” represents the true value, c is the candidate box type, p is the output confidence, v is the tilted box coordinate, λ1, λ2 and λ3 are hyperparameters and their values are set to 1, and (i, j) is the pixel coordinate.
[0073] Step 3: determine the tilt count line of each frame image, extract the spatial features of each frame image for each tilt count line, and select the spatial features of multiple frames before and after each frame image to form the spatiotemporal count features of each frame image.
[0074] As an implementation method, two vehicle counting lines are defined, the vehicle passing counting lines of 8 turns are defined, and the turning spatiotemporal counting feature tSTCF and its extraction method are designed.
[0075] (1) The method for determining the inclined counting line is as follows: first, the intersection traffic video is preprocessed so that the horizontal roads at the intersection in each frame image are horizontal and the vertical roads are vertical; then, the angle between the first counting line (counting line 1) and the horizontal direction is set to 135°, and the angle between the second counting line (counting line 2) and the horizontal direction is set to 45°, and the two counting lines are perpendicular to each other.
[0076] As described above, the traffic video data of the present invention is preprocessed to be a 1024*1024 pixel picture. After preprocessing, the traffic video data used in the present invention has the horizontal road (BD road) of the intersection basically in the horizontal direction, and the vertical road (AC road) basically in the vertical direction. If the angle changes greatly, the image is rotated and the size is set to be unified. Figure 3 Scenes or similar Figure 3 scene.
[0077] In order to count all kinds of turns, we first define the vehicle turns in various situations, such as Figure 3 As shown, the present invention counts a total of 8 turning situations, which are defined as: 1 right turn (A→B), 2 right turn (D→A), 3 right turn (B→C), 4 right turn (C→D), 5 left turn (A→D), 6 left turn (B→A), 7 left turn (D→C), and 8 left turn (C→B).
[0078] The eight steering situations of the vehicle can be fully covered by setting two tilt counting lines. Figure 3 The counting lines 1 and 2 in the image have an angle of 135° between the counting line 1 and the horizontal direction of the image, and an angle of 45° between the counting line 2 and the horizontal direction of the image. The two counting lines are perpendicular to each other.
[0079] (2) Extraction of spatiotemporal count features tSTCF
[0080] After obtaining the tilt detection frame result of the vehicle, the spatiotemporal counting feature tSTCF of each frame is extracted for counting line 1, which is recorded as tSTCF1. This feature includes the following four features of turning vehicles: 1, 4, 6, and 7, and 1 and 7 are turning from the upper right to the lower left of counting line 1, and 4 and 6 are turning from the lower left to the upper right of counting line 1; that is, the tSTCF extracted based on counting line 1 contains two directions. Similarly, the spatiotemporal counting feature tSTCF of each frame is extracted for counting line 2, which is recorded as tSTCF2. This feature includes the following four features of turning vehicles: 2, 3, 5, and 8, and 2 and 8 are turning from the lower right to the upper left of counting line 2, and 3 and 5 are turning from the upper left to the lower right of counting line 2; that is, the tSTCF extracted based on counting line 2 also contains two directions.
[0081] For count line 1, its tSTCF is extracted as follows, recorded as spatiotemporal count feature set tSTCF1.
[0082] For each frame of image detection results, select the detection frame with a tilt detection frame angle between 175° and 105°, denoted as represents the vehicle to be extracted tSTCF selected in the jth frame; is the x-axis coordinate of the upper left corner of the i-th bounding box in the j-th frame; is the y-coordinate of the upper left corner of the i-th bounding box in the j-th frame; is the width of the i-th bounding box in the j-th frame; is the height of the i-th bounding box in the j-th frame.
[0083] right The spatial features of each detection box are calculated according to the following formula
[0084]
[0085] Will according to The values are arranged in ascending order to form a set Get the first 3 values (vehicle spatial features) of the set s(j) as the spatial features of the frame (the jth frame) If there are less than 3 values, fill in the maximum value max=150.
[0086] As an implementation method, a frame before the jth frame and a frame after the jth frame are selected as extraction units to extract the spatiotemporal counting features of the jth frame for counting line 1. As shown in the following formula:
[0087]
[0088] For count line 2, its tSTCF is extracted as follows, recorded as spatiotemporal count feature set tSTCF2.
[0089] For each frame of image detection results, select the detection frame with a tilt detection frame angle between 25° and 75°, denoted as represents the vehicle to be extracted tSTCF selected in the jth frame; is the x-axis coordinate of the upper left corner of the i-th bounding box in the j-th frame; is the y-coordinate of the upper left corner of the i-th bounding box in the j-th frame; is the width of the i-th bounding box in the j-th frame; is the height of the i-th bounding box in the j-th frame.
[0090] right The spatial features of each detection box are calculated according to the following formula
[0091]
[0092] Will according to The values are arranged in ascending order to form a set Get the first 3 values (vehicle spatial features) of the set s(j) as the spatial features of the frame (the jth frame) If there are less than 3 values, fill in the maximum value max=150.
[0093] Consistent with step 1, select the frame before the jth frame and the frame after the jth frame as extraction units to extract the spatiotemporal counting features of the jth frame for counting line 2 As shown in the following formula:
[0094]
[0095] (3) tSTCF category definition
[0096] Through the above analysis, the tSTCF extracted for the two counting lines contains two directions, and the two turning directions are recorded as entering the counting line and exiting the counting line. According to this definition, the tSTCF extracted from the turning vehicles passing through the counting lines in the tSTCF1 and tSTCF2 extracted for the two counting lines are classified. The entry and exit of each counting line are defined as follows: in tSTCF1, turning from the upper right to the lower left of counting line 1 (turning 1 and 7) is defined as a type 1 entry through the counting line (entering in), and turning from the lower right to the upper left of counting line 1 (turning 4 and 6) is defined as a type 2 exit through the counting line (driving out); in tSTCF2, turning from the lower right to the upper left of counting line 2 (turning 2 and 8) is defined as a type 1 entry through the counting line (entering in), and turning from the upper left to the lower right of counting line 2 (turning 3 and 5) is defined as a type 2 exit through the counting line (driving out). That is, among all tSTCFs (including tSTCF1 and tSTCF2) extracted from all vehicles passing through the counting lines (counting lines 1 and 2) in the video, the tSTCFs defined as class 1 have turns 1, 7, 2, and 8, and the tSTCFs defined as class 2 have turns 4, 6, 3, and 5. Figure 3 As shown. The tSTCF extracted from other frames where no vehicle passes through the two counting lines is recorded as 3 categories. In summary, all tSTCF extracted from video frames are divided into three categories: the first category is that the vehicle passes through the counting line by entering the counting line, including turning 1, 7, 2, and 8; the second category is that the vehicle passes through the counting line by exiting the counting line, including turning 4, 6, 3, and 5; the third category is that no vehicle passes through the counting line.
[0097] Step 4: Based on the spatiotemporal counting features of each tilted counting line, the relationship between the vehicle and each counting line in each frame image is obtained after sLSTM processing. The vehicles on multiple turns are counted by combining the processing results and the vehicle tilt detection frames of the selected multiple frames of images.
[0098] As an implementation method, a stack-based short-time recurrent neural network sLSTM is used to process the tSTCF extracted based on the tilt detection results, classify the tSTCF, and then determine whether there are vehicles passing on different turns based on the threshold, and finally obtain the number of vehicles passing on the 8 turns at the intersection in the traffic video.
[0099] After performing multi-angle vehicle detection on the intersection video and extracting tSTCF, the present invention designs a turning vehicle counting model based on the stacked long short-term recurrent neural network sLSTM network. The designed counting model consists of three parts, including input turning spatiotemporal counting features, sLSTM network and multi-turn counter. The model takes tSTCF as input, and the sLSTM network processes tSTCF and outputs j, and then the multi-turn counter receives the output of sLSTM O j , after passing the multi-turn counter, the final counting model outputs 8 multi-turn vehicle counting results: The vehicle counting model structure is as follows Figure 4 shown.
[0100] (1) sLSTM network structure
[0101] Turning to spatiotemporal counting feature F j (Spatial and temporal counting characteristics of counting line 1 Or the spatiotemporal counting characteristics of counting line 2 ) is the input of sLSTM. The sLSTM network consists of two stacked long short-term recurrent neural network (LSTM) layers, a fully connected (FC) layer, a normalized exponential (softmax) layer and a classification (classification) layer. The two stacked LSTM layers in sLSTM have 100 hidden units each. After the FC layer and the softmax layer, there is a classification layer at the end.
[0102] tSTCF Feature F j is the input of sLSTM, F j It is a 3×3-dimensional time series feature, and the tSTCF feature F of a count line corresponding to the j-th frame image j It is directly input into the first LSTM layer, processed by the first LSTM layer, and then input into the second LSTM layer. Figure 3-5 Shows the process of LSTM layer processing STCF features: F j From f j-1 to f j+1 The features of are input into LSTM in time series. In the jth frame, LSTM uses the state of the LSTM network at the (j-1)th step and the input f j To calculate and update the state of the j-th step of LSTM; until processing f j+1 The input is used to update the state of the LSTM at step (j+1) to obtain the final output. The second LSTM layer receives the output data of the first LSTM layer and performs updates from step j-1 to step j+1 as in the first LSTM layer. Finally, the output of the stacked LSTM is obtained and then input to the subsequent fully connected layer FC. The stacked LSTM processes the tSTCF feature F j The process is as Figure 5 shown.
[0103] The turning spatiotemporal counting feature F of a counting line corresponding to the j-th frame image j Input into sLSTM, after sLSTM processes F j After processing the timing information in F jAccording to the above definition of tSTCF category, the input F j There are three categories, namely, the relationship between the vehicle and each counting line includes: the vehicle passes the counting line in an entry mode, the vehicle passes the counting line in an exit mode, and no vehicle passes the counting line. Therefore, the present invention defines the output of the sLSTM network according to the following method: j :For F j For each turning vehicle involved in the jth frame, determine whether it has passed the counting line (including counting line 1 and counting line 2). If all turning vehicles have not passed the line, then O j =1; if a turning vehicle crosses the line in the exit direction (turn 4, 6, 3, 5), then O j =2; if a turning vehicle crosses the line in the direction of entry (turn 1, 7, 2, 8), then O j =3.
[0104] Based on the above output definition, the final output of the last classification layer of the sLSTM network is O j (O j =1,2,3), the classification layer is built based on the cross entropy function and is calculated by the cross entropy loss, which is defined as,
[0105]
[0106] Among them, loss is the cross entropy loss of the classification layer; K is the number of samples, I i,j is the indicator value that the i-th tSTCF belongs to the j-th class; i,j is the output of the softmax layer and is the probability of classifying the i-th tSTCF as the j-th class.
[0107] (2) Training and testing of sLSTM network
[0108] The sLSTM network needs to learn the parameter values of the classification tSTCF through training data. The present invention performs multi-angle vehicle detection on three different intersection videos recorded by drones. After extracting tSTCF according to the tSTCF extraction method proposed by the present invention, the category value (1, 2, 3) of each tSTCF is manually labeled. A total of 10460 tSTCF feature samples were extracted through data inversion operation, including 8576 category 1 samples, 942 category 2 samples, and 942 category 3 samples. The sample sizes of the three categories are unbalanced. In order to balance samples of different categories, this paper adopts a sample amplification strategy of multiplying sample data by random weights to balance the sample sizes of the three categories, and expands the data volume of category 2 samples and category 3 samples by 6 times. Finally, 8576 category 1 samples, 5652 category 2 samples, and 5652 category 3 samples were prepared. 1 / 2 of these 19880 samples are used for training sLSTM, 1 / 4 samples are used for verification, and the remaining 1 / 4 samples are used for testing.
[0109] tSTCF feature extraction and sLSTM counting network were programmed using Matlab. sLSTM was trained and tested using Inteli7-7700 CPU. The training cLSTM network was optimized using the Adam algorithm, with the learning rate set to 0.001, the gradient threshold set to 1 to prevent gradient explosion, 100 training cycles, and 3 iterations per training cycle.
[0110] (3) Multi-turn counter
[0111] The trained sLSTM can classify the extracted tSTCF with high accuracy, and the classification result is output as O j (O j =1,2,3). The present invention designs a multi-turn counter to output the classification results. j Turn selection and accumulation of vehicles passing through the 8 turns are performed. Specifically, for each inclined counting line, the relationship between the vehicle and the counting line is determined; if the relationship between the vehicle and the counting line is that no vehicle has passed through the counting line, no counting is performed; if the relationship between the vehicle and the counting line is that the vehicle has passed through the counting line in an exiting manner or the vehicle has passed through the counting line in an entering manner, the vehicle turn is determined based on the vehicle tilt detection frame of the selected multiple frames of images, and the vehicles passing through the turn are accumulated.
[0112] For O j =1 j , indicating that no turning vehicle passed the counting line in this frame and is not counted.
[0113] If the output O j =2, it means that a turning vehicle is passing in one of the four turning directions 4, 6, 3, and 5. jFrom the tSTCF1 set, that is, for count line 1, there is a vehicle passing in one of the two directions of 4 and 6. If the F j The y value of the center point coordinate of the vehicle detection frame involved is greater than the threshold (H is the height of the input image), then there is a turning vehicle passing through counting line 1 in the 4-direction turn, then If the F j The y value of the center point coordinate of the vehicle detection frame involved is less than the threshold (H is the height of the input image), then there is a turning vehicle passing through counting line 1 in the 6-direction turn, then If the F j From the tSTCF2 set, that is, for counting line 2, there is a vehicle passing in one of the two directions 3 and 5. j The y value of the center point coordinate of the vehicle detection frame involved is greater than the threshold (H is the height of the input image), then there is a turning vehicle passing through counting line 2 in the 3-direction turn, then If the F j The y value of the center point coordinate of the vehicle detection frame involved is less than the threshold (H is the height of the input image), then there is a turning vehicle passing through counting line 2 in the 5-direction turn, then
[0114] If the output O j =3, it means that a turning vehicle is passing in one of the four turning directions 1, 7, 2, and 8. j From the tSTCF1 set, that is, for count line 1, there is a vehicle passing in one of the two directions 1 and 7. If the F j The y value of the center point coordinate of the vehicle detection frame involved is greater than the threshold (H is the height of the input image), then there is a turning vehicle passing through counting line 1 in the 7-direction turn, then If the F j The y value of the center point coordinate of the vehicle detection frame involved is less than the threshold (H is the height of the input image), then if there is a turning vehicle passing through counting line 1 in the turning direction, then If the F j From the tSTCF2 set, that is, for counting line 2, there is a vehicle passing in one of the two directions 2 and 8. j The y value of the center point coordinate of the vehicle detection frame involved is greater than the threshold (H is the height of the input image), then there is a turning vehicle passing through counting line 2 in the 8-direction turn, then If the F j The y value of the center point coordinate of the vehicle detection frame involved is less than the threshold (H is the height of the input image), then there is a turning vehicle passing through counting line 2 in the 2-direction turn, then
[0115] At this point, after the last multi-turn vehicle counter, the sLSTM-based multi-turn counting model proposed in the present invention can simultaneously count the turning vehicles in 8 turning directions at the intersection in real time.
[0116] Embodiment 2
[0117] This embodiment provides a system for counting vehicles at intersections with multiple turns, which specifically includes the following modules:
[0118] A data acquisition unit is configured to: acquire a traffic video at an intersection;
[0119] A tilt frame detection unit is configured to: perform multi-angle detection on the vehicle in each frame of the intersection traffic video to obtain a vehicle tilt detection frame for each frame;
[0120] The spatiotemporal counting feature extraction unit is configured to: determine the tilted counting line of each frame image, extract the spatial feature of each frame image for each tilted counting line, and select the spatial features of multiple frames of images before and after each frame image to form the spatiotemporal counting feature of each frame image;
[0121] The vehicle counting unit is configured to detect the relationship between the vehicle and each counting line in each frame image based on the spatiotemporal counting characteristics of each tilted counting line, and count the vehicles on multiple turns by combining the detection results with the vehicle tilt detection frames of the selected multiple frames of images.
[0122] It should be noted here that the various modules in this embodiment correspond one-to-one to the various steps in Example 1, and the specific implementation process is the same, which will not be repeated here.
[0123] Embodiment 3
[0124] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the method for counting vehicles with multiple turns at an intersection as described in the first embodiment above are implemented.
[0125] Embodiment 4
[0126] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps in the method for counting vehicles with multiple turns at an intersection as described in the first embodiment above are implemented.
[0127] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0128] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0129] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0130] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0131] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0132] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for counting vehicles with multiple turns at an intersection, characterized in that: include: Get intersection traffic video; Perform multi-angle detection on the vehicle in each frame of the intersection traffic video to obtain the vehicle tilt detection frame of each frame; Determine the tilt count line of each frame of image, extract the spatial features of each frame of image for each tilt count line, and select the spatial features of multiple frames of image before and after each frame of image to form the spatiotemporal count features of each frame of image; Based on the spatiotemporal counting characteristics of each tilted counting line, the relationship between the vehicle and each counting line in each frame image is detected, and the vehicles on multiple turns are counted by combining the detection result and the vehicle tilt detection frame of the selected multiple frames of images; The multi-angle detection adopts a multi-angle detection network, and the multi-angle detection network includes: using ResNet as a backbone network to extract features of an input image to obtain four pyramid feature maps; normalizing the four pyramid feature maps, adding the normalized feature maps to obtain added features; processing the added features to obtain a foreground enhancement feature map; adding the four pyramid feature maps to the foreground enhancement feature map to obtain four enhanced pyramid feature maps; after the four enhanced pyramid feature maps are subjected to regional feature aggregation, four pooling feature maps are obtained, and the four pooling feature maps are merged along the channel dimension to obtain a merged feature map; The multi-angle detection network also includes: the merged feature map is subjected to global average pooling, convolution operation and S function in sequence to obtain a channel attention weight map; the channel attention weight map is divided into four blocks and multiplied with four pooled feature maps at the channel level to obtain a multiplied feature map; the multiplied feature maps are summed to obtain a final feature map; the final feature map will be divided into two channels for full connection to predict the horizontal frame and the tilted frame respectively.
2. A method for counting vehicles at multiple intersections as claimed in claim 1, characterized in that: The specific steps of processing the added features are: Taking the added features as input, first obtain the text information through a 3*3 convolution, and then obtain a single-channel feature weight map through a 1*1 convolution operation; The single-channel feature weight map is multiplied with the binary image with the target area as the foreground at the pixel level, and the dot product result is added to the added features to obtain a foreground enhancement feature map.
3. A method for counting vehicles with multiple turns at an intersection as claimed in claim 2, characterized in that: The objective function of the multi-angle detection network consists of three parts, namely: the target segmentation loss between the feature weight map of the single channel and the binary image with the target area as the foreground, the classification loss of the horizontal box and the position loss of the inclined box.
4. A method for counting vehicles at multiple turns at an intersection as claimed in claim 1, characterized in that: The specific method for detecting the relationship between the vehicle and each counting line in each frame image is: The spatiotemporal counting features of a counting line are input into the stack length based short-time recurrent neural network. After the time series information in the spatiotemporal counting features is processed by the stack length based short-time recurrent neural network, the relationship between the vehicle and the counting line is obtained. The relationship between the vehicle and the counting line includes: a vehicle passes through the counting line in an entering manner, a vehicle passes through the counting line in an exiting manner, and no vehicle passes through the counting line.
5. A method for counting vehicles with multiple turns at an intersection as claimed in claim 4, characterized in that: The specific steps of counting vehicles on multiple turns are: For each inclined count line, determine the relationship between the vehicle and the count line; If the relationship between the vehicle and the counting line is that no vehicle passes through the counting line, it is not counted; If the relationship between the vehicle and the counting line is that the vehicle passes the counting line in an exiting manner or the vehicle passes the counting line in an entering manner, the vehicle turning is determined based on the vehicle tilt detection frame of the selected multiple frames of images, and the passing vehicles in the turning direction are accumulated.
6. A multi-turn vehicle counting system at an intersection, characterized in that: include: A data acquisition unit is configured to: acquire a traffic video at an intersection; A tilt frame detection unit is configured to: perform multi-angle detection on the vehicle in each frame of the intersection traffic video to obtain a vehicle tilt detection frame for each frame; The spatiotemporal counting feature extraction unit is configured to: determine the tilted counting line of each frame image, extract the spatial feature of each frame image for each tilted counting line, and select the spatial features of multiple frames of images before and after each frame image to form the spatiotemporal counting feature of each frame image; A vehicle counting unit is configured to: detect the relationship between the vehicle and each counting line in each frame image based on the spatiotemporal counting characteristics of each tilted counting line, and count the vehicles on multiple turns by combining the detection result and the vehicle tilt detection frames of the selected multiple frames of images; The multi-angle detection adopts a multi-angle detection network, and the multi-angle detection network includes: using ResNet as a backbone network to extract features of an input image to obtain four pyramid feature maps; normalizing the four pyramid feature maps, adding the normalized feature maps to obtain added features; processing the added features to obtain a foreground enhancement feature map; adding the four pyramid feature maps to the foreground enhancement feature map to obtain four enhanced pyramid feature maps; after the four enhanced pyramid feature maps are subjected to regional feature aggregation, four pooling feature maps are obtained, and the four pooling feature maps are merged along the channel dimension to obtain a merged feature map; The multi-angle detection network also includes: the merged feature map is subjected to global average pooling, convolution operation and S function in sequence to obtain a channel attention weight map; the channel attention weight map is divided into four blocks and multiplied with four pooled feature maps at the channel level to obtain a multiplied feature map; the multiplied feature maps are summed to obtain a final feature map; the final feature map will be divided into two channels for full connection to predict the horizontal frame and the tilted frame respectively.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in a method for counting multi-turn vehicles at an intersection as described in any one of claims 1-5 are implemented.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the method for counting multi-turn vehicles at an intersection as described in any one of claims 1-5 are implemented.
