The real-time vehicle detection system based on traffic video
Technical field
The present invention relates to traffic vehicle detection technique field, be specifically related to a kind of real-time vehicle detection system based on traffic video.
Background technology
Automobile as fast easily the vehicles be widely used, but increasing rapidly to urban transportation of its quantity brought immense pressure in recent years, also allows corresponding management personnel's work become day by day heavy.Along with the fast development of computer vision technique and hardware product, in order to solve these day by day serious traffic problems, intelligent transportation system (the Intell igent Transportation Systems that arises at the historic moment, be called for short ITS), wherein vehicle identification is the important composition composition of intelligent transportation system, is also widely applied about some existing correlation techniques of vehicle identification.The occasion that these technology have stable condition at some has shown good effect to specific vehicle, as bus, three box car etc.
Present vehicle identification mainly concentrates on the description of vehicle feature and vehicle template profile matching, it is mainly that the feature that the video image that collects from watch-dog obtains vehicle is described that vehicle feature is described, thereby the vehicle of portraying, reaches the object that in video, vehicle detects.The feature of current main description vehicle concentrates on Harris Corner Feature, HOG feature, and Gabor feature, and the single features such as SIFT feature, or single features combines, the union feature of formation.
And be mainly vehicle template base and the template search mechanisms of how Criterion about the description of vehicle template, obtain target by the video image collecting from watch-dog, then the target of obtaining and vehicle template base corresponding template are mated, thereby determine relevant vehicle.Mostly be unrestricted open environment because automobile is of living in, complicated and changeable, there is illumination variation, view transformation etc., so need a kind of accurately, in real time and there is the vehicle detection method of high-adaptability in complicated occasion.
Retrieval one of prior art: the yellow writing brush of In South China Polytechnics, Lin Zhenze, Zhu provide naughty etc. invention " the vehicle automatic identifying method based on vehicle direct picture and template matches ", publication number: CN103324920A.
This disclosure of the invention a kind of vehicle automatic identifying method based on vehicle direct picture and template matches, on gray level image, determine vehicle region by car plate, and the unified big or small vehicle template of foundation, carry out associated gradients calculating in template, after Grad normalization, put into neural network and train, output eight class vehicle results.This vehicle algorithm flow as shown in Figure 1.
In the prior art, first the vehicle direct picture collecting is carried out to gray processing and obtain gray-scale map, and calculate the transverse gradients figure of gray-scale map, reason is to have considered car plate shape and placement feature, is easily obtained car plate position and is calculated car plate width by transverse gradients figure.
In the prior art, because car plate width, the information such as position are fixed mostly, so the method is by the definite position of the transverse gradients figure that obtains and amplify by correlation proportion centered by the position obtaining, roughly can obtain vehicle region, the region unification obtaining is zoomed in feature extraction template
In the prior art, according to the template Grad obtaining, be normalized, obtain the feature of related data as vehicle judgement, be input to neural network, the neural network model obtaining by training, then utilizes this model to obtain the vehicle information that detects data output.
There is following shortcoming in the prior art: this patent utilization the gradient information of vehicle, obtain car plate relative widths and positional information and determine thus vehicle template, but single utilization gradient information and do not consider the impact of gradient around reference point, make vehicle characteristics statement lack completeness, can cause to a certain extent wrong report.In addition, adopt its speed of convergence of neural metwork training slow, have the shortcomings such as local extremum, and the training result of neural network is too dependent on the vehicle sample of selection.
Two of retrieval prior art: ancestor people Lee of China Petroleum Univ. (East-China), public thread are super, the invention " a kind of dynamic vehicle model recognizing method for intelligent transportation system " of Liu Yujie etc., CN103258213A.
This disclosure of the invention a kind of dynamic vehicle model recognizing method for intelligent transportation system.The first trained stage is utilized the image after normalization to extract HOG feature and describes the GIST feature of overall texture, obtains two sorters respectively as input by SVM.Then while detection, Output rusults is merged in conjunction with D-S evidence theory by two sorters that obtain, obtain maximum probability, thereby complete vehicle identification, this algorithm detailed process as shown in Figure 2.
In the prior art, first introduced in the training and testing stage GIST feature that HOG feature and entirety are described, the information when overcoming single features and describing vehicle is certain, has merged whole and part feature.
In the prior art, after two features are obtained, utilize SVM to obtain respectively two judgement models based on two features in the training stage, in the time that test judges vehicle, obtain relevant output by the judgement model that the HOG feature of detection vehicle is trained with the input of GIST feature, just form the basis of the cascading judgement of knowing clearly.
In the prior art, utilize two SVM models to detecting the dependent probability of the judgement vehicle that obtains of vehicle, merged the relevant information of two SVM outputs by D-S theory, thereby obtain most probable value, the vehicle classification that this most probable value is corresponding, be the classification of current vehicle to be identified, so far realized cascading judgement vehicle, obtain final detection result.
There is following shortcoming in the prior art: this patent utilization the HOG feature at edge and overall GIST feature described, strengthen the robustness that vehicle is characterized, and this patent carried out information fusion to the testing result of the judgement model training respectively, realize cascading judgement.But the method need to be trained and detection accuracy is largely subject to the impact of sample set, but sample set can not comprise the vehicle under all ambient conditions, in practical engineering application, the accuracy that its vehicle detects can not guarantee.
Summary of the invention
The object of this invention is to provide a kind of vehicle detection technique based on traffic video that can apply in real time in intelligent transportation system.
For achieving the above object, the present invention adopts following technical scheme: a kind of real-time vehicle detection system based on traffic video, comprises under line and mate two parts in training and line;
Described Xian Xia training department divides and comprises the following steps: (1) calculates Harris angle point, obtains marking area; Then adopt a little marking area is intensive, adopt a little non-marking area is sparse; (2) in the image of adopting after having put, to calculate corresponding expansion gradient and form vehicle template figure, the binary coding of the driving section mould plate figure that goes forward side by side, according to the similar pre-stored gradient response chart of cosine, completes parallel computation design; (3) difference of finally describing according to vehicle feature utilizes the mode of k-means cluster to build different subspace, sets up stratified vehicle template index, logging template relevant information;
On described line, coupling comprises the following steps: (1) is by obtaining the vehicle image of band identification under traffic scene; (2) marking area of computed image vehicle and non-marking area, then a non-homogeneous acquisition gradient map of adopting; (3) gradient point is expanded and binary coding; (4) by the corresponding gradient response diagram of the similar acquisition of cosine; (5) adopt the mode of parallel computation to carry out fast zoom table coupling; (6) obtain vehicle matching result, judge vehicle, complete vehicle and detect.
Under described line, in the step (1) of training part, the detailed step that calculates the gradient map of the nonuniform sampling point that obtains marking area and non-marking area is:
(1.1) first obtain the Harris angle point on vehicle wheel profile;
(1.2), take Harris angle point as the center of circle, circle is drawn on the size blank image the same with vehicle template image in neighborhood of pixels radius R=6, then finds connected domain on this image, thereby orients the marking area of vehicle image;
(1.3) intensive the adopting a little of marking area obtaining, non-marking area carry out sparse adopting a little; Calculate the image gradient of tri-passages of RGB of the image after nonuniform sampling, get the greatest gradient value of this o'clock in three passages for the Grad of each gradient point; Then passing threshold retains the larger gradient point of Grad; The gradient of trying to achieve, be quantified as the individual gradient direction of N (for example N=5), the gradient direction that then occurrence number is maximum in each gradient point field is as the gradient direction of this gradient point;
(1.4) quantize gradient direction afterwards and carry out corresponding binary coding mark, gradient direction is represented with the binary string that length is N=5, form the gradient map of binary representation.
Under described line, the step (2) of training part also comprises the Gradient Features information the pre-stored response table that obtain template, comprises the following steps:
(2.1) expansion of image gradient point is that the image gradient figure of binarization is processed, gradient point expansion process for example, carries out gradient expansion (by the processing of step-by-step OR operation to each gradient point in T × T (T=3) neighborhood, make each point contain the gradient direction occurring in the neighborhood that radius is T/2), thus the binary coding figure after expansion obtained;
(2.2) obtain after the gradient image after expansion, the similarity of template matches adopts the method for asking for cosine similarity to realize; In the process of coupling, this gradient point in T × T neighborhood in all gradient directions, has the cosine response value maximum that the gradient direction of a gradient direction and current matching obtains, and so just thinks that this gradient direction is the gradient direction mating most; Because gradient is quantified as N=5 grade, open gradient response diagram so obtain N=5, each gradient direction is corresponding gradient response table respectively, the maximum cosine response value of the field inside gradient direction set of each gradient response table and binary coding representative is can precompute, and is kept in internal memory for searching the corresponding maximum cosine response value of coding.
Under described line, in the step (3) of training part, K-means cluster is determined vehicle subspace, sets up level index and comprises the following steps:
(3.1) in order to improve the plain speed of searching, reduce the template number of the vehicle while coupling each time, this method adopts k-means clustering method to carry out thick cluster to template base figure according to outward appearance; Form different vehicle space distributions;
(3.2) on the basis of vehicle space distribution, vehicle template base is divided into the two-layer level index of setting up, ground floor template is the large class template of vehicle, second layer template is the concrete template of vehicle.
On described line, the step of compatible portion (1) obtains vehicle detection image to be identified, and the mode of first upgrading by mixed Gauss model and adaptive background obtains vehicle detection image to be identified; In this step, remove as much as possible unnecessary prospect, dwindle the computer capacity of follow-up matching algorithm, improve detection efficiency.
The gradient map of calculating acquisition vehicle nonuniform sampling point to be identified on described line in the step of compatible portion (2) comprises the following steps:
(2.1) first obtain the Harris angle point on vehicle wheel profile;
(2.2), take Harris angle point as the center of circle, radius R=6 pixel is drawn circle on the size blank image the same with vehicle template image, then finds connected domain on this image, thereby orients the marking area of vehicle image;
(2.3) intensive the adopting a little of marking area obtaining, rather than marking area carry out sparse adopting a little.Calculate the image gradient of tri-passages of RGB of the image after nonuniform sampling, get the greatest gradient value of this o'clock in three passages for the Grad of each gradient point.Then passing threshold retains the larger gradient point of Grad.The gradient of trying to achieve, be quantified as the individual gradient direction of N (N=5 in this programme), the gradient direction that then occurrence number is maximum in each gradient point field is as the gradient direction of this gradient point;
(2.4) quantize gradient direction afterwards and carry out corresponding binary coding mark, gradient direction is represented with the binary string that length is N=5, form the gradient map of binary representation.
On described line, in the step of compatible portion (3), vehicle gradient point to be detected is expanded and binary coding, wherein the expansion of image gradient point is that the image gradient figure of binarization is processed, gradient point expansion process carries out gradient expansion (by the processing of step-by-step OR operation to each gradient point in T × T (T=3 in this programme) neighborhood, make each point contain the gradient direction occurring in the neighborhood that radius is T/2), thus the binary coding figure after expansion obtained.
Compute gradient response diagram in the step of compatible portion (4) on described line, wherein in the T × T at gradient point position place (T=3) field in all gradient directions, have the cosine response value maximum that the gradient direction of a gradient direction and current matching obtains, so just think that this gradient direction is the gradient direction mating most.
On described line, the step of compatible portion (5) is fallen into a trap to calculate and is mated, and comprises the following steps:
(5.1) in order further to improve the speed of algorithm, adopt the parallel computation of gradient response diagram.First gradient response diagram is carried out to linearization, form the linearization internal memory of the individual gradient response diagram of cell*cell (getting cell=2 herein).5 gradient response diagram linearities are turned to 4 (cell*cell=4) individual row vector;
(5.2) realize parallel computation by linear internal memory, just can calculate the template matches similarity of multiple windows at every turn simultaneously.In matching process, mate by template base level template, find the linear internal memory of its corresponding gradient response diagram according to the gradient direction of gradient point in template image, and then the position in the region of cell*cell calculates its side-play amount in the linear internal memory (being a row vector) of corresponding gradient response diagram according to this gradient point;
(5.3) finally all row vectors are alignd by side-play amount, relevant position cosine response value is added to summation.In row vector after summation, each element is the similarity of template in this detection window, and its coordinate position corresponding to maximal value place is exactly the position at target place so.
In this programme, N, T and cell are greater than 0 natural number, preferably N=5, T=3, cell=2.
The invention has the beneficial effects as follows: in the solution of the present invention, vehicle detects the coherent detection that is applicable to nearly all vehicle, high for template vehicle detection complexity, the slow-footed problem in search pattern storehouse, this programme is adopted a little by the vehicle marking area after size normalized is intensive, the sparse nonuniform sampling mode of adopting a little of non-marking area, obtain sampled point, then on sampled point, carry out gradient expansion, the modes such as binary coding are set up the vehicle template of being convenient to parallel computation, and by k-means cluster, vehicle outward appearance etc. is carried out to thick cluster and set up different automobile types space, set up multi-level vehicle search, in concrete matching process, adopt to obtain in advance under line and calculate and obtain gradient response table, when coupling, parallel internal memory calculates, by the fast zoom table of the similar calculated response degree of cosine, the real-time that vehicle is detected, the aspects such as accuracy in detection than before scheme had better effect.
Accompanying drawing explanation
Fig. 1 is the process flow diagram of prior art one;
Fig. 2 is the process flow diagram of prior art two;
Fig. 3 is vehicle targets process flow diagram of the present invention;
Fig. 4 obtains based on marking area and non-marking area non-uniform point flow process;
Fig. 5 is that gradient quantizes and corresponding binary scale coding;
Fig. 6 is the gradient expansion of image and forms binary-coded gradient map process;
Fig. 7 is the table of compute gradient response in advance;
Fig. 8 is compute gradient response diagram;
Fig. 9 is the linearization of gradient response diagram;
Figure 10 calculates vehicle template matches similarity figure;
Figure 11 is that example set up in part vehicle template base index;
Figure 12 is vehicle matching process;
Figure 13 is picture size normalization exploded view.
Embodiment
Below in conjunction with accompanying drawing, the invention will be further described.
Embodiment 1: a kind of real-time vehicle detection system based on traffic video, the present invention adopts improved template matching method, mode by a kind of nonuniform sampling obtains sampled point, on sampled point basis, pass through to quantize gradient, and carry out gradient expansion binary representation to quantizing rear gradient direction, obtain respective extension gradient map, thereby set up template, and set up the template base of level by the thick cluster mode of k-means; Then obtain the expansion gradient map of vehicle to be detected by same way, carry out template matches by the mode of level retrieval.In the first stage of setting up template, abandon evenly adopting a little of traditional approach, adopt and a kind ofly adopt point mode based on vehicle region of significance non-homogeneous and build template, the gradient point that has greatly reduced template matches and be calculates, and the calculated amount of response diagram while mating.The subordinate phase forming in template base, for the gradient map that quantizes to obtain after expansion, sets up response chart according to binary numeral numerical value, then result store, and fast finding while being convenient to mate.Adopt parallel mode Rapid matching to improve matching speed in the template matches stage; Template matches is very sensitive to picture size in addition, so will be to picture size normalized.Specifically exactly the size of template image in template base is normalized, the size of the vehicle image extracting is also normalized and so both can reduces template amount in template base simultaneously, also can improve the accuracy rate of matching speed and coupling.Below the specific embodiment of the invention is further described.
1) non-homogeneous adopting a stage
Be different from conventional truck and evenly adopt method a little based on profile, this method adopts and adopts a little based on vehicle marking area is intensive, and the sparse mode of adopting a little of non-marking area is carried out sample point collection, and as shown in Figure 4, its idiographic flow is described below:
(1.1) carry out the calculating of Harris angle point, obtain respective point.Harris angle point is that level and vertical direction change point greatly.
(1.2) obtain utilize after angle point each angle point for center of circle radius R be that 6 pixels are carried out picture circle, then on the size blank image the same with vehicle template image, then find connected domain on this image.
(1.3) by the location with big or small blank image, be transplanted on the vehicle image of relevant position, thereby obtain marking area, except marking area, be defined as non-marking area.
(1.4) intensive the adopting a little of marking area of vehicle, sparse the adopting a little in non-marking area region.
2) build gradient template and realize PARALLEL MATCHING
Vehicle non-homogeneous adopt put after, further build template, carry out gradient quantification, carry out corresponding binary coding etc. and realize corresponding fast parallel coupling, its specific implementation is that specific implementation is:
(2.1) at the computed image RGB on point diagram that adopts obtaining, (rgb color pattern is a kind of color standard of industry member, by to red (R), green (G), the variation of blue (B) three Color Channels and their stacks each other obtain color miscellaneous, RGB be represent red, green, the color of blue three passages, this standard almost comprised mankind eyesights can perception all colours, to use at present one of the widest color system) image gradient of three passages, get the greatest gradient value of this o'clock in three passages for the Grad of each gradient point.In order to strengthen the ability of anti-noise jamming and illumination variation, passing threshold filters gradient image, thereby only leaves the gradient point that Grad is larger.
(2.2) for the point retaining, gradient direction is quantized, be quantified as 5 gradient directions, concrete gradient direction quantitative criteria as shown in Figure 5.The gradient direction that occurrence number is maximum in each gradient point field is as the gradient direction of this gradient point, and each direction is converted to binary coding.
(2.3) in order further to increase the noise resisting ability of characteristics of image, introduce peripheral neighborhood point, the gradient point of image is expanded, incorporate the contextual information of periphery.Specifically: press 3*3 region and divide neighborhood, appearing at the graded of the each point in region for the stack of the gradient direction occurring in neighborhood, then by binary coding mode, all directions are represented, the processing of step-by-step OR operation, obtain new gradient binary representation, its expansion process as shown in Figure 6.
(2.4) obtain after gradient image, adopt the similar mode of cosine to portray match condition, more approaching when the gradient direction at gradient point place in the gradient direction at gradient point place in template and detected image, the cosine response value of calculating is just larger, and both similarities are higher.Concrete formula is described below:
Wherein, S (Image, Template, c) represents the similarity of current region template matches; C represents current region side-play amount; Z represents template region; M represents template window corresponding region in detected image; The gradient index value of the detected image of i and t and template image.
In the process of mating, in the field at this gradient point position place in all gradient directions, have the cosine response value maximum that the gradient direction of a gradient direction and current matching obtains, so just think that this gradient direction is the gradient direction mating most.Therefore, go out N=5 corresponding to current detected image by process computation above and open gradient response diagram, the respectively corresponding gradient response diagram of each gradient direction.The formula of the table of compute gradient response is in advance:
Wherein, ζ represents the binary coded value that the set of neighborhood inside gradient direction forms; I represents the gradient direction (span is 1 to N=5) quantizing.The concrete N=5 that calculates opens gradient response table T1, T2, T3, T4, T5 process as shown in Figure 7.
(2.5) construct N=5 corresponding to current detected image and open gradient response diagram by looking into gradient response table, specifically calculate N=5 and open gradient response table M1, M2, M3, M4, M5 process as shown in Figure 8.
(2.6) while coupling, realize parallel computation, in order to realize the parallel computation of gradient response diagram, first will carry out linearization to gradient response diagram, form the linearization internal memory of the individual gradient response diagram of Cell*Cell (it is 2 that this programme is got Cell).Linearization gradient response diagram detailed process as shown in Figure 9, is opened gradient response diagram linearity by N=5 and is turned to Cell*Cell=4 row vector, be i.e. the linearization internal memory of 4 gradient response diagrams.
(2.7) realize parallel computation by linear internal memory, just can calculate the template matches similarity of multiple windows at every turn simultaneously.In matching process, find the linear internal memory of its corresponding gradient response diagram according to the gradient direction of gradient point in template image, and then the position in the region of cell*cell calculates its side-play amount in the linear internal memory (being a row vector) of corresponding gradient response diagram and is according to this gradient point:
offset=(Y/cell)*(Width/cell)+(X/cell)
Wherein, (X, Y) represents the coordinate position at the gradient point place in template image; Width represents the width of current detected image.The linear internal memory (row vector) that all gradients in template image can be put to corresponding gradient response diagram all finds, calculate again side-play amount separately, finally all row vectors are alignd by side-play amount, relevant position cosine response value is added to summation.In row vector after summation, each element is the similarity of template in this detection window, and its coordinate position corresponding to maximal value place is exactly the position at target place so.Utilize parallel computation design can increase exponentially matching speed.
The process of concrete calculating vehicle template matches similarity figure as shown in figure 10.
3) build different automobile types subspace by k-means cluster and set up level index
Set up vehicle template base index.The template number of the vehicle while coupling each time in order to reduce, to reach the requirement of carrying out in real time vehicle identification, this programme is that vehicle template base is set up index.Adopt k-means clustering method to carry out thick cluster to respective graphical, obtain two layer indexs.Ground floor template is the large class template of vehicle, and second layer template is the concrete template of vehicle.When coupling, first mate with large class template, select that the highest class of matching rate, then mate for the second time by the concrete template of vehicle corresponding to that class, thereby match concrete vehicle.Part vehicle template base index is set up example as shown in figure 11.
4) normalized of picture size
Template matching algorithm is very sensitive to picture size, so will be to picture size normalized.Specifically exactly template image in template base and vehicle image to be identified all will be normalized to unified size, specific practice is to carry out ratio scaling according to image actual aspect ratio, and concrete scaling formula is as follows:
Wherein, W
2, H
2represent figure image width and height after scaling; W
1, H
1represent figure image width and height before scaling.Carry out Matching Experiment by the vehicle template to various sizes and the vehicle image to be identified extracting, experimental result is analyzed to discovery.
(4.1) for the vehicle image to be identified extracting, the vehicle image width W after scaling
2be taken as 160 pixels.Because show by experiment under this size, the Gradient Features of acquisition is counted out and is met the double requirements of efficiency and effect.
(4.2) for vehicle template image, the vehicle template image width W after scaling
2be taken as respectively 155,145,135,125 pixels.Because the vehicle image to be identified extracting can not guarantee that being is whole vehicle size just, have a small amount of non-vehicle region around, but experimental analysis discovery, this non-vehicle region is roughly distributed in certain scope.Therefore analyze by experiment, draw W
2be taken as respectively four sizes of 155,145,135,125 pixel.Specifically as shown in figure 12.
5) vehicle matching process
The matching process that vehicle is concrete is as follows:
(5.1) vehicle image extracting is carried out to picture size normalized (picture size normalized).
(5.2) index of reference template is carried out PARALLEL MATCHING, from this three class template, selects that the highest class of matching similarity.
(5.3) mate for the second time by the concrete template of such corresponding vehicle, thereby match concrete vehicle.
As shown in figure 13, vehicle matching process has been described as an example of " van " example:
In the technical program, do not affecting on the basis of matching effect, to the image after normalized, improve matching efficiency by a kind of nonuniform sampling mode, the binary coding forming after expanding by gradient, the robustness that has not only increased vehicle sign also lays the foundation for the fast zoom table of follow-up parallel computation, carries out Secondary Match in conjunction with the vehicle of the level index of setting up based on thick cluster, has further improved the speed of coupling.This programme has been set up a kind of efficient, and vehicle detects fast.