Embodiment
At problems of the prior art, the target detection scheme after a kind of the improvement is proposed among the present invention, can improve the accuracy of testing result.
For make technical scheme of the present invention clearer, understand, below with reference to the accompanying drawing embodiment that develops simultaneously, scheme of the present invention is elaborated.
Fig. 1 is the process flow diagram of object detection method embodiment of the present invention.As shown in Figure 1, may further comprise the steps:
Step 11: when first two field picture is imported, for each pixel in the image is created a background model respectively, and each background model of initialization.
In the intelligent video analysis system of reality, the size of each two field picture of input all is identical, such as being 640 * 480, so, at these 640 * 480 pixels, being respectively it and creating a background model.False coordinate be (x, gray values of pixel points y) is Y, so its corresponding background model can be expressed as bg_model (x, y).
Include three submodel sub_model[3 in each background model], for explaining conveniently, be referred to as submodel 1, submodel 2 and submodel 3 respectively, further, include average (mean), variance (variance), the frequency of occurrences (freq) and four variablees of duration (time) occur in each submodel.Wherein, all the value representation submodel be evenly distributed the position; Variance is represented the distribution range of submodel; The frequency of occurrences is represented the frequency that submodel occurs on sequential; Duration occurs and represent the time span (frame number) of submodel from occurring present frame first.Fig. 2 is the data structure synoptic diagram of the background model among the present invention.
Afterwards, image according to input carries out initialization to each background model, the average that is about to submodel 1 is set to its corresponding gray values of pixel points Y, its variance is set to a predetermined initial value Init_Var, its frequency of occurrences is set to another predetermined initial value Init_Freq, and it duration occurs and is set to 1; All variablees in submodel 2 and the submodel 3 all are set to 0.The span of Init_Var is generally [4,144], and the span of Init_Freq is generally [0.3,1.0].
Step 12: at each pixel in every two field picture of follow-up input, according to the gray values of pixel points of same coordinate position in its gray-scale value and the former frame image its corresponding background model is upgraded respectively, and to determine this pixel be foreground point or background dot according to upgrading the result.
The specific implementation of this step comprises:
A, (convenient for explaining at each pixel X, represent arbitrary pixel with pixel X), the gray values of pixel points according to same coordinate position in its gray-scale value and the former frame image calculates the overall variance global_var that embodies image change trend respectively.
Wherein, the width of width presentation video, the height of height presentation video, p (x, y)
tThe gray-scale value of remarked pixel point X, its coordinate be (x, y), p (x, y)
T-1Coordinate is (x, gray values of pixel points y), T in the expression former frame image
Var_minValue be 4, T
Var_maxValue be 144, represent the upper and lower bound of variance respectively.
B, determine whether to exist in the background model of pixel X correspondence the submodel with pixel X coupling according to the global_var that calculates, if exist, execution in step C then, otherwise, execution in step D.
In this step, can come to determine whether to exist in the background model of pixel X correspondence submodel in such a way with pixel X coupling:
B1, each submodel in the background model of pixel X correspondence is sorted according to the descending order of the frequency of occurrences, and with the frequency of occurrences less than predetermined threshold T
1Submodel be labeled as invalid submodel, all the other submodels are labeled as effective submodel, follow-up, only mate with effective submodel; T
1Span be generally [0.001,0.3]; Effectively the number of submodel mostly is 3 most, and minimum also have 1 usually.
Afterwards, be in the difference Dif between the average of primary effective submodel after the gray-scale value of calculating pixel point X and the ordering, and whether definite Dif meets the following conditions:
Dif*Dif<T
2*max_var;
Wherein, T
2The expression predetermined threshold, span is generally [1,16], can control the matching range of submodel by it, max_var=max (global_var, var iance), var iance represent corresponding submodel, here be in the variance of primary effective submodel after referring to sort, global_var represents the overall variance that calculates in the steps A;
If satisfy, then think to be in primary effective submodel coupling after pixel X and the ordering, and execution in step C, otherwise, execution in step B2.
B2, determine whether to exist next effectively submodel, if there is no, execution in step D then is if exist, then be in the difference Dif between the average of deputy effective submodel after the gray-scale value of calculating pixel point X and the ordering, and whether definite Dif meets the following conditions: Dif*Dif<T
2* max_var; If satisfy, execution in step C then, otherwise, execution in step B3.
B3, determine whether to exist next effectively submodel, if there is no, execution in step D then is if exist, then be in the difference Dif between the average of tertiary effective submodel after the gray-scale value of calculating pixel point X and the ordering, and whether definite Dif meets the following conditions: Dif*Dif<T
2* max_var; If satisfy, execution in step C then, otherwise, execution in step D.
Among above-mentioned steps B1~B3, if exist and submodel that pixel X mates, execution in step C then, if there is no, execution in step D then.
All variablees in the submodel of C, renewal coupling, give Model Matching variable match_value with the appearance duration assignment after upgrading, and to the frequency of occurrences in other two submodels except that the submodel of coupling with two variablees of duration occur and upgrade, execution in step E then.
In this step, upgrade for all variablees in the submodel of coupling, even
var?iance
new=(1-α)*var?iance
old+Dif*Dif*α;
mean
new=(1-α)*mean
old+Dif*α;
freq
new=(1+α)*freq
old;
time
new=time
old+1;
Wherein, var iance
NewVariance after expression is upgraded, mean
NewAverage after expression is upgraded, freq
NewThe frequency of occurrences after expression is upgraded, time
NewAppearance duration after expression is upgraded, var iance
OldVariance before expression is upgraded, mean
OldAverage before expression is upgraded, freq
OldThe frequency of occurrences before expression is upgraded, time
OldAppearance duration before expression is upgraded, α is the parameter of controlling models renewal rate, span is [0.0001,0.1] usually, the difference between the average before the gray-scale value of Dif remarked pixel point X and the submodel of coupling upgrade.
And make match_value=time
New
Afterwards, to the frequency of occurrences in other two submodels except that the submodel of coupling with two variablees of duration occur and upgrade, even
freq
new=(1-α)*freq
old;
time
new=time
old+1;
The submodel of supposing coupling is a submodel 1, and other two submodels then are submodel 2 and submodel 3 so, and other variable in submodel 2 and the submodel 3 remains unchanged.
D, upgrade all variablees in the submodel (, can choose wantonly) of frequency of occurrences minimum in the background model of pixel X correspondence if be a plurality of, and with 0 assignment to Model Matching variable match_value, execution in step E then.
In this step, order
mean
new=Y;
var?iance
new=144;
freq
new=0.3;
time
new=1;
And make match_value=0;
Wherein, the gray-scale value of Y remarked pixel point X.
All variablees in two submodels of except that the submodel of frequency of occurrences minimum other all remain unchanged.
If E match_value is less than predetermined threshold T
Absorb, promptly
Mask_value<T
Absorb, T
AbsorbSpan be generally [100,3000];
Determine that then pixel X is the foreground point, otherwise, be background dot.
In addition,, need its gray-scale value to be set to 1 so,, then be set to 0 if be background dot if determine that pixel X is the foreground point.
Fig. 3 is the foreground point determined among the present invention and the synoptic diagram of background dot.As shown in Figure 3, white point is wherein represented the foreground point, and stain is represented background dot.
Step 13: utilize foreground point and the background dot determine to obtain an above prospect agglomerate, with the prospect agglomerate as detected target.
Though determined which pixel in the step 12 is the foreground point, and the ownership of undefined each foreground point.Usually, the pairing foreground point of target spatially is continuous, shows as a prospect agglomerate in image, and the profile of these prospect agglomerates is normally closed.The agglomerate mark can be regarded as the process of a profile search and profile tracking, and the corresponding unique profile of each prospect agglomerate can mark each prospect agglomerate by seeking these profiles.
Because according to after mode is handled shown in the step 12, each gray values of pixel points in the image or be 0, or be 1, therefore, this step can realize in the following manner.
A, according to from top to bottom, respectively be not marked as the pixel of following the tracks of end point in from left to right the order traversing graph picture, if a gray values of pixel points is 1, and having a gray values of pixel points in four pixels in the upper and lower, left and right that are adjacent at least is 0, determine that then this pixel is a point, and execution in step B, if can not find point, execution in step E then.
B, profile chained list that the agglomerate label is N of establishment, the point of determining is joined in this profile chained list, and the point of determining is labeled as the tracking end point, specifically, can be labeled as and follow the tracks of end value 0XFF, simultaneously the point of determining is sought reference point as profile, execution in step C; The initial value of N is 1.
C, in seek 3 * 3 the zone that reference point is the center with profile, seek new point, in case find new point, then it is joined in the profile chained list that the agglomerate label is N, and new point is labeled as the tracking end point, simultaneously it is sought reference point as new profile, repeated execution of steps C is up to can not find new point, execution in step D.
D, make N=N+1, and repeat steps A.
E, with the pixel that writes down in each profile chained list respectively as a prospect agglomerate, obtain N prospect agglomerate, with each prospect agglomerate as detected target.
In actual applications, for convenience of subsequent treatment, remove interference such as noise, can the prospect agglomerate that obtain in the step e further be screened, the prospect agglomerate of predetermined condition is not satisfied in i.e. deletion, the prospect agglomerate of counting and being less than 10 as the profile in the profile chained list, and each point in the profile chained list all is in the prospect agglomerate in other prospect agglomerate scope etc.
Fig. 4 is the synoptic diagram of each prospect agglomerate of obtaining among the present invention.
So far, promptly finished introduction about the inventive method embodiment.
Based on above-mentioned introduction, Fig. 5 is the composition structural representation of object detecting device embodiment of the present invention.As shown in Figure 5, comprising:
First processing module 51 is used for when first two field picture is imported, for each pixel in the image is created a background model respectively, and each background model of initialization;
Second processing module 52, be used for each pixel at every two field picture of follow-up input, according to the gray values of pixel points of same coordinate position in its gray-scale value and the former frame image its corresponding background model is upgraded respectively, and to determine this pixel be foreground point or background dot according to upgrading the result;
The 3rd processing module 53 is used to utilize foreground point and the background dot determined to obtain an above prospect agglomerate, with the prospect agglomerate as detected target.
Wherein, can specifically comprise (, not shown) in first processing module 51 for simplifying accompanying drawing:
First processing unit, be used at each pixel, be respectively it and create a background model, comprise three submodels in the described background model, be respectively submodel 1, submodel 2 and submodel 3, include average, variance, the frequency of occurrences in each submodel and four variablees of duration occur;
Second processing unit, the average that is used for each submodel 1 is set to its corresponding gray values of pixel points, and its variance is set to a predetermined initial value, and its frequency of occurrences is set to another predetermined initial value, and it duration occurs and is set to 1; All variablees in each submodel 2 and the submodel 3 all are set to 0.
Can specifically comprise (, not shown) in second processing module 52 for simplifying accompanying drawing:
The 3rd processing unit is used for each the pixel X at every two field picture of follow-up input, and the gray values of pixel points according to same coordinate position in its gray-scale value and the former frame image calculates the overall variance global_var that embodies image change trend respectively;
Manages the unit everywhere, be used for determining according to the global_var that calculates whether the background model of pixel X correspondence exists the submodel that mates with pixel X, if exist, then upgrade all variablees in the submodel that mates, give Model Matching variable match_value with the appearance duration assignment after upgrading, and to the frequency of occurrences in other two submodels except that the submodel of coupling with two variablees of duration occur and upgrade, notify the 5th processing unit to carry out self function then, otherwise, all variablees in the background model of renewal pixel X correspondence in the submodel of frequency of occurrences minimum, and give Model Matching variable match_value with 0 assignment, notify the 5th processing unit to carry out self function then;
The 5th processing unit is used for working as match_value less than predetermined threshold T
AbsorbThe time, determine that pixel X is the foreground point, otherwise, be background dot; Further, the gray values of pixel points that is defined as the foreground point is set to 1, and the gray values of pixel points that is defined as background dot is set to 0.
Wherein, overall variance
The width of width presentation video, the height of height presentation video, p (x, y)
tThe gray-scale value of remarked pixel point X, its coordinate be (x, y), p (x, y)
T-1Coordinate is (x, gray values of pixel points y), T in the expression former frame image
Var_minValue be 4, T
Var_maxValue be 144.
In addition, manage everywhere in the unit and also can specifically comprise:
First handles subelement, be used for each submodel of the background model of pixel X correspondence is sorted according to the descending order of the frequency of occurrences, and with the frequency of occurrences less than predetermined threshold T
1Submodel be labeled as invalid submodel, all the other submodels are labeled as effective submodel, be in the difference Dif between the average of primary effective submodel after the gray-scale value of calculating pixel point X and the ordering, and whether definite Dif meets the following conditions: Dif*Dif<T
2* max_var, wherein, T
2The expression predetermined threshold, max_var=max (global_var, var iance), var iance represents the variance of corresponding submodel, if satisfy, then notify second to handle subelement execution self function, otherwise, determine whether to exist next effectively submodel, if there is no, then notify the 3rd to handle subelement execution self function, if exist, then be in the difference Dif between the average of deputy effective submodel after the gray-scale value of calculating pixel point X and the ordering, and whether definite Dif meets the following conditions: Dif*Dif<T
2* max_var; If satisfy, then notify second to handle subelement execution self function, otherwise, determine whether to exist next effectively submodel, if there is no, then notify the 3rd to handle subelement execution self function, if exist, then be in the difference Dif between the average of tertiary effective submodel after the gray-scale value of calculating pixel point X and the ordering, and whether definite Dif meets the following conditions: Dif*Dif<T
2* max_var; If satisfy, then notify second to handle subelement execution self function, otherwise, notify the 3rd to handle subelement execution self function;
Second handles subelement, is used for upgrading all variablees of the submodel of coupling, even var is iance
New=(1-α) * var iance
Old+ Dif*Dif* α, mean
New=(1-α) * mean
Old+ Dif* α, freq
New=(1+ α) * freq
Old, time
New=time
Old+ 1, wherein, var iance
NewVariance after expression is upgraded, mean
NewAverage after expression is upgraded, freq
NewThe frequency of occurrences after expression is upgraded, time
NewAppearance duration after expression is upgraded, var iance
OldVariance before expression is upgraded, mean
OldAverage before expression is upgraded, freq
OldThe frequency of occurrences before expression is upgraded, time
OldAppearance duration before expression is upgraded, α is the parameter of controlling models renewal rate, the difference between the average before the gray-scale value of Dif remarked pixel point X and the submodel of coupling upgrade; Give Model Matching variable match_value with the appearance duration assignment after upgrading, and to the frequency of occurrences in other two submodels the submodel that removes coupling with two variablees of duration occur and upgrade, even freq
New=(1-α) * freq
Old, time
New=time
Old+ 1, notify the 5th processing unit to carry out self function then;
The 3rd handles subelement, is used for upgrading all variablees in the submodel of background model frequency of occurrences minimum of pixel X correspondence, even mean
New=Y, var iance
New=144, freq
New=0.3, time
New=1, the gray-scale value of Y remarked pixel point X, and give Model Matching variable match_value with 0 assignment, notify the 5th processing unit to carry out self function then.
Can specifically comprise (, not shown) in the 3rd processing module 53 for simplifying accompanying drawing:
The 6th processing unit, be used for according to from top to bottom, respectively be not marked as the pixel of following the tracks of end point in the order traversing graph picture from left to right, if a gray values of pixel points is 1, and on being adjacent, down, a left side, having a gray values of pixel points at least in right four pixels is 0, determine that then this pixel is a point, and the profile chained list that to create an agglomerate label be N, the point of determining is joined in this profile chained list, and the point of determining is labeled as the tracking end point, simultaneously the point of determining is sought reference point as profile, notify the 7th processing unit to carry out self function, the initial value of N is 1; If can not find point, then notify the 8th processing unit to carry out self function;
The 7th processing unit, being used for seek reference point with profile is that new point is sought in 3 * 3 the zone at center, in case find new point, then it is joined in the profile chained list that the agglomerate label is N, and new point is labeled as the tracking end point, simultaneously it is sought reference point as new profile, repeat self function,, make N=N+1 up to can not find new point, and new N sent to the 6th processing unit, notify it to repeat self function;
The 8th processing unit, the pixel that is used for each profile chained list is write down obtains N prospect agglomerate respectively as a prospect agglomerate, with each prospect agglomerate as detected target; Further, after obtaining N prospect agglomerate, also can delete the prospect agglomerate that does not wherein satisfy predetermined condition.
The concrete workflow of device embodiment shown in Figure 5 please refer to the respective description among the method embodiment shown in Figure 1, repeats no more herein.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being made, is equal to replacement, improvement etc., all should be included within the scope of protection of the invention.