Summary of the invention
The objective of the invention is to solve the inaccurate and unreliable problem of the detection target that in target detection, produces owing to illumination effect.In order to achieve the above object, the invention provides a kind of object detection method of removing illumination effect, said object detection method may further comprise the steps:
Step 101: set up background image;
Step 102: calculate and the gradient of output current frame image and the gradient of said background image, said gradient comprises horizontal direction gradient and vertical gradient;
Step 103: the direction and the amplitude of the gradient of more said current frame image and the gradient of said background image, and extract and export prospect profile in view of the above; With
Step 104: the prospect profile that extracts is filled obtaining the prospect agglomerate, and filtering noise is with export target.
Preferably, instep 101, adopt statistical method to set up background image.Said statistical method is to (the x of the pixel in the image of gathering in certain section time t; Y) carrying out statistical study (is exactly to pixel (x; Y) gray-scale value carries out simple number statistics and adds up), select this pixel in this section period (x, stable gray-scale value y) is (with pixel (x; Y) gray-scale value occurrence number is maximum elects stable gray-scale value as) as a setting in the image to should pixel (x; Y) gray-scale value through adding up in this section period t the stable gray-scale value of each pixel in the images acquired, thereby obtains background image.
Preferably, instep 102, adopt gradient operator to calculate horizontal direction gradient, the vertical gradient of said current frame image respectively, and horizontal direction gradient, the vertical gradient of said background image.Said gradient operator is Robert operator or Sobel operator.Robert operator and Sobel operator are the gradient algorithms in the general image treatment, repeat no more here.
Preferably,step 103 may further comprise the steps:
Step 1031: according to the gradient magnitude A2 and the gradient direction θ 2 of each pixel in the horizontal direction gradient of the horizontal direction gradient of the said current frame image ofstep 102 output and vertical gradient and said background image and gradient magnitude A1 that vertical gradient is calculated each pixel in the said current frame image and gradient direction θ 1 and the said background image;
Step 1032: if the pixel in the said current frame image (x, this pixel in gradient magnitude A1 y) and the said background image (x, gradient magnitude A2 y) all>=first threshold T1, then change step 1033 over to; If gradient magnitude A1 and A2 all≤the second threshold value T2, then think this pixel (x y) be noise spot, otherwise calculating | A1-A2|; If | A1-A2|>=the 3rd threshold value T3, think that then (x y) belongs to the foreground point to this pixel; Wherein, first threshold T1 ∈ [8,12], the second threshold value T2 ∈ [3,5], the 3rd threshold value T3 ∈ [4,6];
Step 1033: calculate this pixel (x in the said current frame image; Gradient direction θ 1 y) and this pixel in the said background image (x, the absolute difference of gradient direction θ 2 y) | θ 1-θ 2|, if | θ 1-θ 2| >=the 4th threshold value T4; Think that then (x y) belongs to the foreground point to this pixel; Wherein, the 4th threshold value T4 ∈ [18 °, 22 °]; With
Step 1034: extract the pixel that all belong to the foreground point, thereby obtain prospect profile.
Preferably,step 104 may further comprise the steps:
Step 1041: the prospect profile tostep 103 output is filled to obtain the prospect agglomerate;
Step 1042: calculate the error image of current frame image and background image, adopt thresholding method that this error image is carried out Threshold Segmentation to obtain the variation prospect in the error image; With
Step 1043: said prospect agglomerate and said variation prospect are carried out AND-operation, with the pixel that belongs to said prospect agglomerate and said variation prospect simultaneously as impact point to obtain and export target.
In addition, the present invention also provides a kind of object detecting device of removing illumination effect, and said device comprises: background is set up the unit, is used to adopt statistical method to set up background image; The gradient calculation unit is used to calculate and export the gradient of current frame image and the gradient of background image, and said gradient comprises horizontal direction gradient and vertical gradient; The prospect profile extraction unit is used for the direction and the amplitude of gradient of gradient and the said background image of more said current frame image, and extracts and export prospect profile in view of the above; With the target acquiring unit, be used for the prospect profile that extracts is filled obtaining the prospect agglomerate, and filtering noise is with export target.
Compared with prior art, object detection method of the present invention can detect the target of removing illumination effect exactly with device, has solved the inaccurate and unreliable problem of the detection target that produces owing to illumination effect in the target detection effectively.
Embodiment
For making your auditor can further understand structure of the present invention, characteristic and other purposes, combine appended preferred embodiment to specify as follows at present, illustrated preferred embodiment only is used to technical scheme of the present invention is described, and non-limiting the present invention.
The object detection method of removal illumination effect provided by the present invention is mainly used in the inaccurate and insecure problem of target detection that produces owing to illumination effect in the monitoring scene that solves.
As shown in Figure 1, Fig. 1 is the process flow diagram according to the object detection method of removal illumination effect of the present invention.Can find out that by Fig. 1 the object detection method of removal illumination effect of the present invention may further comprise the steps:
Step 101: set up background image;
Step 102: calculate and the gradient of output current frame image and the gradient of said background image, said gradient comprises horizontal direction gradient and vertical gradient;
Step 103: the direction and the amplitude of the gradient of more said current frame image and the gradient of said background image, and extract and export prospect profile in view of the above; With
Step 104: the prospect profile that extracts is filled obtaining the prospect agglomerate, and filtering noise is with export target.
Wherein, the background image set up ofstep 101 can be start frame image or specific still image.But in order to ensure the stability and the accuracy of background image, the statistical method of preferred employing is set up background image in step 101.This statistical method is implemented through following steps: to the pixel (x in the image of gathering in certain section time t; Y) carrying out statistical study (is exactly to pixel (x; Y) gray-scale value carries out simple number statistics and adds up), select this pixel in this section period (x, stable gray-scale value y) is (with pixel (x; Y) gray-scale value occurrence number is maximum elects stable gray-scale value as) as a setting in the image to should pixel (x; Y) gray-scale value through adding up in this section period t the stable gray-scale value of each pixel in the images acquired, thereby obtains background image.
Instep 102, can adopt gradient operator to calculate horizontal direction gradient, the vertical gradient of current frame image respectively, and horizontal direction gradient, the vertical gradient of background image.Wherein, this gradient operator is preferably Robert operator or Sobel operator.For example, can adopt 3 * 3Robert operator to calculate horizontal direction gradient, the vertical gradient of current frame image respectively, and horizontal direction gradient, the vertical gradient of calculating background image.
The horizontal direction gradient of 3 * 3Robert operator computed image, vertical gradient utilize 3 * 3Robert operator horizontal direction template, vertical direction template computed image interior pixel to put the horizontal difference of corresponding level, vertical formwork, vertical difference exactly.For example, can select 3 * 3Robert operator horizontal direction template to be:
The vertical direction template is:
Pixel (x, horizontal direction gradient S y) then
H(x, y), vertical gradient S
V(x y) is respectively:
SH(x,y)=(fx+1,y-1+2fx+1,y+fx+1,y+1)-(fx-1,y-1+2fx-1,y+fx-1,y+1)
SV(x,y)=(fx-1,y+1+2fx,y+1+fx+1,y+1)-(fx-1,y-1+2fx,y-1+fx+1,y-1)
fX, yRemarked pixel point (x, gray-scale value y).)
As shown in Figure 2, Fig. 2 is the process flow diagram according to thestep 103 of object detection method of the present invention.Can find out by Fig. 2, can may further comprise the steps according to thestep 103 of object detection method of the present invention:
Step 1031: according to the gradient magnitude A2 and the gradient direction θ 2 of each pixel in the gradient magnitude A1 of each pixel in the horizontal direction gradient of the horizontal direction gradient of the current frame image ofstep 102 output and vertical gradient and background image and the vertical gradient calculating current frame image and gradient direction θ 1 and the background image.
Image interior pixel point (x, gradient magnitude y), gradient direction computing formula are following:
Step 1032: if the pixel in the current frame image (this pixel in the x, gradient magnitude A1 y) and background image (x, gradient magnitude A2 y) is all more than or equal to first threshold T1; Then change step 1033 over to, if gradient magnitude A1 and A2, then think this pixel (x all smaller or equal to the second threshold value T2; Y) be noise spot, otherwise calculate | A1-A2|, if | A1-A2| is more than or equal to the 3rd threshold value T3; Think that then (x y) belongs to the foreground point to this pixel.Preferably, first threshold T1 ∈ [8,12], the second threshold value T2 ∈ [3,5], the 3rd threshold value T3 ∈ [4,6].
Step 1033: calculate this pixel (x in the current frame image; Gradient direction θ 1 y) and this pixel in the background image (x, the absolute difference of gradient direction θ 2 y) | θ 1-θ 2|, if | θ 1-θ 2| is more than or equal to the 4th threshold value T4; Think that then (x y) belongs to the foreground point to this pixel.Preferably, the 4th threshold value T4 ∈ [18 °, 22 °].
Step 1034: extract the pixel that all belong to the foreground point, thereby obtain prospect profile.
As shown in Figure 3, Fig. 3 is the process flow diagram according to thestep 104 of object detection method of the present invention.Can find out by Fig. 3, can may further comprise the steps according to thestep 104 of object detection method of the present invention:
Step 1041: the prospect profile tostep 103 output is filled to obtain the prospect agglomerate; The method that profile is filled is a lot; For example can adopt the horizontal direction scanning method, step can be following: the rectangular area with each prospect profile is an object, goes from first of rectangular area to begin scanning; By order from left to right; Scan first point (being leftmost profile) and last point (being the point of right sides), then the pixel between these two point all is made as the foreground point, continues to finish until this line scanning; Begin to scan next line, until last column; The agglomerate that all point after having scanned and foreground point are formed is the prospect agglomerate.
Step 1042: calculate the error image of current frame image and background image, adopt thresholding method that this error image is carried out Threshold Segmentation to obtain the variation prospect in the error image.
Thresholding method is the method for image interior pixel point being cut apart according to threshold value.The choosing method of said threshold value is a lot, and one dimension threshold value, two-dimentional threshold value are arranged.Be example with the simple one dimension fixed threshold of an example below: if the gray-scale value of certain point then is designated as " 1 " to be expressed as the foreground point greater than preset threshold in this error image; Otherwise be designated as " 0 " to be expressed as background dot, obtain the bianry image of prospect thus.
Step 1043: said prospect agglomerate and said variation prospect are carried out AND-operation, with the pixel that belongs to said prospect agglomerate and said variation prospect simultaneously as impact point to obtain and export target.
AND-operation is general a kind of computer operation, if interior certain pixel of image belongs to prospect agglomerate and variation prospect simultaneously particularly, thinks that then this pixel is that impact point then obtains and exports.
As shown in Figure 4, Fig. 4 is the frame diagram according to the object detecting device of removal illumination effect of the present invention.Can find out that by Fig. 4 the object detecting device of removal illumination effect of the present invention comprises:
Background is set up unit 1, is used to set up background image;
Gradient calculation unit 2 is used to calculate and export the gradient of current frame image and background image, and said gradient comprises horizontal direction gradient and vertical gradient;
Prospect profile extraction unit 3 is used for the direction and the amplitude of the gradient of more said current frame image and said background image, and extracts and export prospect profile in view of the above;
Target acquiring unit 4 be used for the prospect profile that extracts is filled obtaining the prospect agglomerate, and filtering noise is with export target.
Compared with prior art, object detection method of the present invention and device have solved the inaccurate and unreliable problem of the detection target that produces owing to illumination effect in the target detection effectively.
What need statement is that foregoing invention content and embodiment are intended to prove the practical application of technical scheme provided by the present invention, should not be construed as the qualification to protection domain of the present invention.Those skilled in the art are in spirit of the present invention and principle, when doing various modifications, being equal to replacement or improvement.Protection scope of the present invention is as the criterion with appended claims.