In-road irregular parking identification method based on video data
Technical Field
The invention relates to the technical field of in-road parking identification, in particular to an in-road irregular parking identification method based on video data.
Background
The number of motor vehicles has also increased dramatically due to the increasing speed of urban modernization and the rapid increase of urban population. With the increasing number of automobiles, problems related to urban traffic, such as illegal parking, parking dispute and the like, become more serious, and the on-road parking is a typical problem.
The manual management of parking spaces in roads has a lot of disadvantages, and managers often make ambiguous decisions and contradictions with vehicle owners, even cause discordant negative effects. Good in-road parking management is of great importance to road traffic, and only by finding out the existing parking problem and solving the specific problem, in-road parking can be managed, so that a clean and smooth urban road is built.
At present, the parking management of the traditional parking lot does not pay attention to the state of a parking vehicle, and particularly the parking state of a large parking lot cannot be monitored in time. Meanwhile, some car owners lack the consciousness of the car owners, so that illegal parking behaviors are generated, the behaviors not only influence the normal parking of other car owners to cause the waste of parking resources, but also increase the difficulty of parking management. Accidents such as parking scraping can be induced, and the urban civilization image is damaged.
At present, a large number of video monitoring devices are applied in the field of intelligent transportation, and video data comprise a large amount of parking data information and can be combined with different scenes to identify specific vehicle behaviors. In short, the intelligent application research of the on-road parking management plays a significant role in the development of intelligent transportation systems. The exploration of the irregular parking behavior identification method has great significance for the development of the intelligent in-road parking management system based on video data.
Disclosure of Invention
The invention aims to provide an in-road irregular parking recognition method based on video data, which is characterized in that an irregular parking behavior classification rule is constructed by a principle method and a key technology for analyzing a vehicle parking behavior by utilizing monitoring video information, and a vehicle feature extraction method based on the video data is provided, so that the automatic recognition of the parking behavior is realized, the intelligent management level of a parking lot is improved, and the intelligent parking application range is expanded.
In order to realize the purpose of the invention, the invention adopts the following technical scheme: an in-road irregular parking identification method based on video data comprises the following steps: step 1, vehicle detection, which specifically comprises the following operations: a visual sensor is arranged in a parking area in a road to acquire a video image sequence, and an adaptive threshold segmentation technology is utilized to segment the area;
step 2, tracking the vehicle, specifically operating as follows: splitting the video image acquired in the step 1 into frame number images, and extracting an identifiable vehicle motion state on the basis of the split images;
step 3, parking judgment, comprising the following specific operations: carrying out Canny operator edge detection on the image of the vehicle of which the vehicle state is judged to be static, and judging whether a jump-type change area exists according to the gray value and the texture characteristics of the image pixels in the step 2 by using an algorithm, namely judging whether the vehicle stops;
and 4, extracting parking characteristics, wherein the specific operation is as follows: IoU of the connected region is calculated, namely the ratio of the intersection and the union of the predicted frame of the parking region and the actual frame of the vehicle for actual parking is calculated, and whether the intersection behavior exists is judged;
and 5, identifying parking behaviors, and specifically operating as follows: judging the angle between the main shaft direction of the vehicle and the main shaft direction of the parking space to identify the parking behavior for the vehicle parked in an inclined position and parked transversely; for the vehicles placed in the reverse direction, judging the distance between the vehicles and the parking space and the direction of an arrow to identify parking behaviors; judging whether four corner points of the vehicle body outline are all in a parking area to identify parking behaviors for vehicles which are parked in a cross-parking position, are parked by pressing a line and are parked without keeping a reasonable vehicle distance; thereby obtaining the illegal parking information of the vehicle.
Preferably, in step 1, the segmentation is performed with the contrast between the object and the background in the image changing as a function of the slowly changing position in the image, and the n × n neighborhood of each pixel (n is an odd number to reduce the amount of computation, and usually n is 3 or 5) is used to count the neighborhood gray of the pixel:
T=M+T×S (1-3)
wherein M represents the average gray value of each pixel in a certain pixel neighborhood; n × n represents that the number of pixels in the horizontal direction (the number of columns) is n, the number of pixels in the vertical direction (the number of rows) is n, then the total pixels of the image are n × n pixels, the gray resolution j, k represents the minimum change distinguishable in the gray level, the (x, y) is a discrete coordinate, and the S represents the standard deviation of the pixel gray level in the neighborhood; t is a constant determined according to image quality (0< T < 1);
when the image quality is good, T takes a smaller value; when the image quality is poor, T takes a larger value; when dynamic adaptive binarization of the neighborhood is considered, T is a threshold value, the value is calculated according to the average gray level of the pixel neighborhood and the standard deviation of the gray level of the neighborhood pixels, and the image is segmented by adopting the dynamic adaptive threshold value T, so that a binarized image can be obtained:
preferably, in step 2, the motion state of the vehicle is determined based on a frame difference method, the frame difference method extracts the foreground object according to the image difference value of the previous frame and the next frame in the video, and the image of the previous frame is assumed to be I1The image of the current frame is I2For a certain point P (x, y) on the image, there is I in the two previous and next frames of images1(x, y) and I2(x, y), namely:
|I1(x, y) -I2(x,y)|>T (2-1)
Wherein T represents a designated threshold value and serves as a fault-tolerant mechanism for judging the vehicle state;
and (3) judging whether the point is a foreground or a background according to the formula (2-1), acquiring an average shaking threshold value according to the front and back displacement of the known stationary object, judging that the vehicle is in a moving state when the distance between two frames before and after the vehicle in an unknown state is greater than T, and judging that the vehicle is in a stationary state if the distance is less than T.
Preferably, in step 3, the Canny operator edge detection includes gaussian filtering, calculating gradient values and gradient directions, filtering non-maximum values, and detecting edges using upper and lower thresholds, where the upper and lower thresholds specifically include the following operations: an upper threshold and a lower threshold are determined, and edges above the lower threshold are both considered.
Preferably, the gaussian filtering specifically includes the following operations: for a pixel at a position (m, n), the gray value (only two-valued graph is considered here) is f (m, n), then the gray value after gaussian filtering becomes:
wherein, gσDenotes a two-dimensional Gaussian kernel with standard deviation σ, and mxn denotes the number of pixels in the horizontal direction (column)The number is m, the number of pixels (line number) in the longitudinal direction is n, and then the total pixels of the image are m multiplied by n pixels;
and multiplying each pixel point and the neighborhood thereof by a Gaussian matrix, and taking the weighted average value of the pixel points as the final gray value.
Preferably, the calculating the gradient value and the gradient direction specifically includes the following operations: the edge is the collection of pixel points with large gray value change, the middle of a black edge and a white edge is the edge, the gray value change of the edge is the maximum, the change degree and the direction of the gray value are represented by gradient, and gradient values g in different directions are obtained by multiplying points by a sobel or other operatorsx(m,n),gy(m,n);
The integrated gradient calculates the gradient value and the gradient direction by the following formulas:
wherein G (m, n) is a gradient value, and θ is a gradient direction.
Preferably, the filtering non-maximum specifically includes the following operations: using a Sobel edge detection algorithm to filter points which are not edges, and enabling the width of the edges to be 1 pixel point as far as possible: if a pixel belongs to the edge, the gradient value of the pixel in the gradient direction is the maximum, if not, the gray value is set to be 0:
wherein M isTFor the binary image, M is the original image, and T is the segmentation threshold.
Preferably, in step 5, the following operations are specifically included for the vehicle parking in the inclined position and the vehicle parking in the transverse direction: setting an angle theta between the main shaft direction of the vehicle and the main shaft direction of the parking space, and judging that the vehicle body deflection angle is in a reasonable range when the theta is less than or equal to th1 by setting an inclination threshold th1 and a transverse stopping threshold th 2; otherwise, continuously judging theta, if the condition is met, the vehicle is in the transverse parking mode in the non-standard parking, and if not, the vehicle is in the inclined parking mode.
Preferably, in step 5, the following operations are specifically included for the vehicles which are parked across a parking space, parked under a pressing line and parked without keeping a reasonable parking space: the method comprises the steps of (1) judging four contour angles of a vehicle body as P1'(XP1', Yp1'), P2' (XP2', Yp2'), P3'(XP3', YP3'), P4' (XP4', Yp4'), and judging whether the vehicle possibly has a cross-position or line pressing behavior in the next step if at least one of the four corner points of the vehicle body contour is not in a current parking area, wherein the four contour angles of the vehicle body are respectively judged to be in the current parking area (x is more than or equal to m1 and is less than or equal to m2, and n1 is more than or equal to n 2); judging four contour angles of the vehicle body and corner points (x is more than or equal to m2 and less than or equal to m3, and y is more than or equal to n1 and less than or equal to n2) of adjacent parking lots, judging the vehicle body to be a cross parking behavior when at least one corner point exists in the range of the adjacent parking areas, and otherwise, judging the vehicle body to be a line pressing parking behavior; if the four corners of the vehicle body contour are all in the range of the current parking area, setting a safety threshold value d, judging that the vehicle is safe to park when all the corners of the vehicle body contour meet the requirements (m1+ d is larger than or equal to x and smaller than or equal to m 2-d, n1 is larger than or equal to y and smaller than or equal to n2), and otherwise, judging that the vehicle does not keep a reasonable distance.
Preferably, the safety threshold d is set to 0.25 m.
Compared with the prior art, the method for identifying the irregular parking in the road based on the video data has the following advantages that: by adopting the video data-based in-road irregular parking recognition method, the principle method and the key technology for analyzing the vehicle parking behavior by utilizing the monitoring video information are utilized, the irregular parking behavior classification rule is established, the vehicle feature extraction method based on the video data is adopted, the automatic recognition of the parking behavior is realized, the intelligent management level of a parking lot is improved, and the intelligent parking application range is expanded.
Drawings
FIG. 1 is a schematic flow chart illustrating an embodiment of an in-road irregular parking recognition method based on video data according to the present invention;
FIG. 2 is a schematic diagram illustrating a state of the method for identifying a parking position of a vehicle in an inclined position according to the present embodiment;
FIG. 3 is a schematic view showing a state where the vehicle is stopped laterally in the present embodiment;
FIG. 4 is a schematic view illustrating a state of the vehicle parking across positions in the present embodiment;
FIG. 5 is a schematic view illustrating a state where the vehicle is pressed and stopped;
FIG. 6 is a schematic view of the present embodiment in a state where the vehicle does not maintain a reasonable vehicle distance;
FIG. 7 is a schematic view showing a reverse parking state of the vehicle according to the present embodiment;
fig. 8 is a diagram of an edge pixel point set in the present embodiment.
Detailed Description
The invention is further described below with reference to the accompanying drawings. The following examples will assist those skilled in the art in further understanding the invention, but are not intended to limit the invention in any way. It should be noted that it would be obvious to those skilled in the art that various changes and modifications can be made without departing from the spirit of the invention. All falling within the scope of the present invention.
Fig. 1 is a schematic flow chart of an in-road irregular parking identification method based on video data, which includes the following steps: step 1, vehicle detection, which specifically comprises the following operations: and arranging a visual sensor in the in-road parking area to acquire a video image sequence, and performing area segmentation by using a self-adaptive threshold segmentation technology.
The grey value of the background is changed and the contrast between the object and the background is also changed in the image, a well functioning threshold in one area of the image may not work well in other areas. The grey scale threshold is taken as a function that changes slowly with position in the image, taking into account the effect of the background on the current target, since the threshold is dynamically changing. Segmentation is performed with a change in contrast between the object and the background in the image, counting the neighborhood gray levels of the pixels using an n × n neighborhood (n is an odd number to reduce the amount of computation, typically n is 3 or 5) for each pixel:
T=M+T×S (1-3)
wherein M represents the average gray value of each pixel in a certain pixel neighborhood; n × n represents that the number of pixels in the horizontal direction (the number of columns) is n, the number of pixels in the vertical direction (the number of rows) is n, then the total pixels of the image are n × n pixels, the gray resolution j, k represents the minimum change distinguishable in the gray level, the (x, y) is a discrete coordinate, and the S represents the standard deviation of the pixel gray level in the neighborhood; t is a constant determined according to image quality (0< T < 1).
When the image quality is good, T takes a smaller value; when the image quality is poor, T takes a larger value; when dynamic adaptive binarization of the neighborhood is considered, T is a threshold value, the value is calculated according to the average gray level of the pixel neighborhood and the standard deviation of the gray level of the neighborhood pixels, and the image is segmented by adopting the dynamic adaptive threshold value T, so that a binarized image can be obtained:
the threshold value T is an adaptive binarization process because its size depends on the location of the pixel, with each pixel having a different threshold value.
Step 2, tracking the vehicle, specifically operating as follows: splitting the video image acquired in the step 1 into frame number images, and extracting an identifiable vehicle motion state on the basis of the split images;
judging the motion state of the vehicle based on a frame difference method, wherein the frame difference method extracts a foreground target according to the image difference value of the front frame and the rear frame in the video, and the image of the front frame is assumed to be I1The image of the current frame is I2For a certain point P (x, y) on the image, there is I in the two previous and next frames of images1(x, y) and I2(xY), namely:
|I1(x, y) -I2(x,y)|>T (2-1)
Wherein T represents a designated threshold value and serves as a fault-tolerant mechanism for judging the vehicle state;
and (3) judging whether the point is a foreground or a background according to the formula (2-1), acquiring an average shaking threshold value according to the front and back displacement of the known stationary object, judging that the vehicle is in a moving state when the distance between two frames before and after the vehicle in an unknown state is greater than T, and judging that the vehicle is in a stationary state if the distance is less than T.
Step 3, parking judgment, comprising the following specific operations: carrying out Canny operator edge detection on the image of the vehicle of which the vehicle state is judged to be static, and judging whether a jump-type change area exists according to the gray value and the texture characteristics of the image pixels in the step 2 by using an algorithm, namely judging whether the vehicle stops;
the Canny operator edge detection comprises Gaussian filtering, gradient value and gradient direction calculation, non-maximum value filtering and edge detection by using upper and lower thresholds, wherein the upper and lower thresholds are used for detecting the edge and specifically comprise the following operations: an upper threshold and a lower threshold are determined, and edges above the lower threshold are both considered.
The main purpose of filtering is noise reduction, and general image processing algorithms need noise reduction firstly. While gaussian filtering mainly smoothes (blurs) the image and also possibly increases the width of the edges, a gaussian function is a function similar to a normal distribution with a large middle and small sides.
The method specifically comprises the following operations: for a pixel at a position (m, n), the gray value (only two-valued graph is considered here) is f (m, n), then the gray value after gaussian filtering becomes:
wherein, gσRepresenting a two-dimensional gaussian kernel with a standard deviation σ, mxn represents the number of pixels in the horizontal direction (column number) m and the number of pixels in the vertical direction (row number) n, the total pixels of the image are mxn pixels.
And multiplying each pixel point and the neighborhood thereof by a Gaussian matrix, and taking the weighted average value of the pixel points as the final gray value.
Calculating the gradient values and gradient directions specifically includes the following operations: the edge is a set of pixels with large gray value variation, the middle of a black edge and a white edge is the edge, as shown in fig. 8, the edge is an edge pixel point set graph, and the gray value variation of the edge is the maximum, as shown in fig. 8. Gradient is used to express the change degree and direction of gray value, and gradient value g in different directions is obtained by multiplying a point by a sobel or other operatorsx(m,n),gy(m,n);
The integrated gradient calculates the gradient value and the gradient direction by the following formulas:
wherein G (m, n) is a gradient value, and θ is a gradient direction.
Filtering the non-maximum values specifically comprises the following operations: using a Sobel edge detection algorithm to filter points which are not edges, and enabling the width of the edges to be 1 pixel point as far as possible: if a pixel belongs to the edge, the gradient value of the pixel in the gradient direction is the maximum, if not, the gray value is set to be 0:
wherein M isTFor the binary image, M is the original image, and T is the segmentation threshold.
The algorithm judges whether a jump-type change area exists according to the characteristics of gray values, textures and the like of pixels in the image. When the function is used for representation, it is represented whether the function image has a drastic change. And carrying out noise reduction on the original image through a Gaussian filter function.
And 4, extracting parking characteristics, wherein the specific operation is as follows: IoU of the connected region is calculated, namely the ratio of the intersection and the union of the predicted frame of the parking region and the actual frame of the vehicle for actual parking is calculated, and whether the intersection behavior exists is judged;
in mathematical morphological operations, dilation and decay are the cornerstones of other complex morphological transformations, which simply combine in sequence to form an open-closed operation. The principle of extracting the image edges by using mathematical morphology is mainly based on some basic properties of morphological transformation, and the edges of the image to be detected can be obtained by performing difference between the result of simple morphological transformation of the image to be detected and the image to be detected, or by performing difference between various morphological transformations. Different from the traditional method, the method is simple to operate and has definite geometric significance. Furthermore, by adjusting the shape of the structural element, corresponding edge information can be obtained.
And 5, identifying parking behaviors, and specifically operating as follows: judging the angle between the main shaft direction of the vehicle and the main shaft direction of the parking space to identify the parking behavior for the vehicle parked in an inclined position and parked transversely; for the vehicles placed in the reverse direction, judging the distance between the vehicles and the parking space and the direction of an arrow to identify parking behaviors; judging whether four corner points of the vehicle body outline are all in a parking area to identify parking behaviors for vehicles which are parked in a cross-parking position, are parked by pressing a line and are parked without keeping a reasonable vehicle distance; thereby obtaining the illegal parking information of the vehicle.
As shown in fig. 2, a state diagram of the vehicle parking in an inclined position and as shown in fig. 3, a state diagram of the vehicle parking in a transverse position, specifically comprising the following operations for the vehicle parking in an inclined position and the vehicle parking in a transverse position: setting an angle theta between the main shaft direction of the vehicle and the main shaft direction of the parking space, and judging that the vehicle body deflection angle is in a reasonable range when the theta is less than or equal to th1 by setting an inclination threshold th1 and a transverse stopping threshold th 2; otherwise, continuously judging theta, if the condition is met, the vehicle is in the transverse parking mode in the non-standard parking, and if not, the vehicle is in the inclined parking mode.
The observation shows that when the included angle is larger than 15 degrees, an observer can obtain a normal front or back visual angle, when the included angle is smaller than 45 degrees, the complete front or back information of the vehicle can be obtained, but the information of the vehicle, the vehicle logo, the license plate and the like is obviously deviated, and when the included angle is larger than 45 degrees, the front or back information of the vehicle body is partially lost, and only the side information of the vehicle body can be obtained. Therefore, the determination thresholds th1 and th2 are set to 15 ° and 45 °.
Fig. 4 is a schematic diagram showing a state of a vehicle parking across a parking space, fig. 5 is a schematic diagram showing a state of a vehicle parking under pressure line, fig. 6 is a schematic diagram showing a state of a vehicle not keeping a reasonable parking space, and the method specifically includes the following operations for the vehicle parking across a parking space, parking under pressure line and parking under a condition that a reasonable parking space is not kept: the method comprises the steps of (1) judging four contour angles of a vehicle body as P1'(XP1', Yp1'), P2' (XP2', Yp2'), P3'(XP3', YP3'), P4' (XP4', Yp4'), and judging whether the vehicle possibly has a cross-position or line pressing behavior in the next step if at least one of the four corner points of the vehicle body contour is not in a current parking area, wherein the four contour angles of the vehicle body are respectively judged to be in the current parking area (x is more than or equal to m1 and is less than or equal to m2, and n1 is more than or equal to n 2); judging four contour angles of the vehicle body and corner points (x is more than or equal to m2 and less than or equal to m3, and y is more than or equal to n1 and less than or equal to n2) of adjacent parking lots, judging the vehicle body to be a cross parking behavior when at least one corner point exists in the range of the adjacent parking areas, and otherwise, judging the vehicle body to be a line pressing parking behavior; if the four corners of the vehicle body contour are all in the range of the current parking area, setting a safety threshold value d, judging that the vehicle is safe to park when all the corners of the vehicle body contour meet the requirements (m1+ d is larger than or equal to x and smaller than or equal to m 2-d, n1 is larger than or equal to y and smaller than or equal to n2), and otherwise, judging that the vehicle does not keep a reasonable distance. Referring to the parking space marking standard and property classification standard, the safety threshold d is set to be 0.25 m.
As shown in fig. 7, which is a schematic view of a reverse parking state of a vehicle, if a monitoring camera is disposed right ahead of a parking space, a overlooking view angle with a certain inclination angle is adopted, and detection of the reverse parking is determined by detecting whether the vehicle is a head or a tail of the vehicle. If the parking direction indicator lamp displays that the parking direction is ahead, and the monitoring video detects that the vehicle is ahead, the parking direction of the vehicle is judged to be ahead; otherwise, if the tail of the vehicle is detected, the vehicle is judged to be in reverse parking.
The method selects the parking spaces in the road of the elegant residence community in the Tangshan street of Jiangning district in Nanjing to carry out shooting experiments, the parking space length is 6000mm, and the width is 2500mm, so that the algorithm is experimentally verified on real video data of the road parking behaviors. The non-standard parking behaviors mainly aiming at typical 6 in-road parking spaces are as follows: inclined parking, transverse parking, cross parking, line pressing parking, unreasonable parking distance maintenance and reverse parking.
In the experimental process, a vehicle parking video shot by parking spaces in the road of the elegant residence community in the soup of the Tangshan street in Jiangning district of Nanjing city is selected, the video format is mp4, the resolution is 960 × 540, and the actual shooting scene is shown in figure 2. The test image recording was 16s long for a total of 450 frames. And acquiring a static image of the target vehicle every 15 frames in the video image sequence, and performing vehicle identification and tracking on the acquired 30 frames of images. Practical tests show that the system can accurately identify the irregular parking behaviors of the parked vehicles staying in the in-road parking spaces.
The foregoing description of specific embodiments of the present invention has been presented. It is to be understood that the present invention is not limited to the specific embodiments described above, and that various changes or modifications may be made by one skilled in the art within the scope of the appended claims without departing from the spirit of the invention. The embodiments and features of the embodiments of the present application may be combined with each other arbitrarily without conflict.