Embodiment
Because distance is very big in the class of automobile, difference such as color, shape is very big between the different vehicle, thereby the embodiment of the invention adopts edge orientation histogram (HOG) feature of the edge contour information between automobile and background that can embody, and adopt level type self-adaptation quick and that be easy to realize to strengthen (AdaBoost) sorter, fast and accurately realize Automobile Detection and tracking.In order further to improve Automobile Detection speed, the embodiment of the invention is attached to movable information in the Automobile Detection.Simultaneously, utilize the positional information of automobile and colouring information etc. to carry out the automobile coupling, obtain the automobile trace information, and adopt the automobile trace information that traveling automobile on the highway is counted, with the statistics magnitude of traffic flow.
Below in conjunction with accompanying drawing, the technical scheme that the embodiment of the invention is provided describes in detail.
Referring to Fig. 1, for speed and the effect that improves Automobile Detection, the method that the mode that the employing that the embodiment of the invention provides combines level type Adaboost and HOG feature detects automobile comprises:
S101, determine the horizontal direction of the image that collects and the edge of vertical direction respectively.
The direction at the edge of S102, calculating discretize, and, edge calculation intensity.
S103, employing histogram mode edge calculation histogram HOG.
S104, employing auto graph are positive sample, and other non-auto graph is anti-sample, and training is based on the quick separation vehicle device of level type Adaboost and HOG.
S105, adopt quick separation vehicle device, determine the automobile position in the input picture based on level type Adaboost and HOG.
Referring to Fig. 2, level type Adaboost structure for all candidate window, adopts the ground floor sorter to judge earlier as shown in Figure 1, if can pass through the ground floor sorter, then adopts second layer sorter to proceed to judge, otherwise, directly refuse.In like manner, carry out follow-up each layer processing, can pass through the rectangular area of all layers sorter as candidate's automobile zone (abbreviation candidate frame).
Above-mentioned each layer sorter (being called strong classifier) all is made up of a plurality of Weak Classifiers, and the weighted sum of the Weak Classifier output in every layer of strong classifier and the threshold value of this layer strong classifier compare resulting result, are the output of this layer strong classifier.AdaBoost strong classifier building method has a variety of, and is commonly used as Discrete-AdaBoost, Real-AdaBoost and Gentle-AdaBoost etc., can be used for constructing above-mentioned each layer strong classifier.The corresponding weak feature of each Weak Classifier, the make of Weak Classifier also has a variety of, can select the above-mentioned Weak Classifier of structure for use.Simple as Weak Classifier building method based on threshold value:
Wherein, x is the input picture of fixed size, g
j(X) represent the weak eigenwert of j of this image correspondence, θ
jBe the decision threshold of j weak feature correspondence, polarity sign p
jValue be 1 or-1, work as p
jBe 1 o'clock, the judgement symbol of decision device is a greater-than sign, works as p
jBe at-1 o'clock, the symbol of decision device is an is less than, h
j(x) the judgement output of j Weak Classifier of expression.Like this, each Weak Classifier threshold ratio that only need carry out once just can be finished judgement.
Preferably, on the make of Weak Classifier, in order to improve the classification capacity of Weak Classifier, the embodiment of the invention adopts the manner of comparison of dual threshold to construct Weak Classifier, each Weak Classifier is set by two threshold value (q
j 1And q
j 2, and q
j 1<q
j 2) and a polarity sign (p
j, p
jValue be 1 or-1) form.
Work as p
jBe 1 o'clock, Weak Classifier is defined as:
Work as p
jBe at-1 o'clock, Weak Classifier is defined as:
Wherein, x is the image of fixed size, g
j(X) corresponding j the weak eigenwert of presentation video, h
j(x) the judgement output of j Weak Classifier of expression.
The make of the Weak Classifier that the embodiment of the invention proposes, more pervasive than the mode that prior art proposes.Work as p
jBe 1, and q
j 2During for positive infinity,
Be converted to
Middle p
j=1 situation; Work as p
jBe 1, and q
j 1During for negative infinitesimal,
Be converted to
Middle p
j=-1 situation.That is to say that the dual threshold mode of embodiment of the invention proposition has included the situation of single threshold.
In the Weak Classifier training step, to current feature g
j(X), select p
j, q
j 1And q
j 2, make Weak Classifier that this weak feature forms weighting error rate minimum to all samples.Therefore, the embodiment of the invention has increased the possible form of candidate's Weak Classifier, thereby makes it possible to select the stronger Weak Classifier of classification capacity, thereby improves the performance of strong classifier and even final level type AdaBoost sorter.
In addition, the embodiment of the invention also can adopt the look-up table Weak Classifier building method structure Weak Classifier that proposes in the prior art.
It should be explicitly made clear at this point that the weak feature in the embodiment of the invention refers to certain accumulated value of the edge orientation histogram correspondence in certain rectangular area.Wherein, the edge orientation histogram in certain zone is defined as the accumulative histogram of each pixel on each discretize edge direction (total DN the direction of supposition) in this rectangular area.Introduce the concrete acquiring method of edge orientation histogram (HOG) below.
Among the step S101, ask for the horizontal edge and the vertical edge of each pixel on the image respectively, the acquiring method of image border has a lot, and commonly used is Sobel and Prewitt operator.The Sobel operator is distributed as in the detection template of level and vertical direction:
With
The Prewitt operator is respectively in the detection template of level and vertical direction:
With
Above-mentioned template is that template is asked at the edge of gray level image.The embodiment of the invention has provided a kind of directly method at computed image edge in the hyperchannel coloured image.Suppose the current pixel point coordinate for (x, y), and the corresponding vectorial CV of all colours channel value of this pixel (x, y), then (x, y) and (x ', y ') two pixel color differences be the norm of the difference of two pixel corresponding color vectors, be NORM (CV (x, y)-CV (x ', y ')).Norm can be (but being not limited to) 1 norm, 2 norms or infinite norm.
The Sobel horizontal edge computing method of coloured image are as follows:
NORM(CV(x+1,y-1)-CV(x-1,y-1))+NORM(CV(x+1,y+1)-CV(x-1,y+1))+2*NORM(CV(x+1,y)-CV(x-1,y))。
The Sobel vertical edge computing method of coloured image are as follows:
NORM(CV(x-1,y+1)-CV(x-1,y-1))+NORM(CV(x+1,y+1)-CV(x+1,y-1))+2*NORM(CV(x,y+1)-CV(x,y-1))。
The Prewitt horizontal edge computing method of coloured image are as follows:
NORM(CV(x+1,y-1)-CV(x-1,y-1))+NORM(CV(x+1,y+1)-CV(x-1,y+1))+NORM(CV(x+1,y)-CV(x-1,y))。
The Prewitt vertical edge computing method of coloured image are as follows:
NORM(CV(x-1,y+1)-CV(x-1,y-1))+NORM(CV(x+1,y+1)-CV(x+1,y-1))+NORM(CV(x,y+1)-CV(x,y-1))。
Among the step S102, edge direction is carried out discretize, the edge direction and the edge strength of trying to achieve discretize are specific as follows:
The horizontal edge of supposing the current pixel point of trying to achieve is EH, and vertical edge is EV, further needs to calculate the direction and the intensity at this pixel edge, supposes that direction is ED, and intensity is EI.Wherein, edge direction has two kinds of definition modes, and a kind of is signless edge direction, and promptly the scope of edge direction is 0 to 180 degree, thinks that the edge direction that differs 180 degree is same direction.Another is the edge direction that symbol is arranged, and edge direction is 0 to 360, thinks that the direction that differs 180 degree is a different directions.Only provide the discretization method of no symbol edge direction in the embodiment of the invention.Suppose to turn to N interval with signless edge direction is discrete, the situation when N=6 as shown in Figure 3.A kind of computing formula of edge strength is
, also can for | EH|+|EV|, the no symbol edge direction among Fig. 3 is
Wherein arccot represents to ask for the inverse function of cotangent function, and then the edge direction of discretize is:
But, adopt above-mentioned definition to calculate ED earlier, the speed of calculating NED then is slow.Preferably, the method for a kind of quick calculating NED of embodiment of the invention proposition comprises:
The first step judges whether EH is 0, if EH is 0, then setting NED is 0; Otherwise, carried out for second step and handle.
In second step, initialization i=0 calculates
Value.
In the 3rd step, judge
Whether less than
, if then execution in step the 6th goes on foot; Otherwise, forwarded for the 4th step to.
In the 4th step, i increases by 1.
In the 5th step, whether judge i less than N-1, if then forwarded for the 3rd step to; Otherwise, the 6th step of execution in step.
In the 6th step, setting NED is i, withdraws from flow process.
Then the edge orientation histogram HOG in certain image-region R is defined as the edge strength of all pixels on all directions in this zone accumulation and, that is:
Wherein, (x y) represents certain pixel coordinate to P, and (P (x, y)) represents the edge strength of this pixel to EI, and (P (x, y)) represents the edge direction of this pixel to ED.
When step S104 trains quick separation vehicle device, at first need to gather and extract automobile sample and other non-automobile samples of standard, and be normalized to fixed size (width such as image is W, highly is H), this size is the size of the Automobile Detection device of training.
For the AdaBoost training algorithm, need construct feature set a little less than the candidate for it.A kind of feasible embodiment is to adopt the value of edge orientation histogram on certain discretize edge direction of the setting rectangular area (being called sub-rectangle) in the image-region of subscribing yardstick as weak feature.The edge orientation histogram correspondence of the sub-rectangle of all existence feature a little less than the value on all discretize directions is the candidate then.For width is W, highly is the image-region of H, and sub-rectangular set is:
{R(left,top,right,bottom)|0≤left<right<W,0≤top<bottom<H}
Wherein, left, top, right, bottom represent left frame, upper side frame, the left frame of sub-rectangle, the position coordinates of lower frame respectively, promptly wide be W, high for any rectangle in the image range of H all in sub-rectangular set, can overlap mutually between this a little rectangle.In order to reduce operand, improve training speed, can limit the width and the altitude range of sub-rectangle, and the spacing between each sub-rectangle left frame and the upper side frame.The width minimum value of setting sub-rectangle is WMin, and the width maximal value is WMax, and the height minimum value is HMin, the height maximal value is HMax, minimum horizontal distance and minimum perpendicular distance are 1 between sub-rectangle, and the sub-rectangle that then sub-rectangular set comprises is: R (left, top, right, bottom), wherein left gets W-wr from 0, and top gets H-hr from 0, wherein wr gets WMax from WMin, and hr gets HMax from HMin.WMin can be taken as 1, and WMax is taken as W, and HMin can be taken as 1, and HMax is taken as H.
For each the sub-rectangle in the above-mentioned sub-rectangular set, all there is a direction gradient histogram Hist, this Hist is a vector, contains N element altogether.The sub-rectangle number of supposing above-mentioned setting is NR, then total NR*N the direction histogram element of all sub-rectangles.Regard each direction histogram element as a weak feature, then the AdaBoost algorithm obtains common NR*N weak feature.
For the AdaBoost algorithm, weak feature database need be set, comprise much being used for selecteed weak feature.Adopt above-mentioned NR*N direction histogram unit that weak feature database usually is set in the embodiment of the invention.
But, directly according to formula
The histogrammic operand of calculated direction can be very big, therefore, the embodiment of the invention adopts the quick edge calculation direction histogram of integral image HOG, promptly the edge strength by each edge direction of all pixels after discretize in the candidate rectangle zone on the edge direction integral image calculating input image with, specific as follows:
Suppose that the edge gradient direction is turned to N direction by discrete, then calculate the edge direction integral image of N direction respectively, the edge direction integral image of supposing n direction is at point (x, y) value be II (x, y, n), as shown in Figure 4, the edge direction integral image of n direction point (x, the value defined of y) locating for all the edge discretize directions in the grey rectangle zone in its upper left corner be n pixel edge strength with, that is:
The mode that adopts following iteration obtains the edge direction integral image of all directions for one time to edge direction and edge strength image from the grey rectangle sector scanning in the upper left corner:
Handle all N direction successively.Suppose when pre-treatment be n direction, adopt rs (x, y, n) expression y capable arrive current pixel (x, y) till all edge directions of (comprising current pixel) be the edge strength sum of the pixel of n, that is:
Then adopt following formula iterative computation edge direction integral image:
If NED (x y) is n, then rs (x, y, n)=rs (x-1, y, n)+EI (x, y); Otherwise, rs (x, y, n)=rs (x-1, y, n); And then have: II (x, y, n)=II (x, y-1, n)+rs (x, y, n).
Concrete implementation is as follows:
To any n=0,1,2...N-1, carry out following processing:
To any y=0,1,2...H-1 and x=0,1,2...W-1, setting II (1, y, n)=0, II (x ,-1, n)=0;
To all row of image, according to y=0,1, the order of 2...H-1 is carried out following processing:
Set rs=0 represent the current line edge direction be n all pixel edge intensity and initial value be 0;
All pixels to image y in capable are docile and obedient preface x=0, and 1,2...W-1 carries out following processing:
If NED (x y) is n, then make rs=rs+EI (x, y);
Otherwise, keep rs constant;
And then calculate:
II(x,y,n)=II(x,y-1,n)+rs;
Then calculate the capable edge direction integral image of y+1 after having calculated the capable edge direction integral image of y.
After all capable disposing to image, finish the calculating of edge direction integral image.
Viola propose a kind of quick calculating rectangular area interior pixel brightness and method, this method can be expanded and be used for edge calculation direction integral image, for each edge direction, need W*H s (x, y, n) write down every row pixel edge direction till the current pixel be n pixel edge strength and.And the embodiment of the invention to adopt every row all edge directions of (comprising current pixel) till the current pixel be the edge strength of n and (be that rs (x, y, n)) comes recursion calculated product partial image.The embodiment of the invention is when the calculated product partial image, according to from top to bottom, from left to right order recursion calculates, therefore embodiment of the invention method only need be preserved the rs (x of current pixel, y) be rs, can save internal memory widely, for the higher application of some request memories, such as chip design, the method that adopts the embodiment of the invention to provide has more advantage.
Adopt above-mentioned edge direction integral image can ask for the edge orientation histogram HOG that rectangular area inward flange direction is n fast.Suppose rectangle D (left, top, right, bottom) in, edge direction is that the edge orientation histogram of n is Hist (n, D), as shown in Figure 5, wherein shadow region A, B, C, D represent a rectangular area respectively, and point 1,2,3,4 is the summit, the lower right corner of corresponding region A, B, C, D respectively, according to the definition of edge direction integral image, can calculate according to following formula:
Hist(n,D)=II(4,n)-II(2,n)-II(3,n)+II(1,n)
Wherein, II (1, n), II (2, n), II (3, n) and II (4, n) represent that respectively edge direction is that the edge direction integral image of n is at point 1, point 2, point 3 with put the value at 4 places.
The Automobile Detection device that above-mentioned training obtains can only detect the automobile of a yardstick (W*H), in order to detect the automobile of different sizes, can detect according to the mode of asking for the pyramid picture structure.Suppose original input picture width and highly be respectively IW and IH, calculate the pyramid image of a series of a plurality of yardsticks (being assumed to M) according to scaling yardstick RS, size is (ROUND (IW*RSm), ROUND (IH*RSm)), wherein ROUND is the computing that rounds up, and the span of m is to M-1 from 0.
Referring to Fig. 6, step S105 specifically comprises:
S601, according to input picture, obtain the pyramid picture structure.
S602, for the pyramid image of each yardstick, calculate the discretize edge direction and the edge strength of this scalogram picture, and the edge calculation direction histogram.
S603, with a fixed step size, obtain rectangle frame position possible on this scalogram picture with vertical direction traversal in the horizontal direction.
The Automobile Detection device model of S604, the fixed size (W*H) that obtains according to above-mentioned training calculates the required edge orientation histogram of detection model, and further calculates current rectangle and whether can pass through the Automobile Detection device, if, execution in step S605 then, otherwise, execution in step S606.
S605, candidate's automobile frame is added the automobile formation, and return execution in step S603, obtain and handle next possible rectangle frame, all possible rectangle frame position all disposes on this scalogram picture.
S606, refuse not the rectangle frame by checking, and return execution in step S603, obtain and handle next possible rectangle frame, all possible rectangle frame position all disposes on this scalogram picture.
S607, behind the pyramid image of handling all yardsticks, according to the candidate's automobile frame in the automobile formation, determine the automobile position in the input picture.
Preferably, step S605 comprises the step that candidate's automobile frame adds the automobile formation: according to the size and the position of candidate's automobile frame to be added, and the size and the position that have been added to the candidate's automobile frame in the automobile formation, judge whether described candidate's automobile frame to be added is close with the described candidate's automobile frame that has added, if, then close candidate's automobile frame is merged, and with the number of the merged candidate's automobile frame degree of confidence as the candidate's automobile frame after merging; Otherwise, described candidate's automobile frame to be added is added in the described automobile formation.
Preferably, step S607 determines that according to the candidate's automobile frame in the automobile formation step of the automobile position in the input picture comprises: when the candidate's automobile frame in the automobile formation is contained in another candidate's automobile frame, and candidate's automobile frame deletion that degree of confidence is less; When degree of confidence is identical, the less candidate's automobile frame of deletion area; To be defined as the automobile position on the input picture through the position of remaining candidate's automobile frame in the automobile formation after described merging and the deletion processing.
Though above-mentioned Automobile Detection device can satisfy the requirement of real time execution, but, in video image, the movable information of the automobile in the combining image can further be accelerated the speed of Automobile Detection, simultaneously, the interference that exists in can also the rejection image background, thus flase drop reduced, improve the Automobile Detection effect.
For the static situation of camera, it is poor that current input image and the background image that sets in advance are done, and obtains motion pixel sign mask; And, be the candidate frame setting threshold in advance, only motion is carried out Automobile Detection greater than to a certain degree candidate frame.In the embodiment of the invention, the number of pixels that changes in the definition rectangle frame is the kinergety of rectangle frame, weighs the degree that the pixel in the rectangle frame changes by this kinergety.
The sign mask images of supposing the pixel that changes in the present image is MI, be in point (x, the sign mask images of y) locating be MI (x, y), if pixel changes, then (x is a non-zero number y) to MI, is assumed to MF, if this pixel does not change, then (x is zero y) to MI.
Further, the number of pixels that adopts rectangular area normalization to change, i.e. normalization kinergety is the number of pixels that changes in the rectangular area and the ratio of rectangular area area.Further, can adopt the mode of integral image to calculate normalization kinergety and kinergety fast.At first calculate the motion sign integral image of full figure, concrete steps are as follows:
To any y=0,1,2...H-1 and x=0,1,2...W-1, setting II (1, y)=0, IMI (x ,-1)=0;
To all row of image, according to y=0,1, the order of 2...H-1 is carried out following processing:
Set rs and represent all number of pixels that change of current line, initialization rs is 0;
All pixels to image y in capable are according to x=0, and 1, the order of 2...W-1 is carried out following processing:
If current pixel changes, then make rs=rs+1; If current pixel does not change, keep rs constant; And then current pixel (x, and motion sign integral image IMI y) (x, y)=IMI (x, y-1)+rs;
Then calculate the capable motion sign integral image of y+1 after having calculated the capable motion sign integral image of y.
After all capable disposing to image, finishing the calculating of motion sign integral image.
As shown in Figure 5, according to the definition of motion sign integral image, kinergety can be calculated according to following formula:
ME(D)=IMI(4)-IMI(2)-IMI(3)+IMI(1)
Wherein IMI (1), IMI (2), IMI (3) and IMI (4) represent that respectively motion sign integral image is at point 1, point 2, point 3 with put the value at 4 places.
The normalization kinergety is:
For the situation of cam movement, adopt the mode of FN frame difference to obtain movable information, FN can equal 2, also can be greater than 2, obtain movement edge pixel sign mask, be the candidate region setting threshold, only motion is carried out Automobile Detection greater than candidate region to a certain degree.Further, determine whether variation has taken place in the rectangle frame, only adopt apart from outer rectangular frame edge longitudinal distance smaller or equal to DH, lateral separation is added up normalization smaller or equal to the pixel of DW and is changed number of pixels, and and threshold ratio determine whether rectangle frame variation has taken place, whether need to adopt the separation vehicle device whether to judge automobile.In embodiments of the present invention, being used for adding up the pixel that whether moves is apart from the pixel of rectangular edges less than threshold value, as shown in Figure 7, employing apart from edge longitudinal less than DH, laterally less than the area part between two rectangle frames of DW as judging the zone that whether moves, this zone is called the border movement zone.
In conjunction with the level type Adaboost separation vehicle device of kinergety as shown in Figure 8, whether the kinergety of judging candidate frame, is then thought not to be automobile if be not more than greater than certain threshold value earlier, directly refuses; If greater than, then adopt the level type Adaboost separation vehicle device that trains to judge based on feature a little less than the HOG.
Further, the embodiment of the invention also provides a kind of automobile tracking based on background subtraction, the automobile tracking then is position, the CF information according to each automobile in the image of different frame, determine the corresponding relation of each automobile, determine that promptly which or which automobile is the automobile of same automobile in the image of different frame in the image, as shown in Figure 9, specifically comprise:
S901, initialization background image.
The method of initialization background image can simply select a pair not have the image of prospect, also can adopt the background image initial method of more complicated.
S902, input picture is compared with background image (being reference picture), obtain the moving region of input picture.
Comparison herein, can adopt the mode that compares with the threshold value that sets in advance after input picture and the background image work difference, also can adopt mixed Gauss model (GMM, Gaussian Mixture Model) and Density Estimator (KDE, Kernel Density Estimation) etc. complicated model relatively obtains the moving region.Consider the processing speed of system, a kind of mode is better before adopting.
The integral image of S903, calculating moving region, and, adopt integral image to obtain the number of pixels that its inside changes to each candidate frame.
S904, the number of pixels that changes and the threshold value that sets in advance are compared, judge that when remarkable motion has taken place, employing is decided the zone based on the quick Automobile Detection device of level type Adaboost algorithm to described fortune and detected, and obtains candidate's automobile frame.
S905, the candidate's automobile frame that obtains is added in candidate's automobile formation of current input image.
S906, the candidate's automobile position that overlaps mutually in the formation of described candidate's automobile is merged processing.
The mode that S907, employing are mated based on histogram, the maximum match degree of the reference automobile frame in each candidate's automobile frame in candidate's automobile formation of calculating current input image and the tracking queue that sets in advance.
Employing is based on the mode of histogram coupling, and calculating comprises with reference to the concrete steps of the maximum match degree of automobile frame and candidate's automobile frame:
Calculating is with reference to the histogram matching degree and the dimension location matching degree of automobile frame and candidate's automobile frame;
Described histogram matching degree be multiply by described dimension location matching degree as described maximum match degree with reference to automobile frame and described candidate's automobile frame.
S908, judge that whether the maximum match degree of candidate's automobile frame is greater than threshold value TP, if, think that then the match is successful, determine candidate's automobile frame and be same automobile frame, and adopt corresponding positional information in the updating location information tracking queue of candidate's automobile frame that the match is successful in the automobile formation with reference to the automobile frame with reference to the automobile frame; Otherwise, add candidate's automobile frame positional information that it fails to match to tracking queue, as new reference items; If tracking queue is empty, promptly do not have in the tracking queue then directly the candidate's automobile frame that merges after handling to be added in the tracking queue with reference to the automobile frame.
S909, according to the reference automobile position in the tracking queue after the described renewal, determine the automobile position on the described input picture.
Further, the present embodiment method also comprises: the occurrence number of the reference automobile frame in the record tracking queue, be assumed to n, and preestablish threshold value TN, if n
3TN thinks that then this is the real car frame with reference to the automobile frame, otherwise thinks candidate's automobile frame.And, write down each with reference to the automobile frame do not have tracked to frame number be nm, for the real car frame, if satisfy nm
3TMN thinks that this real car disappears in the image acquisition scope, then delete the positional information of this real car frame from tracking queue, and wherein, TMN is a pre-set threshold; For candidate's automobile frame, if satisfy nm
3TMPN thinks that then this candidate's automobile disappears, the positional information of this candidate's automobile frame of deletion from tracking queue, and wherein, TMPN is a pre-set threshold.The final real car frame that only will occur carries out keeping records as effective automobile frame, is used for analyzing and inquiry.
Preferably, the present embodiment method also comprises: distribute a unique numbering (ID) for the real car in the tracking queue, the numbering of each emerging real car correspondence increases progressively, and is final, the number of master serial number is the number of the real car of appearance, thereby realizes the counting to automobile.
Further, when mating among the step S907, adopt candidate's automobile frame and assist histogram to mate with reference to the positional information and the size information of automobile frame in video; Suppose that these two automobile frames are respectively R
1(cx1, cy1, w1, h1) and R
2(cx2, cy2, w2, h2), and cx1 wherein, cx2 is respectively the center horizontal ordinate of two rectangle automobile frames, and cy1, cy2 are respectively the central longitudinal coordinate of two automobile frames, and w1, w2 are respectively the width of two automobile frames, and h1, h2 are respectively the height of two automobile frames; The centre distance of two automobile frames is dis=sqrt ((cx1-cx2) * (cx1-cx2)+(cy1-cy2) * (cy1-cy2)), and the dimension location matching degree that then defines two automobile frames is
Sqrt is an extracting operation, and min is for going little value computing, and max is for getting big value computing, and DR and SR are constant.In the embodiment of the invention, the matching degree of two automobile frames multiply by the dimension location matching degree of rectangle automobile frame for the histogram matching degree.
Further, the histogram coupling can adopt the mode of weighted histogram, promptly to setting different weights on the automobile frame during zones of different statistic histogram, such as, the distance of setting weights and each pixel distance automobile frame center is inversely proportional to, and distance center is near more, and weights are big more, distance center is far away more, and weights are more little; The histogram that finally obtains is to the histogram after each pixel weighting.
Preferably, after step S905 finishes Automobile Detection, candidate's automobile frame is not merged the post-processing operation that overlaps mutually rectangle frame, but all candidate's automobile frames is carried out following processing:
Step 1: the number of plies and every layer of weights and this layer threshold value that strong classifier is tried to achieve of the Automobile Detection device that passes through according to candidate's automobile frame, for each candidate's automobile frame is determined a degree of confidence.
Step 2:, then current candidate's automobile frame is merged the post-processing operation that overlaps mutually rectangle frame, and the position of all the candidate's automobile frames after the aftertreatment is added in the tracking queue if tracking queue is empty.
Step 3: if tracking queue is not empty, then in the tracking queue each with reference to the automobile frame, for example with reference to automobile frame A, all candidate's automobile frames that it is corresponding with current input image mate, all matching degrees are all preserved greater than candidate's automobile frame of certain threshold value, as aftertreatment automobile frame, and carry out aftertreatment, last handling process herein is:
All aftertreatment automobile frames are classified according to the position, and the aftertreatment automobile frame that same position is overlapped on together is divided into a class, then, and to the matching degree addition of each aftertreatment automobile frame of belonging to a class total matching degree as such; The class of getting total matching degree maximum is as final matching result, and according to the degree of confidence of such each aftertreatment automobile frame, the weighted sum of position coordinates of trying to achieve each aftertreatment automobile frame is as the position coordinates of coupling automobile frame (A is complementary with reference automobile frame), and upgrades in the tracking queue accordingly position coordinates with reference to automobile frame A with position coordinates of this coupling automobile frame.And, all candidate's automobile frames that position in candidate's automobile formation of current input image correspondence and described coupling automobile frame takes place to overlap are deleted from the formation of described candidate's automobile.
Then, carry out same treatment to next in the tracking queue with reference to the automobile frame, reference automobile frames all in tracking queue all dispose, the candidate's automobile frame that exists in candidate's automobile formation to current input image merges the aftertreatment of overlapping frame again, and all the candidate's automobile frames after this aftertreatment are added in the tracking queue.
In addition, can also adopt the moving region that obtains input picture based on the mode of frame difference, and automobile is followed the tracks of.The method of obtaining the moving region is as follows:
The first step adds context queue with preceding N two field picture as initialization background (reference picture).
Second goes on foot, and input picture is compared with the N frame background image in the context queue obtains the moving region.
Particularly, can adopt input picture and every frame background image poor, and with threshold ratio, the most at last N comparative result respective pixel ask or mode obtain the moving region; And, add the present frame input picture to context queue, with context queue two field picture deletion the earliest.Wherein, N can be 1, also can be greater than 1.
In addition, can also adopt after the background image weighted sum in the context queue, the mode with the current input image comparison obtains the moving region again.
The 3rd step, ask the integral image of moving region, and to each candidate rectangle position, adopt integral image to obtain the number of pixels that its inside changes, and with threshold ratio, see whether it remarkable motion has taken place, if, then adopt Automobile Detection device based on level type Adaboost algorithm, judge whether the candidate rectangle frame is candidate's automobile frame, if then this candidate's automobile frame is added in the automobile formation of present frame input picture.
Introduce the device that the embodiment of the invention provides below.
A kind of image detection device that the embodiment of the invention provides comprises:
The unit is set, is used for obtaining weak feature database, and utilize this weak feature database setting to strengthen the quick separation vehicle device of sorter and edge orientation histogram based on level type self-adaptation by the edge of image direction histogram.
The edge orientation histogram unit is used for edge direction and edge strength by input picture, calculates the edge orientation histogram of described input picture.
Detecting unit is used to adopt described quick separation vehicle device, according to the edge orientation histogram of described input picture, determines the automobile position in the described input picture.
A kind of image tracking means that the embodiment of the invention provides comprises:
The unit is set, is used for obtaining weak feature database, and utilize this weak feature database setting to strengthen the quick separation vehicle device of sorter and edge orientation histogram based on level type self-adaptation by the edge of image direction histogram.
Determine the unit, moving region, be used for input picture is compared with reference picture, obtain the moving region of described input picture.
Identifying unit is used for by described quick separation vehicle device described moving region being judged, obtains the automobile position in the described input picture.
In sum, the Automobile Detection that the embodiment of the invention is realized by level type AdaBoost sorter and HOG feature are combined and the technical scheme of tracking, can determine automobile position quickly and accurately, has very important application value, for example, can be applied in intelligent video monitoring, intelligent transportation, video analysis and fields such as retrieval and picture retrieval.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.