Method and electronic device for determining traffic congestion level
Through video image processing and target detection models, combined with the relative speed and position of vehicles, the congestion parameters of traffic roads are calculated, which solves the problem of low accuracy of traffic congestion levels in the existing technology and achieves a more accurate assessment of traffic conditions.
Patent Information
- Application Number
- CN202210197934.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-03-02
AI Technical Summary
In the existing technology, the accuracy of determining the traffic congestion level by using the average speed of vehicles or the total number of vehicles on the traffic road is low and cannot effectively reflect the traffic conditions.
By obtaining the target video image, use the target detection model (such as yolov4) to determine the relative speed and position of the vehicle, calculate the congestion parameters of the traffic road, and calculate the traffic congestion level by combining the area of the vehicle in the level detection area and the area of the level detection area to improve Accuracy of traffic congestion levels.
It improves the accuracy of traffic congestion levels, reflects traffic conditions more accurately, and helps staff take effective measures.
Smart Images

Figure CN114639036B
Abstract
Description
Background Art
[0002] Urban transportation is the link and lifeline of urban social and economic activities, and plays an extremely important role in urban economic development and the improvement of people's living standards. In recent years, with the growth of population, the rapid development of the national economy and the advancement of urbanization, coupled with the sharp increase in the number of urban vehicles, many large and medium-sized cities have experienced serious traffic congestion, which has seriously affected the improvement of residents' living standards and urban development.
[0003] In the prior art, the average speed of each vehicle or the total number of vehicles on a traffic road is used to determine the traffic congestion level of the traffic road. However, the accuracy of the traffic congestion level obtained in this way is low. Summary of the invention
[0004] In an exemplary embodiment of the present disclosure, a method for determining a traffic congestion level and an electronic device are provided to improve the accuracy of the traffic congestion level.
[0005] A first aspect of the present disclosure provides a method for determining a traffic congestion level, the method comprising:
[0006] At specified time intervals, a target video image is acquired; wherein the target video image includes a plurality of target detection areas in a traffic road;
[0007] For any target detection area in the target video image, perform the following steps:
[0008] Based on the relative speed of each vehicle in the target detection area and the total number of vehicles, determining whether traffic congestion occurs in the target detection area; wherein the relative speed of any vehicle is determined by the target video image and the previous frame of the target video image;
[0009] If it is determined that traffic congestion occurs in the target detection area, for any level detection area in the target detection area, each first vehicle in the level detection area is determined according to the position of each vehicle in the target detection area; and,
[0010] Obtaining a congestion level parameter through the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on a target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold;
[0011] The traffic congestion level of the target detection area is obtained by using the congestion level parameters of the detection areas of each level.
[0012] In this embodiment, whether traffic congestion occurs in the target detection area is determined by the relative speed of each vehicle and the total number of vehicles in the target detection area. If it is determined that traffic congestion occurs in the target detection area, then for any level detection area in the target detection area, the first vehicles in the level detection area are determined according to the positions of each vehicle in the target detection area, and then the congestion level parameter is obtained by the area of each target first vehicle in the level detection area whose relative speed is less than a preset threshold and the area of the level detection area, and the traffic congestion level of the target detection area is obtained by using the congestion level parameter of each level detection area. Therefore, in this embodiment, when it is determined that traffic congestion occurs in the target detection area by the relative speed of each vehicle and the total number of vehicles, the congestion parameter of each level detection area is then determined by the vehicle area of each target first vehicle in each level detection area in the target detection area whose relative speed is less than a preset threshold, so as to determine the traffic congestion level, thereby improving the accuracy of the traffic congestion level.
[0013] In one embodiment, the total number of vehicles in the target detection area is determined based on the target detection neural network model yolov4, and the yolov4 includes a backbone network, a spatial pyramid pooling SPP layer and a PANet network structure layer;
[0014] The first feature map obtained by the SPP layer needs to be upsampled before being input into the PANet network structure layer; and
[0015] The second feature map obtained by the fourth residual block in the backbone network needs to be subjected to upsampling and attention mechanism feature extraction operations before being input into the PANet network structure layer.
[0016] In this embodiment, an upsampling operation is performed before the first feature map is input into the PANet network structure layer, and an upsampling operation and an attention mechanism feature extraction operation are performed before the second feature map is input into the PANet network structure layer. Thus, more information about small targets can be obtained by upsampling the feature map, and the attention information of the vehicle can be extracted by the attention extraction operation, thereby improving the accuracy of vehicle recognition.
[0017] In one embodiment, the attention mechanism feature extraction operation is performed through an attention mechanism feature extraction layer, and the attention mechanism feature extraction layer includes at least one sub-feature extraction layer, and the sub-feature extraction layer includes a fully connected layer and an activation function.
[0018] In this embodiment, the extracted features are enriched by combining the fully connected layer and the activation function, thereby improving the accuracy of vehicle recognition.
[0019] In one embodiment, determining whether traffic congestion occurs in the target detection area based on the relative speed of each vehicle and the total number of vehicles in the target detection area includes:
[0020] Obtaining an average relative speed corresponding to the target detection area through the relative speeds of the vehicles in the target detection area;
[0021] Obtaining a congestion parameter based on the average relative speed and the total number of vehicles;
[0022] comparing the congestion parameter with a preset congestion threshold;
[0023] If the congestion parameter is greater than a preset congestion threshold, it is determined that traffic congestion occurs in the target detection area;
[0024] If the congestion parameter is not greater than the preset congestion threshold, it is determined that no traffic congestion occurs in the target detection area.
[0025] In this embodiment, the congestion parameter is obtained by the relative speed of each vehicle in the target detection area and the total number of vehicles, and whether the target detection area occurs is determined by the congestion parameter, so that the determined result is more accurate.
[0026] In one embodiment, the congestion parameter satisfies the following formula:
[0027]
[0028] Wherein, T is the congestion parameter, is the average relative speed, N is the total number of the vehicles, and k1 and k2 are preset weights.
[0029] In one embodiment, the relative speed of each vehicle in the target detection area is determined by:
[0030] Detecting vehicles in the target detection area using a target detection model to obtain positions of each vehicle in the target detection area;
[0031] For any vehicle, according to the position of the vehicle and the position of the vehicle in the previous frame of the target video image, the relative displacement of the vehicle is obtained;
[0032] Based on the relative displacement of the vehicle, a relative speed of the vehicle is determined.
[0033] In one embodiment, obtaining the congestion level parameter by the area of each target first vehicle in the level detection area and the area of the level detection area includes:
[0034] Adding the areas of the first target vehicles in the level detection area to obtain a total vehicle area;
[0035] The total area of the vehicles is divided by the area of the level detection area to obtain the congestion level parameter.
[0036] This embodiment obtains the congestion level parameter by the total area of vehicles and the area of the level detection area. Thus, the congestion level parameter is determined by the area ratio of each vehicle in the level detection area, thereby further improving the accuracy of the traffic congestion level.
[0037] In one embodiment, obtaining the traffic congestion level of the target detection area by using the congestion level parameters of the detection areas of each level includes:
[0038] For any level detection area, if the congestion level parameter of the level detection area is greater than the preset level parameter, it is determined that congestion occurs in the level detection area;
[0039] Using the preset correspondence between the level detection areas and the level identifiers, determine the level identifiers corresponding to the level detection areas where congestion occurs; wherein the level identifiers are used to indicate the arrangement order of the level detection areas in the target detection area;
[0040] A target level identifier that meets a specified condition is determined from the level identifiers, and the target level identifier is determined as the traffic congestion level of the target detection area.
[0041] In this embodiment, a target level identifier that meets the specified conditions is determined from each level identifier corresponding to each level detection area where congestion occurs, and the target level identifier is determined as the traffic congestion level of the target detection area. Thus, the traffic congestion level is determined by the congestion in the level detection area, thereby improving the accuracy of the traffic congestion level.
[0042] A second aspect of the present disclosure provides an electronic device, including a storage unit and a processor, wherein:
[0043] The storage unit is configured to store a target video image, wherein the target video image includes a plurality of target detection areas in a traffic road;
[0044] The processor is configured to:
[0045] Obtain the target video image at specified time intervals;
[0046] For any target detection area in the target video image, perform the following steps:
[0047] Based on the relative speed of each vehicle in the target detection area and the total number of vehicles, determining whether traffic congestion occurs in the target detection area; wherein the relative speed of any vehicle is determined by the target video image and the previous frame of the target video image;
[0048] If it is determined that traffic congestion occurs in the target detection area, for any level detection area in the target detection area, each first vehicle in the level detection area is determined according to the position of each vehicle in the target detection area; and,
[0049] Obtaining a congestion level parameter through the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on a target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold;
[0050] The traffic congestion level of the target detection area is obtained by using the congestion level parameters of the detection areas of each level.
[0051] In one embodiment, the total number of vehicles in the target detection area is determined based on the target detection neural network model yolov4, and the yolov4 includes a backbone network, a spatial pyramid pooling SPP layer and a PANet network structure layer;
[0052] The first feature map obtained by the SPP layer needs to be upsampled before being input into the PANet network structure layer; and
[0053] The second feature map obtained by the fourth residual block in the backbone network needs to be subjected to upsampling and attention mechanism feature extraction operations before being input into the PANet network structure layer.
[0054] In one embodiment, the attention mechanism feature extraction operation is performed through an attention mechanism feature extraction layer, and the attention mechanism feature extraction layer includes at least one sub-feature extraction layer, and the sub-feature extraction layer includes a fully connected layer and an activation function.
[0055] In one embodiment, the processor performs the step of determining whether traffic congestion occurs in the target detection area based on the relative speed of each vehicle and the total number of vehicles in the target detection area, and is specifically configured as follows:
[0056] Obtaining an average relative speed corresponding to the target detection area through the relative speeds of the vehicles in the target detection area;
[0057] Obtaining a congestion parameter based on the average relative speed and the total number of vehicles;
[0058] comparing the congestion parameter with a preset congestion threshold;
[0059] If the congestion parameter is greater than a preset congestion threshold, it is determined that traffic congestion occurs in the target detection area;
[0060] If the congestion parameter is not greater than the preset congestion threshold, it is determined that no traffic congestion occurs in the target detection area.
[0061] In one embodiment, the processor is further configured to:
[0062] The congestion parameter satisfies the following formula:
[0063]
[0064] Wherein, T is the congestion parameter, is the average relative speed, N is the total number of the vehicles, and k1 and k2 are preset weights.
[0065] In one embodiment, the processor is further configured to:
[0066] The relative speed of each vehicle in the target detection area is determined by:
[0067] Detecting vehicles in the target detection area using a target detection model to obtain positions of each vehicle in the target detection area;
[0068] For any vehicle, according to the position of the vehicle and the position of the vehicle in the previous frame of the target video image, the relative displacement of the vehicle is obtained;
[0069] Based on the relative displacement of the vehicle, a relative speed of the vehicle is determined.
[0070] In one embodiment, the processor executes the step of passing the area of each target first vehicle in the level detection area and the area of the level detection area to obtain a congestion level parameter, which is specifically configured as follows:
[0071] Adding the areas of the first target vehicles in the level detection area to obtain a total vehicle area;
[0072] The total area of the vehicles is divided by the area of the level detection area to obtain the congestion level parameter.
[0073] In one embodiment, the processor executes the method of using the congestion level parameters of the detection areas of each level to obtain the traffic congestion level of the target detection area, and is specifically configured as follows:
[0074] For any level detection area, if the congestion level parameter of the level detection area is greater than the preset level parameter, it is determined that congestion occurs in the level detection area;
[0075] Using the preset correspondence between the level detection areas and the level identifiers, determine the level identifiers corresponding to the level detection areas where congestion occurs; wherein the level identifiers are used to indicate the arrangement order of the level detection areas in the target detection area;
[0076] A target level identifier that meets a specified condition is determined from the level identifiers, and the target level identifier is determined as the traffic congestion level of the target detection area.
[0077] According to a third aspect provided by an embodiment of the present disclosure, a computer storage medium is provided, wherein the computer storage medium stores a computer program, and the computer program is used to execute the method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0079] Figure 1 A schematic diagram of an applicable scenario in an embodiment of the present disclosure;
[0080] Figure 2 This is one of the flowcharts of a method for determining a traffic congestion level according to an embodiment of the present disclosure;
[0081] Figure 3 It is a schematic diagram of the structure of the target detection neural network model yolov4 according to one embodiment of the present disclosure;
[0082] Figure 4 A schematic diagram of the structure of an attention mechanism feature extraction layer according to an embodiment of the present disclosure;
[0083] Figure 5 is a schematic diagram of a target video image according to an embodiment of the present disclosure;
[0084] Figure 6 is a schematic diagram of a target detection area according to an embodiment of the present disclosure;
[0085] Figure 7 A schematic diagram of a process for determining whether traffic congestion occurs in a target detection area according to an embodiment of the present disclosure;
[0086] Figure 8 The third flowchart of the method for determining the traffic congestion level according to an embodiment of the present disclosure;
[0087] Fig. 9 A device for determining a traffic congestion level according to an embodiment of the present disclosure;
[0088] Fig.10 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0089] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0090] In the embodiments of the present disclosure, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0091] The application scenarios described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure, and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems. In the description of the present disclosure, unless otherwise specified, the meaning of "multiple" is two or more.
[0092] The present disclosure provides a method for determining the level of traffic congestion, wherein the relative speed of each vehicle in the target detection area and the total number of vehicles are used to determine whether the target detection area has traffic congestion. If it is determined that the target detection area has traffic congestion, then for any level detection area in the target detection area, according to the position of each vehicle in the target detection area, each first vehicle in the level detection area is determined, and then the area of each target first vehicle in the level detection area whose relative speed is less than a preset threshold and the area of the level detection area are used to obtain the congestion level parameter, and the traffic congestion level of the target detection area is obtained by using the congestion level parameter of each level detection area. Thus, the present disclosure determines that the target detection area has traffic congestion by the relative speed of each vehicle and the total number of vehicles, and then determines the congestion parameter of each level detection area by the vehicle area of each target first vehicle in each level detection area in the target detection area whose relative speed is less than a preset threshold, thereby determining the traffic congestion level, thereby improving the accuracy of the traffic congestion level. Below, the scheme of the present disclosure is described in detail in conjunction with the accompanying drawings.
[0093] like Figure 1 As shown, an application scenario of a method for determining a traffic congestion level includes a terminal device 110, a server 120 and a camera 130. Figure 1 In the example, one camera 130 is used, but the number of cameras 130 is not limited. The terminal device 110 may be a mobile phone, a tablet computer, a personal computer, etc. The server 120 may be implemented by a single server or multiple servers. The server 120 may be implemented by a physical server or a virtual server.
[0094] In a possible application scenario, the camera 130 captures a target video of a traffic road in real time, and the server 120 obtains a target video image of the target video from the camera 130 at specified intervals, and performs the following steps for any target detection area in the target video image: determining whether traffic congestion occurs in the target detection area based on the relative speed of each vehicle in the target detection area and the total number of vehicles; wherein the relative speed of any vehicle is determined by the target video image and the previous frame of the target video image; then if the server 120 determines that traffic congestion occurs in the target detection area, for any level detection area in the target detection area, determining each first vehicle in the level detection area according to the position of each vehicle in the target detection area; and obtaining a congestion level parameter by using the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on a target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold; the server 120 obtains the traffic congestion level of the target detection area by using the congestion level parameters of each level detection area. Finally, the traffic congestion level of the target detection area is sent to the terminal device 110 for display.
[0095] like Figure 2 FIG. 1 is a flow chart of a method for determining a traffic congestion level according to the present disclosure, which may include the following steps:
[0096] Step 201: acquiring a target video image at specified intervals; wherein the target video image includes a plurality of target detection areas in a traffic road;
[0097] It should be noted that the specified duration in this embodiment can be set according to actual conditions, and this embodiment does not limit this, and multiple target detection areas in the same target video image belong to one or more traffic roads.
[0098] Step 202: for any target detection area in the target video image, perform the following steps: determine whether traffic congestion occurs in the target detection area based on the relative speed of each vehicle in the target detection area and the total number of vehicles; wherein the relative speed of any vehicle is determined by the target video image and the previous frame of the target video image;
[0099] It should be noted that the position of the target detection area is preset, and the relative speed of any vehicle is the speed of the vehicle in the target video image relative to the speed of the vehicle in the previous frame of the target video image.
[0100] In one embodiment, the total number of vehicles in the target detection area is determined based on the target detection neural network model yolov4, and the yolov4 includes a backbone network, a spatial pyramid pooling SPP layer and a PANet network structure layer; the first feature map obtained by the SPP layer needs to be upsampled before being input into the PANet network structure layer; and the second feature map obtained by the fourth residual block in the backbone network needs to be upsampled and subjected to attention mechanism feature extraction before being input into the PANet network structure layer.
[0101] The total number of vehicles in the target detection area is determined in the following way:
[0102] The target detection neural network model yolov4 is used to detect the vehicles in the target detection area to obtain the position of each vehicle in the target detection area, and then based on the position of each vehicle in the target detection area, the total number of vehicles in the target detection area is determined.
[0103] It should be noted that the upsampling operation in this embodiment is performed in an unsampling manner.
[0104] like Figure 3 As shown in FIG. 1 , it is a schematic diagram of the structure of the improved yolov4 of the present invention, which includes a backbone network, an SPP module (SPATIAL Pyramid Pooling, spatial pyramid pooling), a PANet network structure layer and a detection layer.
[0105] Among them, the backbone network in this embodiment is CSPdarknet53. The backbone network is mainly used to extract features from the target image in this embodiment. CSPDarknet53 fuses the upper and lower feature maps during detection. The high-level network features provide high-level semantic information of the target in complex scenes, and the low-level network features provide the target position and multi-scale information in complex scenes. The output of the backbone network is divided into three branches, and the size of the feature map output by each branch is different. Among them, the second feature map obtained by the fourth residual block in the backbone network needs to be upsampled by unsampling before being input into the PANet network structure layer, and then the attention mechanism feature extraction operation is performed through the attention mechanism feature extraction layer. Make the determined features richer.
[0106] Three pooling layers of different sizes are used in the SPP module to perform pooling operations on the feature maps extracted by the backbone network. That is, the feature maps extracted by the backbone network are pooled using non-local image expansion pooling layers of 5*5, 9*9 and 15*15 sizes, and then the feature maps output by each pooling layer of the fully connected layer are spliced to obtain the first feature map, which is then upsampled by unsampling and input into the PANet network structure layer. This makes the determined features richer.
[0107] The PANet network structure layer mainly performs upsampling or downsampling on the feature maps obtained from each branch, and then uses the fully connected layer to splice the upsampled and downsampled feature maps, and then uses the convolution layer to perform dimensionality reduction. Three feature maps are obtained.
[0108] The detection layer performs vehicle recognition on the three feature maps obtained in the PANet network structure layer to obtain the final recognition result.
[0109] In order to improve the accuracy of vehicle recognition, in one embodiment, the attention mechanism feature extraction operation is performed through an attention mechanism feature extraction layer, and the attention mechanism feature extraction layer includes at least one sub-feature extraction layer, and the sub-feature extraction layer includes a fully connected layer and an activation function.
[0110] For example, Figure 4 As shown, it is a structural diagram of the attention mechanism feature extraction layer, which includes two sub-feature extraction layers in this embodiment, wherein each sub-feature extraction layer includes a fully connected layer and an activation function, and the activation function of the first sub-feature extraction layer in this implementation is the Rule activation function, and the activation function of the other sub-feature extraction layer is the sigmoid activation function.
[0111] It should be noted that: this embodiment uses two sub-feature extraction layers as an example, and does not limit the number of sub-feature extraction layers in the attention mechanism feature extraction layer in this embodiment. The number of sub-feature extraction layers can be set according to actual conditions, and this embodiment does not limit it here. In addition, the activation function in the sub-feature extraction layer can be selected and set according to actual conditions, and this embodiment does not limit it here.
[0112] In one embodiment, the relative speed of each vehicle in the target detection area is determined by: using the target detection neural network model yolov4 to detect the vehicles in the target detection area, and obtaining the position of each vehicle in the target detection area; for any vehicle, according to the position of the vehicle and the position of the vehicle in the previous frame of the target video image, the relative displacement of the vehicle is obtained; based on the relative displacement of the vehicle, the relative speed of the vehicle is determined. The relative displacement of the vehicle can be determined by formula (1):
[0113]
[0114] Among them, S 相 is the relative displacement of the vehicle, x1 is the horizontal coordinate of the position of the vehicle in the target video image, y1 is the vertical coordinate of the position of the vehicle in the target video image, x2 is the horizontal coordinate of the position of the vehicle in the previous frame of the target video image, y2 is the vertical coordinate of the position of the vehicle in the previous frame of the target video image, and N is the frame number difference between the target video image and the previous frame.
[0115] It should be noted that: in this embodiment, the tracking algorithm is used to obtain the identification of each vehicle, so as to obtain the position of the same vehicle in different frames of video images. The tracking algorithm in this embodiment can be set according to specific actual conditions, and this embodiment is not limited here.
[0116] After determining the relative displacement of the vehicle, the relative speed of the vehicle can be determined by formula (2):
[0117]
[0118] Among them, v 相 is the relative speed of the vehicle, s 相 is the relative displacement of the vehicle, and t is the specified time duration.
[0119] Step 203: if it is determined that traffic congestion occurs in the target detection area, for any level detection area in the target detection area, determine each first vehicle in the level detection area according to the position of each vehicle in the target detection area;
[0120] It should be noted that the level detection areas in the target detection area are pre-set, and the data of the target detection area and the number of the level detection areas can be set according to actual conditions, which are not limited in this embodiment.
[0121] For example, Figure 5 As shown, Figure 5 is a schematic diagram of the target video image. Figure 5There are two traffic roads and three target detection areas in total, wherein each detection area includes three level detection areas. Since the position range of the level detection area is pre-set, the position of each vehicle in the target detection area can be compared with the position of each level detection area respectively to determine each first vehicle in each level detection area.
[0122] Step 204: Obtaining a congestion level parameter through the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on a target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold;
[0123] In one embodiment, the congestion level parameter is determined by: adding the areas of each target first vehicle in the level detection area to obtain a total vehicle area; dividing the total vehicle area by the area of the level detection area to obtain the congestion level parameter.
[0124] The area of each target first vehicle in the level detection region is the area of the bounding box of the target first vehicle obtained by the target detection model. The size of the level detection region is preset, so the area of the level detection region can be determined according to the size of the level detection region.
[0125] Step 205: Obtain the traffic congestion level of the target detection area by using the congestion level parameters of the detection areas of each level.
[0126] In one embodiment, the traffic congestion level of the target detection area can be determined in the following manner: for any level detection area, if the congestion level parameter of the level detection area is greater than the preset level parameter, it is determined that the level detection area is congested; using the preset correspondence between the level detection area and the level identifier, determine the level identifiers corresponding to the level detection areas where congestion occurs; wherein the level identifier is used to indicate the arrangement order of the level detection area in the target detection area; determine the target level identifier that meets the specified conditions from the level identifiers, and determine the target level identifier as the traffic congestion level of the target detection area. The correspondence between the level detection area and the level identifier is shown in Table 1:
[0127] Level detection area Grade identification Level detection area A 1 Level detection area B 2 Level detection area C 3 … …
[0128] Table 1
[0129] It should be noted that the specified condition in this embodiment may be the largest level identifier among the level identifiers or the smallest level identifier among the level identifiers.
[0130] For example, the specified condition is the largest level identifier among all level identifiers. Figure 6 As shown, it is a target detection area in the target video detection image, and the target detection area includes three level detection areas, namely: level detection area A, level detection area B and level detection area C. If the congestion level parameters of level detection area A and level detection area B are both greater than the preset level parameters, but the congestion level parameter of level detection area C is less than the preset level parameter, it is determined that level detection area A and level detection area B are congested. Then, using the corresponding relationship in Table 1, it is determined that the level identification corresponding to level detection area A is 1, and the level identification corresponding to level detection area B is 2. Since the level identification of level detection area B is the target level identification, the traffic congestion level of the target detection area is determined to be level 2.
[0131] After determining the traffic congestion level, the last determined traffic congestion level of the target detection area can be obtained and compared with the current determined traffic congestion level. If the current traffic congestion level is greater than the previous traffic congestion level, it is determined that the congestion in the target detection area is increasing. If the current traffic congestion level is less than the previous traffic congestion level, it is determined that the congestion in the target detection area is dissipating. In this way, the staff can be reminded to take corresponding measures.
[0132] like Figure 7 As shown, a flow chart for determining whether traffic congestion occurs in a target detection area may include the following steps:
[0133] Step 701: Obtain an average relative speed corresponding to the target detection area by the relative speed of each vehicle in the target detection area; wherein the average relative speed can be obtained by formula (3):
[0134]
[0135] in, is the average relative velocity, v i is the relative speed of the i-th vehicle in the target detection area, and n is the relative speed of each vehicle in the target detection area.
[0136] Step 702: Based on the average relative speed and the total number of vehicles, a congestion parameter is obtained; wherein the congestion parameter can be determined by formula (4):
[0137]
[0138] Wherein, T is the congestion parameter, is the average relative speed, N is the total number of the vehicles, and k1 and k2 are preset weights.
[0139] Step 703: Compare the congestion parameter with a preset congestion threshold;
[0140] Step 704 determines whether the congestion parameter is greater than a preset congestion threshold, if so, executes step 705, if not, executes step 706;
[0141] Step 705: Determine that traffic congestion occurs in the target detection area;
[0142] Step 706: Determine that there is no traffic congestion in the target detection area.
[0143] In order to further understand the technical solution of the present disclosure, Figure 8 A detailed description may include the following steps:
[0144] Step 801: acquiring a target video image at specified time intervals; wherein the target video image includes a plurality of target detection areas in a traffic road;
[0145] Step 802: for any target detection area in the target video image, perform the following steps: obtain an average relative speed corresponding to the target detection area through the relative speeds of each vehicle in the target detection area;
[0146] Step 803: Obtaining a congestion parameter based on the average relative speed and the total number of vehicles;
[0147] Step 804: Compare the congestion parameter with a preset congestion threshold;
[0148] Step 805: Determine whether the congestion parameter is greater than a preset congestion threshold, if so, execute step 806, if not, execute step 811;
[0149] Step 806: for any level detection area in the target detection area, determining each first vehicle in the level detection area according to the position of each vehicle in the target detection area;
[0150] Step 807: Obtaining a congestion level parameter through the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on a target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold;
[0151] Step 808: For any level detection area, if the congestion level parameter of the level detection area is greater than a preset level parameter, it is determined that congestion occurs in the level detection area;
[0152] Step 809: using the preset correspondence between the level detection areas and the level identifiers, determining the level identifiers corresponding to the level detection areas where congestion occurs; wherein the level identifiers are used to indicate the arrangement order of the level detection areas in the target detection area;
[0153] Step 810: determining a target level identifier that meets a specified condition from the level identifiers, and determining the target level identifier as the traffic congestion level of the target detection area;
[0154] Step 811: Determine that there is no traffic congestion in the target detection area.
[0155] Based on the same disclosure concept, the method for determining the traffic congestion level described above in the present disclosure can also be implemented by a device for determining the traffic congestion level. The effect of the device for determining the traffic congestion level is similar to that of the aforementioned method, and will not be described in detail here.
[0156] Fig. 9 The figure is a schematic diagram of the structure of a device for determining a traffic congestion level according to an embodiment of the present disclosure.
[0157] like Fig. 9 As shown, the apparatus 900 for determining a traffic congestion level of the present disclosure may include a target video image determination module 910 , a traffic congestion determination module 920 , a first vehicle determination module 930 , a congestion level parameter determination module 940 and a traffic congestion level determination module 950 .
[0158] The target video image determination module 910 is used to obtain a target video image at a specified time interval; wherein the target video image includes a plurality of target detection areas in the traffic road;
[0159] The traffic congestion determination module 920 is used to perform the following steps for any target detection area in the target video image: based on the relative speed of each vehicle in the target detection area and the total number of vehicles, determine whether traffic congestion occurs in the target detection area; wherein the relative speed of any vehicle is determined by the target video image and the previous frame of the target video image;
[0160] The first vehicle determination module 930 is configured to determine, if it is determined that traffic congestion occurs in the target detection area, for any level detection area in the target detection area, the first vehicles in the level detection area according to the positions of the vehicles in the target detection area; and
[0161] The congestion level parameter determination module 940 is used to obtain the congestion level parameter according to the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on the target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold;
[0162] The traffic congestion level determination module 950 is used to obtain the traffic congestion level of the target detection area by using the congestion level parameters of the detection areas of each level.
[0163] In one embodiment, the total number of vehicles in the target detection area is determined based on the target detection neural network model yolov4, and the yolov4 includes a backbone network, a spatial pyramid pooling SPP layer and a PANet network structure layer;
[0164] The first feature map obtained by the SPP layer needs to be upsampled before being input into the PANet network structure layer; and
[0165] The second feature map obtained by the fourth residual block in the backbone network needs to be subjected to upsampling and attention mechanism feature extraction operations before being input into the PANet network structure layer.
[0166] In one embodiment, the attention mechanism feature extraction operation is performed through an attention mechanism feature extraction layer, and the attention mechanism feature extraction layer includes at least one sub-feature extraction layer, and the sub-feature extraction layer includes a fully connected layer and an activation function.
[0167] In one embodiment, the traffic congestion determination module 920 is specifically configured to:
[0168] Obtaining an average relative speed corresponding to the target detection area through the relative speeds of the vehicles in the target detection area;
[0169] Obtaining a congestion parameter based on the average relative speed and the total number of vehicles;
[0170] comparing the congestion parameter with a preset congestion threshold;
[0171] If the congestion parameter is greater than a preset congestion threshold, it is determined that traffic congestion occurs in the target detection area;
[0172] If the congestion parameter is not greater than the preset congestion threshold, it is determined that no traffic congestion occurs in the target detection area.
[0173] In one embodiment, the apparatus further comprises:
[0174] The congestion parameter determination module 960 is used for the congestion parameter to satisfy the following formula:
[0175]
[0176] Wherein, T is the congestion parameter, is the average relative speed, N is the total number of the vehicles, and k1 and k2 are preset weights.
[0177] In one embodiment, the apparatus further comprises:
[0178] The relative speed determination module 970 is used to determine the relative speed of each vehicle in the target detection area by:
[0179] Detecting vehicles in the target detection area using a target detection model to obtain positions of each vehicle in the target detection area;
[0180] For any vehicle, according to the position of the vehicle and the position of the vehicle in the previous frame of the target video image, the relative displacement of the vehicle is obtained;
[0181] Based on the relative displacement of the vehicle, a relative speed of the vehicle is determined.
[0182] In one embodiment, the congestion level parameter determination module 940 is specifically configured to:
[0183] Adding the areas of the first target vehicles in the level detection area to obtain a total vehicle area;
[0184] The total area of the vehicles is divided by the area of the level detection area to obtain the congestion level parameter.
[0185] In one embodiment, the traffic congestion level determination module 950 is specifically configured to:
[0186] For any level detection area, if the congestion level parameter of the level detection area is greater than the preset level parameter, it is determined that congestion occurs in the level detection area;
[0187] Using the preset correspondence between the level detection areas and the level identifiers, determine the level identifiers corresponding to the level detection areas where congestion occurs; wherein the level identifiers are used to indicate the arrangement order of the level detection areas in the target detection area;
[0188] A target level identifier that meets a specified condition is determined from the level identifiers, and the target level identifier is determined as the traffic congestion level of the target detection area.
[0189] After introducing a method and an apparatus for determining a traffic congestion level according to an exemplary embodiment of the present disclosure, next, an electronic device according to another exemplary embodiment of the present disclosure is introduced.
[0190] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0191] In some possible implementations, the electronic device according to the present disclosure may include at least one processor and at least one computer storage medium. The computer storage medium stores program code, and when the program code is executed by the processor, the processor executes the steps in the method for determining the traffic congestion level according to various exemplary embodiments of the present disclosure described above in this specification. For example, the processor may execute the following steps: Figure 2 Steps 201-206 shown in .
[0192] Refer to the following Fig.10 The electronic device 1000 according to this embodiment of the present disclosure is described. Fig.10 The electronic device 1000 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0193] like Fig.10 As shown, the electronic device 1000 is in the form of a general electronic device. The components of the electronic device 1000 may include but are not limited to: the at least one processor 1001, the at least one computer storage medium 1002, and a bus 1003 connecting different system components (including the computer storage medium 1002 and the processor 1001).
[0194] Bus 1003 represents one or more of several types of bus structures, including a computer storage media bus or computer storage media controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.
[0195] The computer storage medium 1002 may include readable media in the form of volatile computer storage media, such as random access computer storage media (RAM) 1021 and / or cache storage media 1022 , and may further include read-only computer storage media (ROM) 1023 .
[0196] The computer storage medium 1002 may also include a program / utility 1025 having a set (at least one) of program modules 1024, such program modules 1024 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0197] The electronic device 1000 may also communicate with one or more external devices 1004 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or communicate with any device that enables the electronic device 1000 to communicate with one or more other electronic devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1005. Furthermore, the electronic device 1000 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1006. As shown, the network adapter 1006 communicates with other modules for the electronic device 1000 via a bus 1003. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0198] In some possible implementations, various aspects of a method for determining a traffic congestion level provided by the present disclosure may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the method for determining a traffic congestion level according to various exemplary embodiments of the present disclosure described above in this specification.
[0199] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access computer storage medium (RAM), a read-only computer storage medium (ROM), an erasable programmable read-only computer storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only computer storage medium (CD-ROM), an optical computer storage medium, a magnetic computer storage medium, or any suitable combination of the above.
[0200] The program product for determining the traffic congestion level of the embodiment of the present disclosure may adopt a portable compact disk read-only computer storage medium (CD-ROM) and include program code, and may be run on an electronic device. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0201] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0202] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0203] Program code for performing the disclosed operations may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user electronic device, partially on the user device, as a separate software package, partially on the user electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In the case of a remote electronic device, the remote electronic device may be connected to the user electronic device via any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external electronic device (e.g., via the Internet using an Internet service provider).
[0204] It should be noted that although several modules of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules described above can be embodied in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be embodied.
[0205] In addition, although the operations of the disclosed method are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0206] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk computer storage media, CD-ROM, optical computer storage media, etc.) containing computer-usable program codes.
[0207] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. 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.
[0208] These computer program instructions may also be stored in a computer-readable computer storage medium that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable computer storage medium produce a manufactured product including 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.
[0209] 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. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0210] Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.
Claims
1. A method for determining a traffic congestion level, characterized in that: The method comprises: At specified time intervals, a target video image is acquired; wherein the target video image includes a plurality of target detection areas in a traffic road; For any target detection area in the target video image, perform the following steps: Based on the relative speed of each vehicle in the target detection area and the total number of vehicles, determining whether traffic congestion occurs in the target detection area; wherein the relative speed of any vehicle is determined by the target video image and the previous frame of the target video image; If it is determined that traffic congestion occurs in the target detection area, for any level detection area in the target detection area, each first vehicle in the level detection area is determined according to the position of each vehicle in the target detection area; and, Obtaining a congestion level parameter through the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on a target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold; The traffic congestion level of the target detection area is obtained by using the congestion level parameters of each level detection area; wherein, the traffic congestion level of the target detection area is obtained by using the congestion level parameters of each level detection area, including: for any level detection area, if the congestion level parameter of the level detection area is greater than the preset level parameter, it is determined that the level detection area is congested; using the correspondence between the preset level detection areas and the level identifiers, the level identifiers corresponding to the level detection areas where congestion occurs are determined; wherein the level identifiers are used to indicate the arrangement order of the positions of the level detection areas in the target detection area; from the level identifiers, a target level identifier that meets the specified conditions is determined, and the target level identifier is determined as the traffic congestion level of the target detection area; if the current traffic congestion level of the target detection area is greater than the previous traffic congestion level of the target detection area, it is determined that the congestion in the target detection area is increasing; if the current traffic congestion level of the target detection area is less than the previous traffic congestion level of the target detection area, it is determined that the congestion in the target detection area is dissipating.
2. The method according to claim 1, characterized in that: The total number of vehicles in the target detection area is determined based on the target detection neural network model yolov4, and the yolov4 includes a backbone network, a spatial pyramid pooling SPP layer and a PANet network structure layer; The first feature map obtained by the SPP layer needs to be upsampled before being input into the PANet network structure layer; and The second feature map obtained by the fourth residual block in the backbone network needs to be subjected to upsampling and attention mechanism feature extraction operations before being input into the PANet network structure layer.
3. The method according to claim 2, characterized in that The attention mechanism feature extraction operation is performed through an attention mechanism feature extraction layer, and the attention mechanism feature extraction layer includes at least one sub-feature extraction layer, and the sub-feature extraction layer includes a fully connected layer and an activation function.
4. The method according to claim 1, characterized in that: The determining whether traffic congestion occurs in the target detection area based on the relative speed of each vehicle and the total number of vehicles in the target detection area includes: Obtaining an average relative speed corresponding to the target detection area through the relative speeds of the vehicles in the target detection area; Obtaining a congestion parameter based on the average relative speed and the total number of vehicles; comparing the congestion parameter with a preset congestion threshold; If the congestion parameter is greater than a preset congestion threshold, it is determined that traffic congestion occurs in the target detection area; If the congestion parameter is not greater than the preset congestion threshold, it is determined that no traffic congestion occurs in the target detection area.
5. The method according to claim 4, characterized in that The congestion parameter satisfies the following formula: ; in, is the congestion parameter, is the average relative velocity, is the total number of vehicles, , The preset weights.
6. The method according to claim 1 or 4, characterized in that: The relative speed of each vehicle in the target detection area is determined by: Detecting vehicles in the target detection area using a target detection model to obtain positions of each vehicle in the target detection area; For any vehicle, according to the position of the vehicle and the position of the vehicle in the previous frame of the target video image, the relative displacement of the vehicle is obtained; Based on the relative displacement of the vehicle, a relative speed of the vehicle is determined.
7. The method according to claim 1, characterized in that The obtaining of the congestion level parameter by using the area of each target first vehicle in the level detection area and the area of the level detection area includes: Adding the areas of the first target vehicles in the level detection area to obtain a total vehicle area; The total area of the vehicles is divided by the area of the level detection area to obtain the congestion level parameter.
8. An electronic device, characterized in that: The device comprises a storage unit and a processor, wherein: The storage unit is configured to store a target video image, wherein the target video image includes a plurality of target detection areas in a traffic road; The processor is configured to: Obtain the target video image at specified time intervals; For any target detection area in the target video image, perform the following steps: Based on the relative speed of each vehicle in the target detection area and the total number of vehicles, determining whether traffic congestion occurs in the target detection area; wherein the relative speed of any vehicle is determined by the target video image and the previous frame of the target video image; If it is determined that traffic congestion occurs in the target detection area, for any level detection area in the target detection area, each first vehicle in the level detection area is determined according to the position of each vehicle in the target detection area; and, Obtaining a congestion level parameter through the area of each target first vehicle in the level detection area and the area of the level detection area; wherein the position of each vehicle and the area of the target first vehicle in the level detection area are determined based on a target detection model, and the target first vehicle is a first vehicle whose relative speed is less than a preset threshold; The traffic congestion level of the target detection area is obtained by using the congestion level parameters of each level detection area; wherein, the traffic congestion level of the target detection area is obtained by using the congestion level parameters of each level detection area, including: for any level detection area, if the congestion level parameter of the level detection area is greater than the preset level parameter, it is determined that the level detection area is congested; using the correspondence between the preset level detection areas and the level identifiers, the level identifiers corresponding to the level detection areas where congestion occurs are determined; wherein the level identifiers are used to indicate the arrangement order of the positions of the level detection areas in the target detection area; from the level identifiers, a target level identifier that meets the specified conditions is determined, and the target level identifier is determined as the traffic congestion level of the target detection area; if the current traffic congestion level of the target detection area is greater than the previous traffic congestion level of the target detection area, it is determined that the congestion in the target detection area is increasing; if the current traffic congestion level of the target detection area is less than the previous traffic congestion level of the target detection area, it is determined that the congestion in the target detection area is dissipating.
9. The electronic device according to claim 8, characterized in that: The total number of vehicles in the target detection area is determined based on the target detection neural network model yolov4, and the yolov4 includes a backbone network, a spatial pyramid pooling SPP layer and a PANet network structure layer; The first feature map obtained by the SPP layer needs to be upsampled before being input into the PANet network structure layer; and The second feature map obtained by the fourth residual block in the backbone network needs to be subjected to upsampling and attention mechanism feature extraction operations before being input into the PANet network structure layer.
