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, described 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 described background image, described gradient comprises horizontal direction gradient and vertical gradient;
Step 103: the direction and the amplitude of the gradient of more described current frame image and the gradient of described 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, in step 101, adopt statistical method to set up background image.Described 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 (x in this section period, y) stable gray-scale value 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, by adding up in this section period t the stable gray-scale value of each pixel in the images acquired, thereby obtain background image.
Preferably, in step 102, adopt gradient operator to calculate horizontal direction gradient, the vertical gradient of described current frame image respectively, and horizontal direction gradient, the vertical gradient of described background image.Described 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 described current frame image of step 102 output and vertical gradient and described background image and gradient magnitude A1 that vertical gradient is calculated each pixel in the described current frame image and gradient direction θ 1 and the described background image;
Step 1032: if the pixel in the described current frame image (x, this pixel in gradient magnitude A1 y) and the described 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 described current frame image, y) gradient direction θ 1 and interior this pixel (x of described background image, y) absolute difference of gradient direction θ 2 | θ 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 to step 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: described prospect agglomerate and described variation prospect are carried out AND-operation, with the pixel that belongs to described prospect agglomerate and described 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 described 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 described gradient comprises horizontal direction gradient and vertical gradient; The prospect profile extraction unit is used for the direction and the amplitude of the gradient of the gradient of more described current frame image and described background 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 and device can detect the target of removing illumination effect exactly, have 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, feature and other purposes, now be described in detail as follows in conjunction with appended preferred embodiment, 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.As seen from Figure 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 described background image, described gradient comprises horizontal direction gradient and vertical gradient;
Step 103: the direction and the amplitude of the gradient of more described current frame image and the gradient of described 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 of step 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 by 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 (x in this section period, y) stable gray-scale value 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, by adding up in this section period t the stable gray-scale value of each pixel in the images acquired, thereby obtain background image.
In step 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:
S
H(x,y)=(f
x+1,y-1+2f
x+1,y+f
x+1,y+1)-(f
x-1,y-1+2f
x-1,y+f
x-1,y+1)
S
V(x,y)=(f
x-1,y+1+2f
x,y+1+f
x+1,y+1)-(f
x-1,y-1+2f
x,y-1+f
x+1,y-1)
f
X, yRemarked pixel point (x, gray-scale value y).)
As shown in Figure 2, Fig. 2 is the process flow diagram according to the step 103 of object detection method of the present invention.As seen from Figure 2, the step 103 according to object detection method of the present invention can 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 current frame image of step 102 output and vertical gradient and background image and gradient magnitude A1 that vertical gradient is calculated each pixel in the current frame image and gradient direction θ 1 and the background image.
Image interior pixel point (x, gradient magnitude y), gradient direction computing formula are as follows:
Step 1032: if the pixel (x in the current frame image, y) this pixel (x in gradient magnitude A1 and the background image, y) gradient magnitude A2 then changes step 1033 over to all more than or equal to first threshold T1, if gradient magnitude A1 and A2 are all smaller or equal to the second threshold value T2, then think this pixel (x, 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, y) gradient direction θ 1 and interior this pixel (x of background image, y) absolute difference of gradient direction θ 2 | θ 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 the step 104 of object detection method of the present invention.As seen from Figure 3, the step 104 according to object detection method of the present invention can may further comprise the steps:
Step 1041: the prospect profile to step 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 as follows: the rectangular area with each prospect profile is an object, begin scanning from first row of rectangular area, by order from left to right, scan first point (being leftmost profile) and last point (being the point on limit, the left and right sides), then the pixel between these two point all is made as the foreground point, continue and 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 described 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: described prospect agglomerate and described variation prospect are carried out AND-operation, with the pixel that belongs to described prospect agglomerate and described 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.As seen from Figure 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 described 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 described current frame image and described 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 and replacing or improve.Protection scope of the present invention is as the criterion with appended claims.