CN109741350B - Traffic video background extraction method based on morphological change and active point filling - Google Patents
Traffic video background extraction method based on morphological change and active point filling Download PDFInfo
- Publication number
- CN109741350B CN109741350B CN201811473688.XA CN201811473688A CN109741350B CN 109741350 B CN109741350 B CN 109741350B CN 201811473688 A CN201811473688 A CN 201811473688A CN 109741350 B CN109741350 B CN 109741350B
- Authority
- CN
- China
- Prior art keywords
- image
- rgb
- value
- img
- gray
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000605 extraction Methods 0.000 title claims abstract description 23
- 230000004660 morphological change Effects 0.000 title claims abstract description 7
- 238000001514 detection method Methods 0.000 claims abstract description 38
- 230000009191 jumping Effects 0.000 claims description 24
- 238000005192 partition Methods 0.000 claims description 7
- 239000000203 mixture Substances 0.000 claims description 6
- 230000003628 erosive effect Effects 0.000 claims description 5
- 238000012549 training Methods 0.000 claims description 5
- 230000007797 corrosion Effects 0.000 claims description 3
- 238000005260 corrosion Methods 0.000 claims description 3
- 230000006740 morphological transformation Effects 0.000 claims description 3
- 238000000034 method Methods 0.000 abstract description 10
- 230000008569 process Effects 0.000 abstract description 7
- 230000004308 accommodation Effects 0.000 abstract description 2
- 238000004458 analytical method Methods 0.000 abstract description 2
- 238000004364 calculation method Methods 0.000 description 2
- 239000003086 colorant Substances 0.000 description 2
- 230000007547 defect Effects 0.000 description 2
- 230000010339 dilation Effects 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000005070 sampling Methods 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006698 induction Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Images
Landscapes
- Traffic Control Systems (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
The invention relates to a background extraction method, in particular to a traffic video background extraction method based on morphological change and active point filling, and belongs to the technical field of traffic video detection and analysis. The invention processes the single-channel gray image to obtain the outline of the object in the image, thereby judging whether the object exists in the detection area and intercepting the image without the object in the detection area as a fixed background. The fixed background is relative to the mixed Gaussian background, and the counting accuracy is higher when the intersection intermittently stops and queues. Due to the traffic light shunting condition, the urban road often has the condition of vehicle backlog such as queuing, parking and the like in a short time, and the fixed background can well deal with the condition. Through filling the pixel on the red blue car gray level image, prevent that red blue car colour from too close ground and the condition of omitting to remember from taking place on the gray level image to can improve traffic flow count's accuracy, accommodation is wide, safe and reliable.
Description
Technical Field
The invention relates to a background extraction method, in particular to a traffic video background extraction method based on morphological change and active point filling, and belongs to the technical field of traffic video detection and analysis.
Background
With the development of intelligent transportation, real-time traffic flow data detection plays an increasingly important role. In the past, the vehicle flow is generally detected by a way of laying magnetic induction coils, but the defects of road surface damage, inconvenient maintenance and the like during installation are gradually replaced by a way of video detection. The video vehicle detection technology based on image processing is a key point of research in the aspect of vehicle flow detection in the field of intelligent transportation because of the advantages of large detection area, flexible setting, no damage to road surface in later maintenance and the like.
In recent years, video flow detection has been developed continuously to obtain many relevant solutions, and in background extraction, gaussian mixture background extraction can better describe a complex background due to its high adaptive performance to the background environment, and allows the existence of moving objects in the background modeling process, and is commonly used in the background extraction of vehicle flow detection. However, the gaussian mixture model has limitations in actual background extraction, and when vehicles at an intersection are temporarily backlogged, intermittently stopped and slowly passed by a large vehicle, the gaussian mixture model mixes a part of stopped or slowly moved large vehicles as a background, which causes background interference, and causes vehicle flow to be missed or over-recorded. This condition occurs commonly at intersections, affects the accuracy of the traffic flow count, and is obviously unacceptable in practical applications.
Disclosure of Invention
The invention aims to overcome the defects in the prior art, and provides a traffic video background extraction method based on morphological change and active point filling, which can effectively extract the background in a traffic video, can improve the accuracy of traffic flow counting, and has the advantages of wide application range, safety and reliability.
According to the technical scheme provided by the invention, the traffic video background extraction method based on morphological change and active point filling comprises the following steps:
step 1, acquiring traffic video information and converting the traffic video information into a single-channel gray image; after the converted single-channel gray image is obtained, reading a frame of gray image, and skipping to the step 2;
step 2, judging whether an object exists in the gray level image of the read frame, and jumping to step 3 when the object exists in the read gray level image, or jumping to step 4;
step 3, accumulating 1 for the count value n representing the existence of the object, clearing the count value m representing the absence of the object, and jumping to the step 5 when the count value n is not less than the threshold value H, or jumping to the step 7;
step 4, accumulating the counting value m representing the absence of the object by 1; when the count value M is not less than the threshold value M, jumping to the step 6, otherwise, jumping to the step 7;
step 5, switching to a Gaussian mixture background extraction method for background extraction, and skipping to step 7;
step 6, intercepting the current image as a fixed background, and clearing a count value n representing the existence of an object;
step 7, reading the next frame image, judging whether the read next frame image is the last frame image, and jumping to step 8 when the read next frame image is the last frame image, otherwise, jumping to step 2;
and 8, finishing the background extraction.
The step 2 specifically comprises the following steps:
step 2.1, performing morphological transformation on the single-channel gray image IMG _ source of the read frame to obtain an expansion image IMG _ partition and a corrosion image IMG _ anode;
step 2.2, calculating an absolute value IMG _ sub of a difference value between the gray value of the expansion image IMG _ partition and the gray value of the erosion image IMG _ anode, and binarizing the absolute value IMG _ sub to obtain an image IMG _ bank, specifically,
wherein the threshold value R is 50-70;
and 2.3, counting 255 pixels in the detection area in the IMG _ bind image to obtain a counting result act _ num, judging that an object exists in the detection area when the act _ num is larger than K, otherwise, judging that no object exists in the detection area, wherein the value range of K is 10-20.
Step 2.3, filling red and blue vehicle pixel points in a gray scale map of the image IMg _ binary, specifically, calculating R _ rgb, G _ rgb and B _ rgb of each pixel point in the detection area; if R _ rgb, G _ rgb and B _ rgb are in the range of R _ rgb _ range, G _ rgb _ range and B _ rgb _ range, setting the value of the current pixel point on the foreground gray scale image as a white point of 255; otherwise, keeping the value of the current pixel point;
after filling the pixels in the detection area in the IMG _ binary image, counting 255 pixels in the detection area to obtain a counting result act _ num;
the ranges of R _ rgb _ range, G _ rgb _ range and B _ rgb _ range are obtained by carrying out sample training on red and blue vehicles.
The invention has the advantages that: the method comprises the steps of processing a single-channel gray-scale image to obtain the outline of an object in the image, judging whether the object exists in a detection area or not, and intercepting the image without the object existing in the detection area as a fixed background. The fixed background is relative to the mixed Gaussian background, and the counting accuracy is higher when the intersection intermittently stops and queues. Due to the traffic light shunting condition, the urban road often has the condition of vehicle backlog such as queuing, parking and the like in a short time, and the fixed background can well deal with the condition. Through filling the pixel on the red blue car gray level image, prevent that red blue car colour from too close ground and the condition of omitting to remember from taking place on the gray level image to can improve traffic flow count's accuracy, accommodation is wide, safe and reliable.
Drawings
FIG. 1 is a flow chart of the present invention.
Fig. 2 is a process of determining whether an object exists in a gray image of a read frame according to the present invention.
FIG. 3 is a flow chart of the present invention for training color feature values of a vehicle.
FIG. 4 is a flow chart of filling the red and blue pixels on the gray scale image according to the present invention.
Detailed Description
The invention is further illustrated by the following specific figures and examples.
As shown in fig. 2: in order to effectively extract the background in the traffic video and improve the accuracy of traffic flow counting, the traffic video background extraction method comprises the following steps:
step 1, acquiring traffic video information and converting the traffic video information into a single-channel gray image; after the converted single-channel gray image is obtained, reading a frame of gray image, and skipping to the step 2;
specifically, the traffic video information can be acquired by means of a monitoring camera and the like, and can be converted into a single-channel grayscale image IMG _ source by adopting a common technical means in the technical field. In specific implementation, if a video source is a time-bare code stream, the value of each frame of the acquired video source is YUV or RGB directly, and the YUV and the RGB can be converted and are known; if the code stream is encoded, the YUV or RGB value is obtained after decoding according to the encoding rule, and the decoding process is also known.
YUV is a way of color coding, Y, U, V represents a color space, Y represents brightness, U represents chroma, V represents density, and the combination of YUV represents a color image, and the single Y value represents the gray level value of the image, so taking the Y value of the image is directly the gray level image. The calculation formula of the gray value Y is as follows: y is 0.299R + 0.587G + 0.114B.
Step 2, judging whether an object exists in the gray level image of the read frame, and jumping to step 3 when the object exists in the read gray level image, or jumping to step 4;
as shown in fig. 2, the step 2 specifically includes the following steps:
step 2.1, performing morphological transformation on the single-channel gray image IMG _ source of the read frame to obtain an expansion image IMG _ partition and a corrosion image IMG _ anode;
in the embodiment of the present invention, after performing the dilation operation, the dilated image IMG _ partition can be obtained, and after performing the erosion operation, the eroded image IMG _ anode can be obtained, and the specific processes of performing the dilation operation and the erosion operation are well known to those skilled in the art, and are not described herein again.
Step 2.2, calculating an absolute value IMG _ sub of a difference value between the gray value of the expansion image IMG _ partition and the gray value of the erosion image IMG _ anode, and binarizing the absolute value IMG _ sub to obtain an image IMG _ bank, specifically,
wherein the threshold value R is 50-70;
in the embodiment of the invention, the threshold R is obtained according to data statistics, mainly aims to eliminate noise interference of partial road surfaces while extracting the object profile, and can distinguish the gray values of positive and negative samples through the threshold R.
And 2.3, counting 255 pixels in the detection area in the IMG _ bind image to obtain a counting result act _ num, judging that an object exists in the detection area when the act _ num is larger than K, otherwise, judging that no object exists in the detection area, wherein the value range of K is 10-20.
As shown in fig. 3 and 4, step 2.3 further includes filling red and blue vehicle pixel points in a gray scale map of the image IMg _ binary, specifically, calculating R _ rgb, G _ rgb, and B _ rgb of each pixel point in the detection area; if R _ rgb, G _ rgb and B _ rgb are in the range of R _ rgb _ range, G _ rgb _ range and B _ rgb _ range, setting the value of the current pixel point on the foreground gray scale image as a white point of 255; otherwise, keeping the value of the current pixel point;
after filling the pixels in the detection area in the IMG _ binary image, counting 255 pixels in the detection area to obtain a counting result act _ num;
the ranges of R _ rgb _ range, G _ rgb _ range and B _ rgb _ range are obtained by carrying out sample training on red and blue vehicles.
In specific implementation, a vehicle sample is taken, and characteristic values R _ rgb, G _ rgb and B _ rgb of the color of the vehicle body are calculated; wherein R _ rgb ═ R/(R + G + B); g _ rgb ═ G/(R + G + B); b _ rgb/(R + G + B), and thereby the maximum value and the minimum value of each of R _ rgb, G _ rgb, and B _ rgb are calculated.
And repeating the step calculation process, and updating the maximum value and the minimum value of each of R _ rgb, G _ rgb and B _ rgb until all the vehicle samples are trained.
Taking the maximum and minimum values of R _ rgb, G _ rgb and B _ rgb obtained after training as the range of the color judgment of the red and blue pixel points: r _ rgb _ range, G _ rgb _ range, B _ rgb _ range.
And (4) taking an image source, traversing the detection area, and calculating the R _ rgb, G _ rgb and B _ rgb values of each pixel point in the detection area. If R _ rgb, G _ rgb and B _ rgb are in the range of R _ rgb _ range, G _ rgb _ range and B _ rgb _ range, setting the value of the current pixel point on the foreground gray scale image as a white point of 255; and if the current pixel point is not in the range, the value of the current pixel point is not changed.
According to the method, the characteristic value ranges of R/(R + G + B), G/(R + G + B) and G/(R + G + B) of red and blue vehicles are obtained by counting the characteristics of RGB values of the red and blue vehicles, and the pixel points which accord with the characteristic values are set as white points on the foreground gray level image, so that the problem that the pixel points of the gray level image of the red and blue vehicles are too dark is solved.
In the embodiment of the invention, the threshold K is obtained by statistics, and the vehicle on the road surface is better distinguished from the vehicle without the vehicle through the threshold K.
Step 3, accumulating 1 for the count value n representing the existence of the object, clearing the count value m representing the absence of the object, and jumping to the step 5 when the count value n is not less than the threshold value H, or jumping to the step 7;
step 4, accumulating the counting value m representing the absence of the object by 1; when the count value M is not less than the threshold value M, jumping to the step 6, otherwise, jumping to the step 7;
step 5, switching to a Gaussian mixture background extraction method for background extraction, and skipping to step 7;
step 6, intercepting the current image as a fixed background, and clearing a count value n representing the existence of an object;
step 7, reading the next frame image, judging whether the read next frame image is the last frame image, and jumping to step 8 when the read next frame image is the last frame image, otherwise, jumping to step 2;
and 8, finishing the background extraction.
In the embodiment of the invention, the threshold H and the threshold M are determined by sampling according to the frame number of the video, and the background is updated once if no vehicle exists in three seconds according to the sampling rule; and (3) changing the background-free updating into the Gaussian background after 20-30 minutes (setting is different according to different road conditions and time is customized). If the video is 20 frames/second, 3 seconds are specified, and the background is updated once when no vehicle exists; and switching to the Gaussian background after 20 minutes without background updating, wherein the frame number is 60 frames and 24000 frames.
In general, the threshold H may be set to 20000, and the threshold M may be selected to be 50. That is, when no object exists in 50 continuous frames in the detection area, the image of the current frame is intercepted as a fixed background. When a fixed background is used, when the number of frames of the detection area using the same fixed background is accumulated to exceed 20000 frames, the mixed Gaussian background is switched back. Due to the change of factors such as ambient light, the fixed background is different from the actual background when the fixed background is not updated for a long time, the accuracy of the traffic flow is counted by a background difference method, and therefore the mixed Gaussian background is switched back when the interception condition of the fixed background is not met in the detection area for a long time.
The invention processes the single-channel gray image to obtain the outline of the object in the image, thereby judging whether the object exists in the detection area and intercepting the image without the object in the detection area as a fixed background. The fixed background is relative to the mixed Gaussian background, and the counting accuracy is higher when the intersection intermittently stops and queues. Due to the traffic light shunting condition, the urban road often has the condition of vehicle backlog such as queuing, parking and the like in a short time, and the fixed background can well deal with the condition.
The invention optimizes the problem that the colors of red and blue vehicles in the gray image are too dark, and prevents the condition that the colors of the red and blue vehicles on the gray image are too close to the ground and are missed by filling the pixel points on the gray image of the red and blue vehicles, thereby improving the accuracy of traffic flow counting, and having wide application range, safety and reliability.
Claims (1)
1. A traffic video background extraction method based on morphological change and active point filling is characterized by comprising the following steps:
step 1, acquiring traffic video information and converting the traffic video information into a single-channel gray image; after the converted single-channel gray image is obtained, reading a frame of gray image, and skipping to the step 2;
step 2, judging whether an object exists in the gray level image of the read frame, and jumping to step 3 when the object exists in the read gray level image, or jumping to step 4;
step 3, accumulating 1 for the count value n representing the existence of the object, clearing the count value m representing the absence of the object, and jumping to the step 5 when the count value n is not less than the threshold value H, or jumping to the step 7;
step 4, accumulating the counting value m representing the absence of the object by 1; when the count value M is not less than the threshold value M, jumping to the step 6, otherwise, jumping to the step 7;
step 5, switching to a Gaussian mixture background extraction method for background extraction, and skipping to step 7;
step 6, intercepting the current image as a fixed background, and clearing a count value n representing the existence of an object;
step 7, reading the next frame image, judging whether the read next frame image is the last frame image, and jumping to step 8 when the read next frame image is the last frame image, otherwise, jumping to step 2;
step 8, finishing the background extraction;
the step 2 specifically comprises the following steps:
step 2.1, performing morphological transformation on the single-channel gray image IMG _ source of the read frame to obtain an expansion image IMG _ partition and a corrosion image IMG _ anode;
step 2.2, calculating an absolute value IMG _ sub of a difference value between the gray value of the expansion image IMG _ partition and the gray value of the erosion image IMG _ anode, and binarizing the absolute value IMG _ sub to obtain an image IMG _ bank, specifically,
wherein the threshold value R is 50-70;
step 2.3, counting 255 pixel points in the detection area in the IMG _ bind image to obtain a counting result act _ num, judging that an object exists in the detection area when the act _ num is larger than K, and otherwise, judging that the object does not exist in the detection area, wherein the value range of the K is 10-20;
step 2.3, filling red and blue vehicle pixel points in a gray scale map of the image IMg _ binary, specifically, calculating R _ rgb, G _ rgb and B _ rgb of each pixel point in the detection area; if R _ rgb, G _ rgb and B _ rgb are in the range of R _ rgb _ range, G _ rgb _ range and B _ rgb _ range, setting the value of the current pixel point on the foreground gray scale image as a white point of 255; otherwise, keeping the value of the current pixel point;
after filling the pixels in the detection area in the IMG _ binary image, counting 255 pixels in the detection area to obtain a counting result act _ num;
the ranges of R _ rgb _ range, G _ rgb _ range and B _ rgb _ range are obtained by carrying out sample training on red and blue vehicles.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811473688.XA CN109741350B (en) | 2018-12-04 | 2018-12-04 | Traffic video background extraction method based on morphological change and active point filling |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811473688.XA CN109741350B (en) | 2018-12-04 | 2018-12-04 | Traffic video background extraction method based on morphological change and active point filling |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109741350A CN109741350A (en) | 2019-05-10 |
CN109741350B true CN109741350B (en) | 2020-10-30 |
Family
ID=66358465
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811473688.XA Active CN109741350B (en) | 2018-12-04 | 2018-12-04 | Traffic video background extraction method based on morphological change and active point filling |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109741350B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111260934B (en) * | 2020-01-15 | 2021-03-12 | 山东双百电子有限公司 | Traffic flow detection method based on traffic video network |
CN113870154A (en) * | 2020-06-30 | 2021-12-31 | 广州慧睿思通人工智能技术有限公司 | Image data processing method, image data processing device, computer equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101025862A (en) * | 2007-02-12 | 2007-08-29 | 吉林大学 | Video based mixed traffic flow parameter detecting method |
CN103198300A (en) * | 2013-03-28 | 2013-07-10 | 南通大学 | Parking event detection method based on double layers of backgrounds |
CN104952256A (en) * | 2015-06-25 | 2015-09-30 | 广东工业大学 | Video information based method for detecting vehicles at intersection |
CN107025652A (en) * | 2017-05-05 | 2017-08-08 | 太原理工大学 | A kind of flame detecting method based on kinetic characteristic and color space time information |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8934698B2 (en) * | 2011-06-22 | 2015-01-13 | The Johns Hopkins University | System and device for characterizing cells |
-
2018
- 2018-12-04 CN CN201811473688.XA patent/CN109741350B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101025862A (en) * | 2007-02-12 | 2007-08-29 | 吉林大学 | Video based mixed traffic flow parameter detecting method |
CN103198300A (en) * | 2013-03-28 | 2013-07-10 | 南通大学 | Parking event detection method based on double layers of backgrounds |
CN104952256A (en) * | 2015-06-25 | 2015-09-30 | 广东工业大学 | Video information based method for detecting vehicles at intersection |
CN107025652A (en) * | 2017-05-05 | 2017-08-08 | 太原理工大学 | A kind of flame detecting method based on kinetic characteristic and color space time information |
Also Published As
Publication number | Publication date |
---|---|
CN109741350A (en) | 2019-05-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022027931A1 (en) | Video image-based foreground detection method for vehicle in motion | |
CN100545867C (en) | Aerial shooting traffic video frequency vehicle rapid checking method | |
Kaur et al. | An efficient approach for number plate extraction from vehicles image under image processing | |
US9811746B2 (en) | Method and system for detecting traffic lights | |
CN107273838B (en) | Processing method and device for snapshot pictures of traffic signal lamps | |
CN104616290A (en) | Target detection algorithm in combination of statistical matrix model and adaptive threshold | |
CN105160691A (en) | Color histogram based vehicle body color identification method | |
CN101154271A (en) | License plate character segmentation method based on rapid region labeling algorithm and license plate large-interval positioning method | |
CN104715239A (en) | Vehicle color identification method based on defogging processing and weight blocking | |
CN103473534B (en) | A kind of vehicle checking method based on video | |
CN104715252A (en) | License plate character segmentation method with combination of dynamic template and pixel points | |
CN110782409B (en) | A Method for Removing the Shadow of Multiple Moving Objects | |
CN104952256A (en) | Video information based method for detecting vehicles at intersection | |
CN109741350B (en) | Traffic video background extraction method based on morphological change and active point filling | |
CN106127124A (en) | The automatic testing method of the abnormal image signal in region, taxi front row | |
CN105389781A (en) | Vehicle light repairing method based on saliency detection and Criminisi algorithm | |
CN114332497A (en) | Mine car camera dirty detection method | |
CN111027564A (en) | Low-illumination imaging license plate recognition method and device based on deep learning integration | |
CN106951831B (en) | Pedestrian detection tracking method based on depth camera | |
Zhu et al. | Optimization of image processing in video-based traffic monitoring | |
CN109859220B (en) | Linear image segmentation method | |
Davix et al. | License plate localization by sobel vertical edge detection method | |
CN110633705A (en) | Low-illumination imaging license plate recognition method and device | |
CN110852228B (en) | Method and system for extracting dynamic background and detecting foreground object in monitoring video | |
Yang et al. | A novel binarization approach for license plate |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |