Real-time vehicle detecting 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 car based on traffic video
Type detecting system.
Background technology
Automobile is widely used as the quick vehicles the most easily, but the increasing rapidly to city of its quantity in recent years
City's traffic brings immense pressure, also allows the work of corresponding management personnel become the heaviest.Along with computer
Vision technique and the fast development of hardware product, in order to solve these the most serious traffic problems, intelligence is handed over
Way system arises at the historic moment (Intelligent Transportation Systems is called for short ITS), Qi Zhongche
Type identification is the important composition composition of intelligent transportation system, about some existing correlation techniques of vehicle cab recognition
Have also been obtained extensively application.Specific vehicle is shown by these technology in some occasions with steady-state conditions
Good effect, such as bus, three box car etc..
Present vehicle cab recognition is concentrated mainly on vehicle feature description and vehicle template profile matching, vehicle feature
Describe the feature description mainly obtaining vehicle from the video image that monitoring device collects, thus portray car
Type, reaches the purpose of vehicle detection in video.The current main feature describing vehicle concentrates on Harris angle
The single features such as some feature, HOG feature, Gabor characteristic, and SIFT feature, or single features is carried out
Combination, the union feature of formation.
And about the vehicle template base describing mainly the most how Criterion of vehicle template and template search mechanism,
By obtaining target on the video image that collects from monitoring device, then by the target obtained and vehicle template
Storehouse corresponding template is mated, so that it is determined that relevant vehicle.Unrestricted opening it mostly is residing for automobile
Environment, 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.
One of retrieval prior art: In South China Polytechnics Huang writing brush, Lin Zhenze, Zhu provide naughty etc. invention " base
Vehicle automatic identifying method in vehicle frontal image Yu template matching ", publication number: CN103324920A.
A kind of vehicle automatic identifying method based on vehicle frontal image Yu template matching of this disclosure of the invention,
On gray level image, determine vehicle region by car plate, and set up the vehicle template of unified size, enter in template
Row associated gradients calculates, and puts into neutral net and is trained, export eight class vehicle results after Grad normalization.
This vehicle algorithm flow is as shown in Figure 1.
In the prior art, first the vehicle frontal image collected is carried out gray processing and obtain gray-scale map, and
Calculating the transverse gradients figure of gray-scale map, reason is to consider car plate shape and placement feature, passes through transverse gradients
Figure easily obtains car plate position and calculates car plate width.
In the prior art, because car plate width, the information such as position is fixing mostly, leads in this way
Cross the transverse gradients figure defined location obtained and by relevant scaling, substantially centered by the position obtained
Vehicle region can be obtained, zoom in feature extraction template unified for the region obtained,
In the prior art, according to the template Grad obtained, it is normalized, obtains related data
The feature judged as vehicle, is input to neutral net, the neural network model obtained by training, then
This model is utilized to obtain the vehicle information of detection data output.
The prior art has a disadvantage in that the gradient information of this patent utilization vehicle, it is thus achieved that car plate is correlated with
Width and positional information thereby determine that vehicle template, but single utilization gradient information and do not account for reference point week
Enclose the impact of gradient, make vehicle characteristics statement lack completeness, wrong report can be caused to a certain extent.It addition,
Use its convergence rate of neural metwork training slow, there is the shortcomings such as local extremum, and the training of neutral net
Result is too dependent on the vehicle sample of selection.
The two of retrieval prior art: China Petroleum Univ. (East-China) ancestor people Lee, public super, the Liu Yujie's of thread etc.
Invention " a kind of dynamic vehicle model recognizing method in intelligent transportation system ", CN103258213A.
A kind of dynamic vehicle model recognizing method in intelligent transportation system of this disclosure of the invention.First instruct
The white silk stage utilizes the image zooming-out HOG feature after normalization and describes the GIST feature of overall texture, as
Input obtains two graders by SVM respectively.When then detecting, combine D-S by two graders obtained
Output result is merged by evidence theory, obtains maximum of probability, thus completes vehicle cab recognition, and this algorithm is concrete
Process is as shown in Figure 2.
In the prior art, first introduce the GIST of HOG feature and whole description in training and test phase
Feature, information when overcoming single features to describe vehicle is certain, has merged overall and local feature.
In the prior art, after two features obtain, SVM is utilized to respectively obtain based on two features in the training stage
Two discrimination model, when test judges vehicle, by defeated to HOG feature and the GIST feature of detection vehicle
Enter the discrimination model that trains and obtain correlation output, the basis of the cascading judgement that is formed for knowing clearly.
In the prior art, utilize two SVM models dependent probability to the judgement vehicle that detection vehicle obtains,
Having been merged the relevant information of two SVM outputs by D-S theory, thus obtained most probable value, this is maximum
The vehicle classification that probit is corresponding, is the classification of current vehicle to be identified, so far achieves cascading judgement car
Type, it is thus achieved that final detection result.
The prior art has a disadvantage in that this patent utilization describes HOG feature and the entirety at edge
GIST feature, enhances the robustness characterizing vehicle, and the discrimination model that this patent is to being respectively trained out
Testing result carried out information fusion, it is achieved that cascading judgement.But the method needs training and detection accurately
Property is largely affected by sample set, but sample set can not comprise the vehicle under all ambient conditions,
In practical engineering application, the accuracy of its vehicle detection can not ensure.
Summary of the invention
It is an object of the invention to provide a kind of can apply in real time in intelligent transportation system based on traffic video
Vehicle detection technique.
For achieving the above object, the present invention adopts the following technical scheme that a kind of real-time based on traffic video
Vehicle detecting system, mates two parts including on training under line and line;
Described Xian Xia training department divides and comprises the following steps: (1) calculates Harris angle point, it is thus achieved that marking area;
Then sampling site intensive to marking area, sampling site sparse to non-significant region;(2) image after sampling site completes
In, calculate corresponding extension gradient and form vehicle Prototype drawing, the binary coding of driving section mould plate figure of going forward side by side,
Prestore gradient response chart according to cosine is similar, complete parallel computation design;(3) finally according to vehicle
The mode that the difference of feature description utilizes k-means to cluster builds different subspace, sets up stratified vehicle
Template index, logging template relevant information;
On described line, coupling comprises the following steps: (1) obtains vehicle image to be identified by under traffic scene;
(2) calculating marking area and the non-significant region of image vehicle, the most non-homogeneous sampling site obtains gradient map;(3)
Gradient point is extended and binary coding;(4) by the similar acquisition of cosine corresponding gradient response diagram;(5)
The mode using parallel computation carries out fast zoom table coupling;(6) vehicle matching result is obtained, it is judged that vehicle,
Complete vehicle detection.
Train in the step (1) of part under described line, calculate obtain marking area and non-significant region non-all
The detailed step of the gradient map of even sampled point is:
(1.1) the Harris angle point on vehicle wheel profile is first obtained;
(1.2) with Harris angle point as the center of circle, neighborhood of pixels radius R=6 draws circle to size and vehicle Prototype drawing
In blank image as, then on this image, find connected domain, thus orient the aobvious of vehicle image
Write region;
(1.3) obtain the intensive sampling site of marking area, non-significant region carry out sparse sampling site;Calculate non-
The image gradient of tri-passages of RGB of the image after uniform sampling, the Grad for each gradient point takes this
Greatest gradient value o'clock in three passages;Then retain, by threshold value, the gradient point that Grad is bigger;?
The gradient tried to achieve, is quantified as N (such as N=5) individual gradient direction, then occurring in each gradient point neighborhood
The most gradient direction of number of times is as the gradient direction of this gradient point;
(1.4) gradient direction after quantifying carries out corresponding binary coding, by gradient direction with a length of
The binary string of N=5 represents, forms the gradient map of binary representation.
The step (2) training part under described line also includes obtaining the Gradient Features information of template and prestoring
Response table, comprises the following steps:
(2.1) extension of image gradient point is that the image gradient figure to binarization processes, and gradient point extends
Process carries out gradient extension (i.e. by step-by-step "or" in T × T (such as T=3) neighborhood to each gradient point
Operation processes, and makes each point contain radius by the gradient direction occurred in the neighborhood of T/2), thus obtain
Binary coding figure after must extending;
(2.2), after obtaining the gradient image after extension, the similarity of template matching uses and asks for cosine similarity
Method realize;During coupling, this gradient point in all gradient directions, has in T × T neighborhood
Cosine response value obtained by the gradient direction of one gradient direction and current matching is maximum, then be considered as this
Gradient direction is the gradient direction mated most;Because gradient is quantified as N=5 grade, open so obtaining N=5
Gradient response diagram, each gradient direction respectively corresponding gradient response table, each gradient response table with
The maximum cosine response value of the neighborhood inside gradient direction set representated by binary coding is to precompute
Come, be saved in internal memory for the maximum cosine response value searched corresponding to coding.
Training in the step (3) of part under described line, K-means cluster determines vehicle subspace, sets up layer
Secondary sex cords draws and comprises the following steps:
(3.1) search element speed, the template number of vehicle when minimizing is mated each time to improve, adopt
With k-means clustering method, template base figure is slightly clustered according to outward appearance;Form different vehicle spaces to divide
Cloth;
(3.2) on the basis of vehicle spatial distribution, vehicle template base is divided into two-layer and sets up level index,
Ground floor template is the big class template of vehicle, and second layer template is the concrete template of vehicle.
On described line, the step (1) of compatible portion obtains vehicle detection image to be identified, first passes through mixing height
The mode of this model and adaptive RTS threshold adjustment obtains vehicle detection image to be identified;In this step,
Remove unnecessary prospect as much as possible, reduce the computer capacity of subsequent match algorithm, improve detection efficiency.
The step (2) of compatible portion calculates on described line the gradient obtaining vehicle nonuniform sampling point to be identified
Figure comprises the following steps:
(2.1) the Harris angle point on vehicle wheel profile is first obtained;
(2.2) with Harris angle point as the center of circle, R=6 pixel of radius draws circle to size and vehicle Prototype drawing
In blank image as, then on this image, find connected domain, thus orient the aobvious of vehicle image
Write region;
(2.3) obtain the intensive sampling site of marking area rather than marking area carry out sparse sampling site.Meter
Calculating the image gradient of tri-passages of RGB of the image after nonuniform sampling, the Grad for each gradient point takes
This some greatest gradient value in three passages.Then retain, by threshold value, the gradient point that Grad is bigger.
The gradient tried to achieve, it is quantified as N (N=5 in this programme) individual gradient direction, then that each gradient point is adjacent
The gradient direction that in territory, occurrence number is most is as the gradient direction of this gradient point;
(2.4) gradient direction after quantifying carries out corresponding binary coding, by gradient direction with a length of
The binary string of N=5 represents, forms the gradient map of binary representation.
On described line, in the step (3) of compatible portion, vehicle gradient point to be detected extends and binary coding, its
The extension of middle image gradient point is that the image gradient figure to binarization processes, and gradient point expansion process is to often
Individual gradient point carries out gradient extension (i.e. by step-by-step OR operation in T × T (T=3 in this programme) neighborhood
Process, make each point contain radius by the gradient direction occurred in the neighborhood of T/2), thus obtain expansion
Binary coding figure after exhibition.
The step (4) of compatible portion calculates gradient response diagram, wherein at gradient point position on described line
T × T (T=3) neighborhood in all gradient directions, have the gradient side of a gradient direction and current matching
Maximum to obtained cosine response value, then being considered as this gradient direction is the gradient direction mated most.
On described line, the calculation of falling into a trap of the step (5) of compatible portion is mated, and comprises the following steps:
(5.1) in order to improve the speed of algorithm further, the parallel computation of gradient response diagram is used.The most right
Gradient response diagram carries out linearisation, is formed in the linearisation of cell*cell (taking cell=2 herein) individual gradient response diagram
Deposit.5 gradient response diagrams are linearly turned to 4 (cell*cell=4) individual row vector;
(5.2) realize parallel computation by linear internal memory, just can calculate the mould of multiple window every time simultaneously
Plate matching similarity.In the matching process, mate by template base Hierarchy template, according in template image
The gradient direction of gradient point finds the linear internal memory of the gradient response diagram of its correspondence, then further according to this gradient point
It (is one that position in the region of cell*cell calculates it at the linear internal memory of corresponding gradient response diagram
Row vector) in side-play amount;
(5.3) finally all row vectors are alignd by side-play amount, relevant position cosine response value is added
Summation.The similarity of template during each element is this detection window in row vector after summation, then it
Coordinate position corresponding at maximum is exactly the position at target place.
In this programme, N, T and cell are the natural number more than 0, preferably N=5, T=3, cell=2.
The invention has the beneficial effects as follows: in the solution of the present invention, vehicle detection is applicable to nearly all vehicle
Coherent detection, high for template vehicle detection complexity, the slow-footed problem in search pattern storehouse, this programme
By the intensive sampling site of vehicle marking area after size normalized, the sparse sampling site in non-significant region non-
The sides such as uniform sampling mode, obtains sampled point, then carry out gradient extension on sampled point, binary coding
Formula sets up the vehicle template being easy to parallel computation, and is slightly clustered vehicle outward appearance etc. by k-means cluster
Set up different automobile types space, set up the search of multi-level vehicle, concrete matching process uses obtain in advance and count under line
Calculate parallel internal memory when obtaining gradient response table, coupling to calculate, by the cosine similar calculating fast zoom table of responsiveness,
Real-time to vehicle detection, the aspect such as accuracy in detection had had more preferable effect than former scheme.
Accompanying drawing explanation
Fig. 1 is the flow chart of prior art one;
Fig. 2 is the flow chart of prior art two;
Fig. 3 is vehicle targets flow chart of the present invention;
Fig. 4 is to obtain based on marking area and non-significant area non-uniform point flow process;
Fig. 5 is that gradient quantifies and corresponding binary scale coding;
Fig. 6 is the gradient extension of image and forms binary-coded gradient map process;
Fig. 7 is to precalculate gradient response table;
Fig. 8 is to calculate gradient response diagram;
Fig. 9 is gradient response diagram linearisation;
Figure 10 is to calculate vehicle template matching similarity graph;
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 displaying figure.
Detailed description of the invention
The invention will be further described below in conjunction with the accompanying drawings.
Embodiment 1: a kind of real-time vehicle detecting system based on traffic video, the present invention uses the mould of improvement
Plate matching process, obtains sampled point by the way of a kind of nonuniform sampling, throughput on the basis of sampled point
Change gradient, and gradient direction after quantifying is carried out gradient extension binary representation, it is thus achieved that respective extension gradient
Figure, thus set up template, and the mode that slightly clustered by k-means sets up the template base of level;Then phase is passed through
Obtain the extension gradient map of vehicle to be detected with mode, carry out template matching by the mode of level retrieval.Building
The first stage of shuttering, abandon the uniform sampling site of traditional approach, used a kind of based on vehicle region of significance
Non-homogeneous sampling site mode builds template, greatly reduces the gradient point calculating that template matching is, and rings during coupling
Should the amount of calculation of figure.In the second stage that template base is formed, for the gradient map obtained after quantifying extension, root
Set up response chart according to binary numeral numerical value, then result is stored, it is simple to quickly search during coupling.?
The template matching stage uses parallel mode Rapid matching to improve matching speed;Additionally template matching is to picture size
Very sensitive, so will be to picture size normalized.Particularly as being by the size of template image in template base
It is normalized, the size of the vehicle image extracted is also carried out normalization simultaneously and the most both can reduce mould
Template amount in plate storehouse, it is also possible to improve matching speed and the accuracy rate of coupling.Below the present invention is embodied as
Mode is further described.
1) the non-homogeneous sampling site stage
Being different from conventional truck method based on the uniform sampling site of profile, this method uses based on vehicle marking area
Intensive sampling site, the mode of the sparse sampling site in non-significant region carries out sample point collection, and as shown in Figure 4, it specifically flows
Journey is described as follows:
(1.1) Harris angle point calculating is carried out, it is thus achieved that respective point.Harris angle point is that horizontally and vertically direction becomes
Change big point.
(1.2) utilizing each angle point after obtaining angle point is that 6 pixels carry out picture circle, then for center of circle radius R
In size blank image as vehicle template image, then on this image, find connected domain.
(1.3) by the location of the blank image with size, it is transplanted on the vehicle image of relevant position, from
And obtain marking area, in addition to marking area, it is defined as non-significant region.
(1.4) in the intensive sampling site of marking area of vehicle, the sparse sampling site of non-significant regions.
2) build gradient template and realize PARALLEL MATCHING
After the non-homogeneous sampling site of vehicle completes, template to be built further, carry out gradient quantization, carry out corresponding
Binary codings etc. realize corresponding fast parallel coupling, and it implements is to implement to be:
(2.1) (rgb color pattern is a kind of face of industrial quarters to calculate image RGB on the sampling site figure obtained
Colour standard, be by red (R), green (G), the change of blue (B) three Color Channels and they each other
Superposition obtain color miscellaneous, RGB is i.e. the color representing three passages of red, green, blue,
This standard almost include human eyesight can all colours of perception, be to use the widest cie system of color representation cie at present
One of system) image gradient of three passages, the Grad for each gradient point takes this o'clock in three passages
Greatest gradient value.In order to strengthen the ability of anti-noise jamming and illumination variation, by threshold value to gradient image
Filter, thus leave behind the gradient point that Grad is bigger.
(2.2) for the point retained, gradient direction is quantified, is quantified as 5 gradient directions, specifically
Gradient direction quantitative criteria is as shown in Figure 5.Gradient directions most for occurrence number in each gradient point neighborhood
As the gradient direction of this gradient point, and each direction is converted into binary coding.
(2.3) in order to increase the noise resisting ability of characteristics of image further, peripheral neighborhood point is introduced, to image
Gradient point be extended, incorporate the contextual information of periphery.Specifically: divide neighborhood by 3*3 region,
The superposition being the gradient direction occurred in neighborhood the graded of each point occurred in region,
Then being indicated all directions by binary coding mode, step-by-step OR operation processes, it is thus achieved that new
Gradient binary representation, its expansion process is as shown in Figure 6.
(2.4) after obtaining gradient image, the mode using cosine similar portrays match condition, when ladder in template
In the gradient direction at degree point place and detected image gradient direction at gradient point closer to, then calculate
Cosine response value is the biggest, and both similarities are the highest.Concrete formula is described as follows:
Wherein, (Image, Template c) represent the similarity of current region template matching to S;C represents current region
Side-play amount;Z represents template area;M represents the region that template window is corresponding in detected image;I and t quilt
Detection image and the gradient index value of template image.
During mating, in the neighborhood at this gradient point position in all gradient directions, have
Cosine response value obtained by the gradient direction of one gradient direction and current matching is maximum, then be considered as this
Gradient direction is the gradient direction mated most.Therefore, current detected image is calculated by process above
Corresponding N=5 opens gradient response diagram, the most corresponding gradient response diagram of each gradient direction.Count in advance
The formula calculating gradient response table is:
Wherein, ζ represents the binary coded value that the set of neighborhood inside gradient direction is formed;I represents the gradient of quantization
Direction (span is 1 to N=5).The concrete N=5 that calculates opens gradient response table T1, T2, T3, T4, T5
Process is as shown in Figure 7.
(2.5) N=5 constructing current detected image corresponding by looking into gradient response table opens gradient response diagram,
The concrete N=5 that calculates opens gradient response table M1, M2, M3, M4, M5 process as shown in Figure 8.
(2.6) parallel computation is realized during coupling, in order to realize the parallel computation of gradient response diagram, first will be to ladder
Degree response diagram carries out linearisation, forms the line of Cell*Cell (it is 2 that this programme takes Cell) individual gradient response diagram
Property internal memory.Linearisation gradient response diagram detailed process as it is shown in figure 9, open gradient response diagram linearisation by N=5
Linearisation internal memory for Cell*Cell=4 row vector, i.e. 4 gradient response diagrams.
(2.7) realize parallel computation by linear internal memory, just can calculate the mould of multiple window every time simultaneously
Plate matching similarity.In the matching process, find it corresponding according to the gradient direction of gradient point in template image
The linear internal memory of gradient response diagram, then count further according to this gradient point position in the region of cell*cell
Calculating its side-play amount in the linear internal memory (being a row vector) of corresponding gradient response diagram is:
Offset=(Y/cell) * (Width/cell)+(X/cell)
Wherein, the coordinate position at the gradient point place during (X, Y) represents template image;Width represents current detected
The width of image.Then can by the linear internal memory of gradient response diagram corresponding for gradient point all in template image (OK
Vector) all find, then calculate respective side-play amount, finally all row vectors are alignd by side-play amount,
Relevant position cosine response value carries out being added summation.In row vector after summation, each element is this detection window
The similarity of template in Kou, then coordinate position corresponding at its maximum is exactly the position at target place.
Utilize parallel computation design can increase exponentially matching speed.
The process of concrete calculating vehicle template matching similarity graph is 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.In order to reduce the template number of vehicle when mating each time, with
Reaching to carry out in real time the requirement of vehicle cab recognition, this programme is that vehicle template base sets up index.K-means is used to gather
Respective graphical is slightly clustered by class method, it is thus achieved that two layer indexs.Ground floor template is the big class template of vehicle,
Second layer template is the concrete template of vehicle.During coupling, first mate with big class template, select matching rate
That high class, then carry out mating for the second time by the concrete template of the vehicle that class is corresponding, thus match concrete car
Type.Part vehicle template base index sets 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.Particularly as
It is to be intended to normalize to unified size, specific practice by template image in template base and vehicle image to be identified
Being to carry out scale according to image actual aspect ratio, concrete scaling formula is as follows:
Wherein, W2、H2Represent the figure image width after scaling and height;W1、H1Represent the figure image width before scaling and height.
By the vehicle template of various sizes is mated experiment, to reality with the vehicle image to be identified extracted
Test result to be analyzed finding.
(4.1) the vehicle image width W for the vehicle image to be identified extracted, after scaling2It is taken as
160 pixels.Because being shown experimentally that under this size, it is thus achieved that Gradient Features count out meet efficiency and
The double requirements of effect.
(4.2) the vehicle template image width W for vehicle template image, after scaling2Be taken as 155 respectively, 145,
135,125 pixel.Because it is the most whole vehicle that the vehicle image to be identified extracted does not ensures that
Size, around has a small amount of non-vehicle region, but experimental analysis finds, this non-vehicle region is substantially distributed in
In certain scope.Therefore by experimental analysis, W is drawn2It is taken as 155,145,135,125 respectively
Four sizes of pixel.The most as shown in figure 12.
5) vehicle matching process
The matching process that vehicle is concrete is as follows:
(5.1) vehicle image extracted is carried out picture size normalized (at picture size normalization
Reason).
(5.2) index of reference template carries out PARALLEL MATCHING, from this three class template, selects matching similarity the highest
That class.
(5.3) carry out second time by the concrete template of the vehicle of such correspondence to mate, thus match concrete vehicle.
As shown in figure 13, as a example by " van ", vehicle matching process is illustrated:
In the technical program, on the basis of not affecting matching effect, to the image after normalized, logical
Cross a kind of nonuniform sampling mode and improve matching efficiency, the binary coding formed after being extended by gradient, no
Increase only vehicle characterize robustness also lay the foundation for the fast zoom table of follow-up parallel computation, in conjunction with based on
The vehicle of the level index that thick cluster is set up carries out Secondary Match, further increases the speed of coupling.We
Case establishes a kind of efficient, and quick vehicle detects.