Disclosure of Invention
The invention aims to solve the technical problem that a traffic flow density calculation method, a system, a terminal and a computer readable storage medium are provided, and aims to solve the problem that in the prior art, the traffic flow density condition of a detected road section cannot be determined because the track of an operation target is in a changing state at any moment and does not have fixed movement time.
The invention is realized in this way, and a traffic flow density calculation method includes:
carrying out binarization processing on a detection image acquired in a detection area to obtain a binary image;
counting the running target in the binary image by using a pixel counting method to obtain the traffic density of the detection area;
and determining the traffic density state of the detection area by adopting fuzzy traffic density according to the traffic density of the detection area.
Further, the binarizing the detection image acquired from the detection area to obtain a binary image includes:
acquiring a detection image of the detection area;
performing mixed Gaussian background modeling on the foreground image of the detection image to obtain a modeling image;
and carrying out binarization processing on the modeling image to obtain the binary image.
Further, the acquiring a detection image of the detection area includes:
determining a trapezoidal area for detection according to the shape of the lane, and taking the trapezoidal area as the detection area;
and acquiring a detection video of the detection area, and acquiring each frame of detection image in the detection video.
Further, the counting the running target in the binary image by using a pixel counting method to obtain the traffic flow density of the detection area includes:
any pixel point P in binary image of detection regioniHas a pixel value of Xi,Xi0 or Xi1, the pixel value X of the pixel region composing the operation targeti1, the total pixel value of the binary image of the detection area is SpixThe density of the traffic is rhopixAnd then:
further, the determining the traffic density state of the detection area by using the fuzzy traffic density according to the traffic density of the detection area includes:
determining the traffic density state by adopting fuzzy traffic density according to the traffic density of the detection area by utilizing a Gaussian distribution model and a 3 sigma principle;
respectively using S, U and V to represent the rare and normal states of traffic densityDensity of traffic flow, and the density of traffic flowpixThe fuzzy is { S, U, V }, and the traffic flow density rhopixThe membership function of (a) includes:
by rho1、ρ2Denotes the critical value between S and U, p3、ρ4Represents a critical value between U and V;
if fS(ρpix) The greater the traffic density ρpixThe greater the degree of S, when rhopix∈(0,ρ1) While, determining the traffic density ρpixIs S; when rhopix∈(ρ1,ρ2) While, determining the traffic density ρpixBetween S and U;
if fU(ρpix) The greater the traffic density ρpixThe greater the degree of U, when rhopix∈(ρ1,ρ2) While, determining the traffic density ρpixBetween S and U; when rhopix∈(ρ2,ρ3) While, determining the traffic density ρpixIs U; when rhopix∈(ρ3,ρ4) While, determining the traffic density ρpixBetween U and V;
if fV(ρpix) The greater the traffic density ρpixThe greater the degree of V, when rhopix∈(ρ3,ρ4) While, determining the traffic density ρpixBetween U and V; when rhopix∈(ρ41) determining the traffic density ρpixIs V.
An embodiment of the present invention further provides a traffic density calculation system, including:
the processing unit is used for carrying out binarization processing on the detection image acquired by the detection area to obtain a binary image;
the statistical unit is used for counting the running target in the binary image by using a pixel statistical method to obtain the traffic density of the detection area;
and the determining unit is used for determining the traffic density state of the detection area by adopting fuzzy traffic density according to the traffic density of the detection area.
Further, the statistical unit is specifically configured to:
any pixel point P in binary image of detection regioniHas a pixel value of Xi,Xi0 or Xi1, the pixel value X of the pixel region composing the operation targeti1, the total pixel value of the binary image of the detection area is SpixThe density of the traffic is rhopixAnd then:
further, the determining unit is specifically configured to:
determining the traffic density state by adopting fuzzy traffic density according to the traffic density of the detection area by utilizing a Gaussian distribution model and a 3 sigma principle;
respectively using S, U and V to represent three states of dilute, normal and dense traffic density states, and using traffic density rhopixThe fuzzy is { S, U, V }, and the traffic flow density rhopixThe membership function of (a) includes:
by rho1、ρ2Denotes the critical value between S and U, p3、ρ4Represents a critical value between U and V;
if fS(ρpix) The greater the traffic density ρpixThe greater the degree of S, when rhopix∈(0,ρ1) While, determining the traffic density ρpixIs S; when rhopix∈(ρ1,ρ2) While, determining the traffic density ρpixBetween S and U;
if fU(ρpix) The greater the traffic density ρpixThe greater the degree of U, when rhopix∈(ρ1,ρ2) While, determining the traffic density ρpixBetween S and U; when rhopix∈(ρ2,ρ3) While, determining the traffic density ρpixIs U; when rhopix∈(ρ3,ρ4) While, determining the traffic density ρpixBetween U and V;
if fV(ρpix) The greater the traffic density ρpixThe greater the degree of V, when rhopix∈(ρ3,ρ4) While, determining the traffic density ρpixBetween U and V; when rhopix∈(ρ41) determining the traffic density ρpixIs V.
The embodiment of the present invention further provides a terminal, which includes a memory, a processor, and a computer program stored in the memory and running on the processor, and when the processor executes the computer program, the steps in the traffic density calculation method are implemented as described above.
The embodiment of the invention also provides a readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program realizes the steps in the traffic flow density calculation method.
Compared with the prior art, the invention has the beneficial effects that: the embodiment of the invention obtains a binary image by carrying out binarization processing on a detection image collected by a detection area, obtains the traffic density of the detection area by utilizing a pixel statistical method to count the running target in the binary image, and determines the traffic density state of the detection area by adopting fuzzy traffic density according to the traffic density of the detection area. The embodiment of the invention measures the traffic density state by adopting the fuzzy traffic density, and solves the problem that the traffic density condition of the detected road section cannot be determined in the prior art.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Fig. 1 shows a traffic density calculation method provided in an embodiment of the present invention, including:
s101, carrying out binarization processing on a detection image acquired by a detection area to obtain a binary image;
s102, counting the running target in the binary image by using a pixel counting method to obtain the traffic density of the detection area;
s103, determining the traffic density state of the detection area by adopting fuzzy traffic density according to the traffic density of the detection area.
The following examples of the invention are further illustrated:
in order to reduce the influence of the areas on traffic information parameters and improve the real-time performance, a trapezoidal area is defined in the traffic scene according to the shape of a lane for detection operation, the detection area is marked as S, for example, a shadow area in fig. 2 is a detection area S, and the upper left corner of the traffic scene is set as a coordinate origin O.
a) The pixel statistics-based traffic density detection algorithm comprises the following steps:
in order to obtain the traffic flow density, the embodiment of the invention provides a traffic flow density detection algorithm based on pixel statistics, and the traffic flow density detection algorithm carries out binarization processing on a foreground image modeled by adopting a mixed Gaussian background to obtain a binary image. Specifically, the foreground image is an image of a vehicle, a person and the like in a detection image, the background image is a static background in the detection image, binarization processing is performed on the foreground after background modeling is performed to obtain a gray level image only paying attention to the vehicle and the pedestrian, the gray level image is a binary image, and any pixel point P in the binary image of the detection areaiHas a pixel value of Xi,Xi0 or Xi1. Pixel value X of pixel region constituting an operation targeti1. Setting the total pixel value of the binary image of the detection area as spixThe density of the traffic is rhopixThen, the traffic density ρ is obtained by the following equationpix。
b) Density of fuzzy traffic
Based on the above, the traffic density ρ of the kth unit time period can be obtained from the equation (1)pix. The embodiment of the invention utilizes a Gaussian distribution model and a 3 sigma principle, adopts fuzzy traffic flow density to measure the traffic flow density state, respectively uses S, U and V to represent the sparse state, the normal state and the dense state of the traffic density state, and uses the traffic flow density rho to measure the traffic flow density statepixThe ambiguity is { S, U, V }. Membership function of (2) - (4), fuzzy traffic flow densityThe graph of membership functions for degrees is shown in figure 3.
Let ρ be1、ρ2Is a critical value between S (lean) and U (normal), p3、ρ4Is a critical value between U (normal) and V (dense). As can be seen from equation (2) and fig. 3: f. ofSThe greater the traffic density ρpixThe greater the degree of belonging to S. When rhopix∈(0,ρ1) Time, traffic density ρpixIs S (dilute); when rhopix∈(ρ1,ρ2) Time, traffic density ρpixBetween S (lean) and U (normal).
As can be seen from equation (3) and fig. 3: f. ofUThe greater the traffic density ρpixThe greater the degree of belonging to U. When rhopix∈(ρ1,ρ2) Time, traffic density ρpixBetween S (dilute) and U (normal); when rhopix∈(ρ2,ρ3) Time, traffic density ρpixIs U (normal); when rhopix∈(ρ3,ρ4) Time, traffic density ρpixBetween U (normal) and V (dense).
As can be seen from equation (4) and fig. 3: f. ofVThe greater the traffic density ρpixThe greater the degree of belonging to V. When rhopix∈(ρ3,ρ4) Time, traffic density ρpixBetween U (normal) and V (dense); when rhopix∈(ρ41) determining the traffic density ρpixIs V (secret).
Fig. 4 shows a traffic density calculation system provided in an embodiment of the present invention, including:
aprocessing unit 401, configured to perform binarization processing on a detection image acquired in a detection area to obtain a binary image;
acounting unit 402, configured to count the running target in the binary image by using a pixel counting method, so as to obtain a traffic density of the detection area;
a determiningunit 403, configured to determine a traffic density state of the detection area by using the fuzzy traffic density according to the traffic density of the detection area.
Further, theprocessing unit 401 is specifically configured to:
acquiring a detection image of the detection area;
performing mixed Gaussian background modeling on the foreground image of the detection image to obtain a modeling image;
and carrying out binarization processing on the modeling image to obtain the binary image.
Further, theprocessing unit 401 is further configured to:
determining a trapezoidal area for detection according to the shape of the lane, and taking the trapezoidal area as the detection area;
and acquiring a detection video of the detection area, and acquiring each frame of detection image in the detection video.
Further, thestatistical unit 402 is specifically configured to:
any pixel point P in binary image of detection regioniHas a pixel value of Xi,Xi0 or Xi1, the pixel value X of the pixel region composing the operation targeti1, the total pixel value of the binary image of the detection area is SpixThe density of the traffic is rhopixAnd then:
further, the determiningunit 403 is specifically configured to:
determining the traffic density state by adopting fuzzy traffic density according to the traffic density of the detection area by utilizing a Gaussian distribution model and a 3 sigma principle;
respectively using S, U and V to represent three states of dilute, normal and dense traffic density states, and using traffic density rhopixThe fuzzy is { S, U, V }, and the traffic flow density rhopixThe membership function of (a) includes:
by rho1、ρ2Denotes the critical value between S and U, p3、ρ4Represents a critical value between U and V;
if fS(ρpix) The greater the traffic density ρpixThe greater the degree of S, when rhopix∈(0,ρ1) While, determining the traffic density ρpixIs S; when rhopix∈(ρ1,ρ2) While, determining the traffic density ρpixBetween S and U;
if fU(ρpix) The greater the traffic density ρpixThe greater the degree of U, when rhopix∈(ρ1,ρ2) While, determining the traffic density ρpixBetween S and U; when rhopix∈(ρ2,ρ3) While, determining the traffic density ρpixIs U; when rhopix∈(ρ3,ρ4) While, determining the traffic density ρpixBetween U and V;
if fV(ρpix) The greater the traffic density ρpixThe greater the degree of V, when rhopix∈(ρ3,ρ4) Determining the vehicleFlow density ρpixBetween U and V; when rhopix∈(ρ41) determining the traffic density ρpixIs V.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical division, and other divisions may be realized in practice, for example, a plurality of modules or components may be combined or integrated into another apparatus, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present invention is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no acts or modules are necessarily required of the invention.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In view of the above description of the method and system for calculating traffic density provided by the present invention, those skilled in the art will recognize that there may be variations in the embodiments and applications of the method and system according to the concepts of the present invention.