Summary of the invention
In view of this, the invention provides a kind of method and system of removing the people flow rate statistical of false target, to solve the existing not statistical uncertainty true problem of people flow rate statistical scheme.
For this reason, the embodiment of the invention adopts following technical scheme:
A kind of method of removing the people flow rate statistical of false target comprises: adopt sorter that present image is carried out the number of people and detect, determine each number of people in the present image; Each number of people of determining is followed the tracks of, formed number of people target trajectory; Number of people target trajectory is carried out the smoothness analysis; Carry out the flow of the people counting according to the number of people target trajectory direction after analyzing.
Describedly number of people target trajectory is carried out the smoothness analysis comprise: determine the smoothness of number of people target trajectory, judge whether described smoothness satisfies threshold value, if, keep this number of people target trajectory, otherwise, this number of people target trajectory abandoned.
Adopt sorter present image is carried out the number of people detect after, determine each number of people in the present image before, also comprise: the detected number of people of sorter is carried out the edge feature fine screening handle.
Describedly the detected number of people of sorter is carried out the edge feature fine screening handle and to comprise: calculate described sorter and be judged as the rectangle inward flange feature of number of people target and the degree of fitting of the upside of ellipse arc that presets, if degree of fitting is greater than threshold value, then this rectangle is defined as the number of people, otherwise this rectangle is removed from object listing.
The employing sorter carries out number of people detection to present image before, also comprise: the surveyed area in the image is carried out scene calibration, thereby surveyed area is divided into plurality of sub-regions; Described sorter carries out number of people detection and carries out in described plurality of sub-regions.
Describedly surveyed area in the image is carried out scene calibration comprise: select to demarcate frame; Calculate the scene depth variation factor; Calculate number of people target size variation range in the surveyed area; According to the number of people target size variation range surveyed area is divided into plurality of sub-regions.
Described sorter is a multicategory classification device in parallel.
Described multicategory classification device carries out number of people detection to image and comprises: the detection order that all kinds of sorters are set, adopting each sorter that present image is carried out the number of people successively according to the detection order detects, up to determining the number of people, wherein, the multicategory classification device of described parallel connection is formed in parallel by at least two class sorters.
The multicategory classification device of described parallel connection is formed in parallel by any two or more in dark hair generic classifier, light hair sorter, cap sorter and the expansion sorter.
A kind of system of removing the people flow rate statistical of false target comprises: number of people detection module, and be used to adopt sorter that present image is carried out the number of people and detect, determine each number of people in the present image; Number of people target tracking module is used for each number of people of determining is followed the tracks of, and forms number of people target trajectory; Number of people target trajectory analysis module is used to calculate the smoothness of number of people target trajectory, judges whether described smoothness satisfies threshold value, if, keep this number of people target trajectory, otherwise, this number of people target trajectory abandoned; The flow of the people counting module, the number of people target trajectory direction that is used for after analysis is carried out the flow of the people counting.
Also comprise: the scene calibration module is used for the surveyed area of image is carried out scene calibration, thereby surveyed area is divided into plurality of sub-regions.
Described sorter is a multicategory classification device in parallel; Described number of people detection module comprises rough detection submodule and fine screening submodule, described rough detection submodule is used to be provided with the detection order of all kinds of sorters, adopting each sorter that present image is carried out the number of people successively according to the detection order detects, up to determining the number of people, wherein, the multicategory classification device of described parallel connection is formed in parallel by at least two class sorters; The fine screening submodule is used for the detected number of people of multicategory classification device of parallel connection is carried out edge feature fine screening processing.
The multicategory classification device of described parallel connection is formed in parallel by any two or more in dark hair generic classifier, light hair sorter, cap sorter and the expansion sorter.
As seen, the present invention can remove false target by the smoothness analysis to number of people target trajectory, can further improve the detection accuracy rate.Further, the present invention can detect multiclass number of people targets such as dark hair, light hair and shades of colour cap simultaneously with the use in parallel of a plurality of sorters, guarantees that statistics is more comprehensive.Further, the present invention also is provided with an expansion sorter, can be according to the application of particular surroundings, gather sample training, and detect the number of people of designated color or cap, such as the working cap in factory or warehouse etc.Further, on the basis of sorter as number of people rough detection of a plurality of parallel connections, utilize edge feature that the rough detection result is carried out fine screening again, obtain real number of people target at last, make that detection is more accurate.In addition, the present invention selects the size of detection window automatically by scene calibration before detection, makes the various camera angle of the present invention's energy self-adaptation, has widened range of application.
Embodiment
The present invention proposes a kind of method of removing the people flow rate statistical of false target, sees also Fig. 1, is one embodiment of the invention process flow diagram, comprising:
S100: adopt sorter that present image is carried out the number of people and detect, determine each number of people in the present image;
S101: each number of people of determining is followed the tracks of, formed number of people target trajectory;
S102: number of people target trajectory is carried out the smoothness analysis;
S103: carry out the flow of the people counting according to the number of people target trajectory direction after analyzing.
Wherein, the process of number of people target trajectory being carried out the smoothness analysis is: determine the smoothness of number of people target trajectory, judge whether described smoothness satisfies threshold value, if, keep this number of people target trajectory, otherwise, this number of people target trajectory abandoned.
As seen, the present invention detects can remove false target by the smoothness analysis to number of people target trajectory, can further improve the detection accuracy rate.
In order further to improve the accuracy of people flow rate statistical, on scheme basis shown in Figure 1, can further be optimized, comprise, scene calibration, employing multicategory classification device in parallel carry out rough detection, the rough detection result are carried out edge feature fine screening etc., see also Fig. 2, be another embodiment of the present invention process flow diagram, comprising:
S201: scene calibration;
Particularly, scene calibration is meant carries out scene calibration to the surveyed area in the image, thereby surveyed area is divided into plurality of sub-regions.
S202: the number of people detects;
The number of people detects and further comprises sorter rough detection in parallel and two steps of edge feature fine screening, thereby determines each number of people in the present image.
S203: number of people target following;
By each number of people of determining is followed the tracks of, form number of people target trajectory.
S204: number of people target trajectory is carried out the smoothness analysis;
Particularly, number of people target trajectory is carried out the smoothness analysis comprise: determine the smoothness of number of people target trajectory, judge whether described smoothness satisfies threshold value, if, keep this number of people target trajectory, otherwise, this number of people target trajectory abandoned.
S205: people flow rate statistical: flow of the people is counted by number of people target trajectory direction.
Need to prove, above-mentioned scene calibration, the number of people of sorter rough detection in parallel is carried out the edge feature fine screening, and can also can use separately in conjunction with application the improvement that number of people target trajectory is analyzed.
Below the optimum embodiment of the present invention who comprises all improvements is carried out labor.
1, scene calibration
Because the video camera that is used for people flow rate statistical generally all is hard-wired, the scene variability is less, so the scene calibration module only need enable before first frame detects number of people target, and the result who all adopts first frame to demarcate when each frame detects number of people afterwards gets final product.If scene changes, then need to enable once more scene calibration.
Under video camera situation without spin, the change in depth of scene can be approximated to be along the linear variation of image y coordinate, that is:
w(x,y)=f×y+c (1)
Wherein, (x, y) expression center image coordinate is that (f is the scene depth coefficient for x, the width of number of people target boundary rectangle y), and c is a constant to w.The purpose of scene calibration is exactly to determine the value of f and c by demarcating frame, thereby through type (1) is obtained the size of number of people target boundary rectangle in arbitrary coordinate place in the image.
Two unknown quantity f and the c of the present invention by selecting 4~6 to demarcate in the frame calculating formulas (1), thereby obtain the change in depth coefficient of scene, in the coboundary and lower limb coordinate substitution formula (1) with the surveyed area boundary rectangle, obtain minimum people's area of bed w in the surveyed area then
MinWith maximum people's area of bed w
Max, last, according to the number of people change in size scope surveyed area is divided into plurality of sub-regions, corresponding one of each subregion changes less number of people range of size, in ensuing number of people detection module, each subregion different size window search candidate rectangle.
Scene calibration step block diagram comprises as shown in Figure 3:
S301: select to demarcate frame;
S302: calculate the scene depth variation factor;
S303: calculate number of people target size variation range in the surveyed area;
S304: surveyed area is divided into plurality of sub-regions according to number of people target size variation range.
So far, scene calibration finishes.Next begin in each two field picture, to carry out detection, tracking and the counting of the number of people.
2, the number of people detects
The number of people among the present invention detects and is divided into sorter rough detection in parallel and two links of edge feature fine screening.
By the good sorter of training in advance the inhuman head of major part is marked eliminating in the sorter rough detection link in parallel, the inhuman head's mark of remaining number of people target and part flase drop behaviour head target, and then remove most of flase drop by edge feature fine screening link, keep true number of people target.Number of people detection module structured flowchart as shown in Figure 4.
The present invention adopts the haar feature to train respectively based on the Adaboost algorithm to comprise the positive branch of the dark hair generic classifier of the front number of people and the back side number of people, dark hair sorter, dark hair back side branch sorter, light hair sorter, cap sorter and for adapting to the special a plurality of sorters such as expansion sorter that are provided with of specific environment.The array mode of a plurality of sorters is shown in Fig. 4 rough detection link: dark hair generic classifier and positive branch sorter, the synthetic tree structure of back side branch set of classifiers, form in parallel with light hair sorter, cap sorter and expansion sorter then, the sorter testing result enters people's head edge fine screening link, obtains real number of people target at last.
2.1, sorter rough detection link in parallel
Training aids needs to train with a large amount of positive samples and negative sample in advance, and the present invention adopts the haar feature of using in the detection of people's face to add Adaboost algorithm trainable recognizer.
The Haar feature is made of the rectangle of two or three different sizes.The shape and the half-tone information of specific objective can be described by the size, array mode and the angle that change rectangle.The Adaboost algorithm is a kind of method that some Weak Classifiers can be combined into strong classifier.Each Weak Classifier selects one or several haar feature to come sample is classified, and several Weak Classifiers are by the synthetic one-level strong classifier of Adaboost algorithm groups.All kinds of sorters described in the present invention form by some grades of strong classifier cascades.
The present invention according to the number of people target size that the scene calibration module obtains, adopts the exhaustive mode seeker head to mark candidate rectangle in surveyed area.Candidate rectangle is input to respectively in dark hair generic classifier, light hair sorter, cap sorter and the expansion sorter classifies, if be classified as the number of people, then this candidate rectangle is detected as the output of number of people target, continue to judge next candidate rectangle, otherwise, to select candidate rectangle to abandon, continue to judge next candidate rectangle.
In said process, a candidate rectangle is classified device and is categorized as the strong classifiers at different levels that number of people target needs to pass through step by step cascade classifier, otherwise is classified as inhuman head's mark, and its process synoptic diagram as shown in Figure 5.
In addition, in the above-mentioned sorter testing process, the preferential sorter of selecting can be according to the practical application adjustment.The probability maximum of dark hair in the general application scenarios, the dark hair sorter of therefore preferential selection detects, and at special scenes, such as detecting the doorway, warehouse, the expansion sorter that can preferentially select the working cap sample training to obtain detects, to accelerate detection speed.
2.2, edge feature fine screening link
By sorter rough detection link in parallel, most of non-number of people rectangle has been excluded, and only stays true number of people rectangle and is classified the rectangle that the device flase drop is the number of people.Edge feature fine screening link then can be removed most of flase drop rectangle by the edge feature that extracts in the rectangle, keeps true number of people target.
The present invention adopts oval first circular arc as the headform, and the edge feature fine screening is exactly to calculate to be classified device and to be judged as the rectangle inward flange feature of number of people target and the degree of fitting of oval first circular arc.If degree of fitting is greater than judgment threshold, then this rectangle is true number of people rectangle, otherwise is flase drop number of people rectangle, and this rectangle is removed from object listing.
3, the number of people is followed the tracks of
Need to follow the tracks of after number of people target detection is come out, form target trajectory, to avoid same target repeat count.Target tracking module of the present invention adopts particle filter algorithm that number of people target is followed the tracks of.
The flow process of particle filter tracking as shown in Figure 6, detailed process is as follows:
Step 601: particle initialization;
When new detected number of people target does not have existing particle at once, a then newly-generated particle tracker, and with each particle position and size in the new detected object initialization tracker, and compose the weighted value of equating for each particle.
Step 602: particle resamples;
In tracing process, particle " degradation phenomena " can occur through after weight is upgraded several times, promptly the weight of the minority particle of approaching true number of people rectangle can become bigger, and becoming very little away from the weight of most of particle of number of people rectangle, a large amount of calculating can be wasted on the very little particle of these weights.In order to solve " degradation phenomena ", after upgrading, each particle weight should resample to particle.
It is exactly to keep and duplicate the bigger particle of weight that particle resamples, and rejects the less particle of weight, and the particle that makes the heavy particle of original cum rights be mapped as equal weight continues predicting tracing.When tracker was newly-generated, the weight of each particle equated in the tracker, therefore, need not resample again.
Step 603: the propagation of particle;
The propagation of particle also is the state transitions of particle, is meant the state renewal process in time of particle.Among the present invention, the state of particle is meant the position and the size of the target rectangle of particle representative.The propagation of particle adopts a kind of random motion process to realize that promptly the current state of particle adds that by Last status a random quantity obtains.Like this, each current particle is all being represented a possible position and the size of number of people target in present frame.
Step 604: according to observed reading new particle weight more;
Particle has just obtained possible position and the size of number of people target in present frame by circulation way, also needs to utilize the observed reading of present image to determine which particle most possibly is a number of people rectangle.Extract the haar feature of particle correspondence image rectangle and edge feature among the present invention as the observed reading weight of new particle more.The observed reading of particle is approaching more with the true number of people, and then the rectangle of this particle correspondence may be number of people rectangle more, and the weight of particle increases; Otherwise the weight of particle reduces.
Step 605: upgrade target trajectory;
Particle is sorted by the weight size, take out the particle of weight maximum, the rectangle of the particle correspondence of calculating weight maximum and everyone head that detection obtains mark the overlapping area of rectangle, the overlapping area maximum, and the number of people target greater than setting threshold promptly is the number of people of number of people target correspondence in present frame of this particle place tracker representative, then use the target trajectory of the position renewal tracker of this number of people target, and replace the particle of weight maximum, enter next frame and follow the tracks of with this number of people target; If everyone head who detects in the particle of weight maximum and present frame mark is all not overlapping or overlapping area less than threshold value, think that then the number of people target of this particle place tracker representative does not find the corresponding number of people in present frame, then upgrade the target trajectory of tracker, and enter the next frame tracking with this particle position.If the particle N continuous of weight maximum (N>2) frame can not find corresponding number of people target, the number of people target and the disappearance of the tracker representative at this particle place then are described, reject this tracker.
Through above-mentioned five steps, the number of people target between frame and the frame just associates the movement locus that has formed number of people target.
4, smooth trajectory degree analysis module
In general, the motion of true number of people target is smoother, and the flase drop target then may present mixed and disorderly motion, and therefore, the present invention removes flase drop by the smoothness analysis to target trajectory, further improves detection accuracy.
The target trajectory that tracking module generates is analyzed, calculated the smoothing factor of target trajectory, if smoothing factor then keeps this track greater than the level and smooth threshold value of setting; Otherwise, reject this track.Smooth trajectory degree analysis module flow process comprises as shown in Figure 7:
S701: obtain target trajectory;
S702: the smoothness of determining number of people target trajectory;
S703: judge whether smoothness satisfies the smoothness threshold value requirement of presetting, if, carry out S704, otherwise, S705 carried out;
S704: keep this target trajectory;
S705: abandon this target trajectory;
S706: export target movement locus.
5, flow of the people counting module
The present invention counts flow of the people by number of people target trajectory direction.The present invention judges in surveyed area whether the direction of this target trajectory is consistent with " stream of people enters " direction of setting, if consistent, counting adds one then " to enter number ", otherwise " leaving number " counting adds one.After counting is finished with this target label for " counting ", make track be in disarmed state, avoid same target repeat count.
So far, analyze and this five big step of people flow rate statistical, promptly finished comprehensive, accurate statistics flow of the people by scene calibration, number of people detection, number of people target following, number of people target trajectory.
Corresponding with said method, the present invention also provides a kind of system of people flow rate statistical, and this system can pass through software, hardware or software and hardware combining and realize.
With reference to figure 8, this system comprises:
Number of people detection module 801 is used to adopt sorter that present image is carried out the number of people and detects, and determines each number of people in the present image;
Number of people target tracking module 802, each number of people that is used for number of people detection module 801 is determined is followed the tracks of, and forms number of people target trajectory;
Flow of the people counting module 803 is used for carrying out the flow of the people counting in the number of people target trajectory direction that number of people target tracking module 802 is determined;
Especially, this system also comprises number of people target trajectory analysis module 804, is used to calculate the smoothness of number of people target trajectory, judge whether described smoothness satisfies threshold value, if keep this number of people target trajectory, otherwise, abandon this number of people target trajectory.At this moment, flow of the people counting module 803 is on the basis of number of people target trajectory analysis module 804, adds up according to the number of people of movement locus direction.
Preferably, sorter adopts multicategory classification device in parallel to realize, for example, be formed in parallel by any two or more in dark hair generic classifier, light hair sorter, cap sorter and the expansion sorter, at this moment, number of people detection module 801 comprises rough detection submodule and fine screening submodule, wherein, the rough detection submodule is used to be provided with the detection order of all kinds of sorters, adopts each sorter that present image is carried out the number of people successively according to the detection order and detects, up to determining the number of people; The screening submodule is used for the detected number of people of multicategory classification device of parallel connection is carried out edge feature fine screening processing.
Preferably, this system also comprises:
Scene calibration module 805 is used for the surveyed area of image is carried out scene calibration, thereby surveyed area is divided into plurality of sub-regions.Wherein, the purpose of scene calibration module 805 is the depth coefficients that obtain scene, can calculate the size of the number of people target of each position in the image according to the scene depth coefficient, provides the detection size for the people head marks detection module.At this moment, the size that number of people detection module 801 provides according to scene calibration module 805, seeker head's mark in the plurality of sub-regions of appointment.
The specific implementation of said system sees also method embodiment, does not give unnecessary details.
As seen, the present invention can remove false target by the smoothness analysis to number of people target trajectory, can improve the detection accuracy rate.Further, the present invention adopts the haar feature trains a plurality of parallel connections based on the Adaboost algorithm sorter as number of people rough detection, utilizes edge feature that the rough detection result is carried out fine screening again, obtains real number of people target at last.Among the present invention a plurality of sorters parallel connections are used, can detect multiclass number of people targets such as dark hair, light hair and shades of colour cap simultaneously, the present invention also is provided with an expansion sorter, can be according to the application of particular surroundings, gather sample training, detect the number of people of designated color or cap, such as the working cap in factory or warehouse etc.In addition, the present invention selects the size of detection window automatically by scene calibration before detection, makes the various camera angle of the present invention's energy self-adaptation, has widened range of application.
The above only is a preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.