Embodiment
Below in conjunction with specific embodiment, technical solution of the present invention is further illustrated.
As shown in Figure 1, the specific embodiment of the present invention is: the invention provides a kind of people's face phase method of discrimination, comprise camouflage sorter, camouflage model and recognition of face sorter, described people's face phase method of discrimination comprises the steps:
Step 100: obtain facial image, that is, obtain facial image from video or image.In the present invention, first to obtain facial image, the obtaining of facial image derives from and in video, cuts facial image, also can derive from the image that contains people face part in image, the image in the present invention can be the image electronic file that contains people face part on the image electronic file of directly reception or the image electronic file of scanning generation or truncated picture file.In the specific embodiment of the present invention, facial image is lived to people's face according to the size of people's face with rectangle frame and be limited, that is to say and obtain facial image with the large rectangular image of having the face and being lived by rectangle frame of trying one's best.
Step 200: carry out the camouflage of people's face and differentiate, that is, facial image is pretended to differentiate according to camouflage sorter, camouflage model.In the present invention, described people's face camouflage differentiation comprises: wear dark glasses camouflage is differentiated, wear dark glasses camouflage is differentiated, worn masks or the camouflage differentiation of scarf.Before pretending differentiation, need to generate camouflage sorter and camouflage model.Specifically, the camouflage sorter in the present invention comprises cap sorter, sunglasses sorter, according to cap sorter, differentiates whether facial image is the camouflage of being branded as, and whether according to sunglasses sorter, differentiate facial image is wear dark glasses camouflage.Described camouflage model comprises complexion model, and whether according to complexion model, differentiate facial image is to wear masks or the camouflage of scarf.Below illustrate the generative process of camouflage sorter:
The generative process of cap sorter: first obtain the image of multiple different laying method difformity caps and be not two groups of images of image of cap, generally quantitatively respectively over 100, these images are normalized, such as the unified regulation of size is 40x30 pixel size.Then using the image of multiple caps as positive example sample, using multiple be not the image of cap as negative data, these positive example samples and negative data form the training set of cap cascade classifier.Utilizing Opencv(OpenCV is the computer vision storehouse of increasing income that Intel Company supports, it consists of a series of C functions and a small amount of C++ class, has realized a lot of general-purpose algorithms of image processing and computer vision aspect.) in the Adaboosting algorithm based on Haar feature finished writing, the training of sorter realizes by the haartraining program in Opencv, the training set of the cap cascade classifier obtained of take is input training respectively, obtain cap sorter, the final cap cascade classifier being output as based on Harr feature.
Obtain after cap cascade classifier, then obtain cap hu invariant (Hu Shi invariant, some moment characteristics wherein.Because the moment of inertia about major axis and minor axis and some very useful square invariants all can directly be obtained by square, bending moment is not the statistical property of image, meet translation, gentry's contracting, rotate all constant unchangeability, in field of image recognition, be widely used, first Hu has proposed the not bending moment for region shape identification, and Hu Shi invariant is some moment characteristics.) training set.Utilize the cap cascade classifier forming in sorter training, detect cap, and cut cap area image, in the image collection obtaining like this, there are two class images, one class is cap, and an other class is not cap (being referred to as " false cap " here), then they is divided into two groups, one group that is cap is positive example sample, and " false cap " one group is negative data; (obtaining cap Hu invariant training set image set used and above-mentioned training cap cascade classifier image library used is here two different image sets to be so formed for obtaining the cap image set of cap Hu invariant; These two image sets are all ready before system operation, calculate wherein 7 hu invariants of all images, form cap hu invariant training set, wherein have cap and non-cap two class data.
By said method, obtained cap sorter.
After obtaining cap sorter, utilize cap sorter to differentiate the camouflage of being branded as in image,, first utilize cap cascade classifier Preliminary detection, to ' the cap image ' that detect, 7 invariant training sets in recycling cap sorter and positive integer of K(, get in the present invention 9) whether be genuine cap near neighbor method if differentiating in the image of current detection, if just the proper vector of current detection cap from cap hu invariant training set cap data close to, be judged to cap, otherwise be not cap.In specific implementation process, true cap image be mistaken for cap image 7 Hu not in bending moment the 5th dimension draw and have good separation property with the point of the 7th dimensional feature, therefore by these two features, as the input of k nearest neighbor method, reduce erroneous judgement, so also reduced computation complexity.
The same with said process, the acquisition process of sunglasses sorter is as follows:
The generative process of sunglasses sorter: first obtain the image of multiple different laying method difformity sunglasses and be not two groups of images of image of sunglasses, generally quantitatively respectively over 100, these images are normalized, such as the unified regulation of size is 40x30 pixel size.Then using the image of multiple sunglasses as positive example sample, using multiple be not the image of sunglasses as negative data, these positive example samples and negative data form the training set of sunglasses cascade classifier.Utilizing Opencv(OpenCV is the computer vision storehouse of increasing income that Intel Company supports, it consists of a series of C functions and a small amount of C++ class, has realized a lot of general-purpose algorithms of image processing and computer vision aspect.) in the Adaboosting algorithm based on Haar feature finished writing, the training of sorter realizes by the haartraining program in Opencv, the training set of the sunglasses sorter obtained of take is input training respectively, obtain sunglasses sorter, the final sunglasses cascade classifier being output as based on Harr feature.
Obtain after sunglasses cascade classifier, then obtain sunglasses hu invariant (Hu Shi invariant, some moment characteristics wherein.Because the moment of inertia about major axis and minor axis and some very useful square invariants all can directly be obtained by square, bending moment is not the statistical property of image, meet translation, gentry's contracting, rotate all constant unchangeability, in field of image recognition, be widely used, first Hu has proposed the not bending moment for region shape identification, and Hu Shi invariant is some moment characteristics.) training set.Utilize the sunglasses cascade classifier forming in sorter training, detect cap, and cut sunglasses area image, in the image collection obtaining like this, there are two class images, one class is sunglasses, and an other class is not sunglasses (being referred to as " false sunglasses " here), then they is divided into two groups, one group that is sunglasses is positive example sample, and ' false sunglasses ' one group is negative data; (obtaining sunglasses Hu invariant training set image set used and above-mentioned training sunglasses cascade classifier image library used is here two different image sets to be so formed for obtaining the sunglasses image set of sunglasses Hu invariant; ), calculate wherein 7 hu invariants of all images, form sunglasses hu invariant training set, wherein there are sunglasses and non-sunglasses two class data.
By said method, obtained sunglasses sorter.
After obtaining sunglasses sorter, utilize sunglasses sorter to differentiate carrying out wear dark glasses camouflage in image, , first utilize sunglasses cascade classifier Preliminary detection, to ' the sunglasses image ' that detect, calculate again 7 Hu invariants that are somebody's turn to do ' sunglasses image ', then 7 Hu invariant input neural networks, according to neural network Output rusults (0 or 1, 0 represents it is not sunglasses, 1 represents it is sunglasses) whether the image of differentiating current detection be genuine cap, utilize 7 invariant training sets and multilayer neural network method in cap sorter, neural metwork training process is as follows, use has three layers of BP neural network, 7 nodes of input layer (corresponding 7 Hu invariants), 10 nodes of hidden layer, node of output layer (whether correspondence is sunglasses), the sunglasses hu invariant training set of the data set of neural network training for intercepting from video.After training, produce neural network model.
Two relevant steps in following brief description camouflage sorter:
One, the Adaboosting algorithm based on Haar feature.Adaboosting algorithm based on Haar feature detects the target of some appointments, as people's face, sunglasses, eyes, automobile etc.Specifically cross as follows: Haar feature is divided three classes: the feature templates that edge feature, linear feature, central feature become with diagonal line Feature Combination.Adularescent and two kinds of rectangles of black in feature templates, and the eigenwert that defines this template be white rectangle pixel value and that deduct black rectangle pixel value and.Determining that the quantity of Harr-like feature after characteristic formp just depends on the size of training sample image matrix, feature templates is placed arbitrarily in subwindow, form is called an a kind of feature, and the feature of finding out all subwindows is the basis of carrying out weak typing training.Adaboost is a kind of iterative algorithm, and its core concept is to train different sorter (Weak Classifier) for same training set, then these Weak Classifiers is gathered, and forms a stronger final sorter (strong classifier).Utilize the harr feature of sample to carry out sorter training, obtain the strong classifier of a cascade.Training sample is divided into positive example sample and negative data, wherein positive example sample refers to target sample to be checked (such as people's face or automobile etc.), negative data refers to other arbitrary image, and all sample images are all normalized to same size (for example, 20x20).After sorter has been trained, just can be applied to the detection of the area-of-interest (size identical with training sample) in input picture.Target area (automobile or people's face) sorter being detected is output as 1, otherwise is output as 0.In order to detect whole sub-picture, mobile search window in image, detects each position and determines possible target.In order to search for the target object of different sizes, sorter is designed to carry out size change, more more effective than the size that changes image to be checked like this.So in order to detect the target object of unknown size in image, scanning sequence need to scan image several times with the search window of different proportion size conventionally.
Two, the calculating of hu invariant.
The computing method of 7 hu invariants are as follows: for digital picture f (x, y), and its (p+q) rank geometric moment m
pqrepresent:
Center square μ
pqbe translation invariant, also need standardization to obtain yardstick standardization square:
7 invariants that hu constructs are:
φ
1=η
20+η
02
φ
2=(η
20-η
02)
2+4η
11 2
φ
3=(η
30-3η
12)
2+(3η
21+η
03)
2
φ
4=(η
30+η
12)
2+(η
21+η
03)
2
φ
5=(η
30-3η
12)(η
30+η
12)[(η
30+η
12)
2-3(η
21+η
03)
2]+
(3η
21-η
03)(η
21+η
03)[3(η
30+η
12)
2-(η
21+η
03)
2]
φ
6=(η
20-η
02)[(η
30+η
12)
2-(η
21+η
03)
2]+4η
11(η
30+η
12)(η
21+η
03)
φ
7=(3η
21-η
03)(η
30+η
12)[(η
30+η1
2)
2-3(η
21+η
03)
2]-
(η
30-3η
12)(η
21+η
03)[3(η
30+η
12)
2-(η
21+η
03)
2]
M
pqbe (p+q) rank square of image, p, q are nonnegative integers arbitrarily; μ
pqit is (p+q) center, rank bending moment not of image; η
pqfor (p+q) center, the rank bending moment not after standardization; Φ
i(i=1,2 ... 7) being seven invariants recklessly, is scalar.
In the present invention, described camouflage model comprises complexion model, and whether according to complexion model, differentiate facial image is to wear masks or the camouflage of scarf.Detailed process is as follows: the function of complexion model is to have an image to given, finds and human face region that mark is not blocked, so that the identifying processing of later stage facial image.Then pass through to calculate similarity, thereby mark is carried out in the region of people's face.Comprise following three steps:
One, brightness of image adjustment
Given image, due to the mass discrepancy of camera, the difference of illumination, has larger difference, and for reducing the impact of external condition on face complexion color, first we carry out pre-service rectification to it.Here the rectification formula of disposal route is as follows:
Sc=Sc*scalar
Wherein, Sc is the rgb value of original image, the rgb value that Savg is standard picture, the mean value of the corresponding RGB of corresponding RGB component that Scavg is present image.The rgb value of standard picture, then we calculate respectively R, the G of all pixels in all pictures, the mean value of tri-passages of B obtains by take 20 images under normal illumination condition.By calculating, the SAVGB=174.415 that we obtain, SAVGG=180.664, SAVGR=180.448.
We find comparison by image rectification result, and before image rectification, video image exists over-exposed problem, adopt after correcting algorithm, and picture contrast has obviously strengthened.
Two, human face region detects
For the region of people's face, detect us and adopted the method for calculating human face region similarity.
First, we are transformed into YCbCr color form image.Compare with rgb color space, YCbCr can well separate the brightness in coloured image.
The formula that rgb color space is converted to YCbCr space is as follows:
Cb=128-37.797*R/255-74.203*G/255+112*B/255
Cr=128+112*R255-93.786*G/255-18.214*B/255
Remove Y component (luminance component), we reduce to two dimension a three-dimensional planar, and on this two dimensional surface, the region of the colour of skin is relatively very concentrated, so we simulate this distribution by Gaussian distribution.
We adopt the method for training to obtain such center of distribution, then according to the distance at the pixel Li Gai center that will investigate, obtain the similarity of a colour of skin, then obtain the similar distribution plan of a former figure, again according to certain rule to this distribution plan binaryzation, finally determine the region of the colour of skin.In the time of training, that need to determine is average M and variance C.By formula below:
M=E(x),C=E((x-x)(x-M)
T)x=[r,t]
T
Wherein, x is the Cr of the color of all pixels in image, the vector that two values of Cb form.While calculating similarity, adopt formula:
P(r,b)=exp[-0.5(x-M)
TC
-1(x-M)]
P(r, b) also referred to as Cr in YCbCr space, the probability that the pixel that two values of Cb are r, b is the colour of skin, calculates after similarity, if P(r, b) be greater than given threshold value, this point is the colour of skin, and corresponding pixel points gray-scale value is made as 1, otherwise is 0, accordingly image is carried out to binaryzation, threshold value is determined according to experimental result repeatedly.Be 0.62 in the present invention.
Three, the extraction of human face region
Correctly image is being carried out after binaryzation, whole face is in theory in the region in same connection, although perhaps also may there are other less connected regions in image, the area of whole human face region should be maximum.Based on this, we first calculate the area ratio of connected region area and whole image, look for area ratio necessarily to limit interval connected component, just can think that this connected region is exactly the human face region that will look for.Limit and intervally by test of many times result, to determine, in the present invention, to limit interval be [0.25,0.68] to area ratio, and area ratio is greater than 0.25 and be less than 0.68 o'clock this connected region and be considered to people's face.
Step 300: people's face is differentiated mutually, that is, carry out face classification face for the facial image pretending in camouflage differentiation result according to recognition of face sorter and differentiate mutually.
Detailed process is as follows: from video, grab a two field picture.In the present invention, with the face classification device training providing in opencv, detect people's face.In specific implementation process, the gray level image that is the size (70 * 100 pixel) of training sample this facial image normalization size.If y ∈ is R
nrepresent this facial image, be test sample book, A ∈ R
n * mbeing the matrix that all training samples form, is all image patterns in the suspect's face database having loaded, the corresponding training sample of each row.Suppose that test sample y can be expressed as follows with the linear combination of all training samples:
Wherein, m represents the number of training sample, a
krepresent k training sample, α
kbe in linear combination with k the coefficient that training sample is corresponding.Wherein, α=(α
1, α
2.., α
m)
tcoefficient vector, A=(a
1, a
2.., a
m).
Pass through following formula
Obtain coefficient vector.
Calculate every class sample to describing the contribution of test sample book.From formula (* *), each training sample has contribution to the description of test sample book, and the contribution of k training sample is α
ka
k(k=1,2 ..., m).Because the classification under each training sample is known, so the contribution of all training samples in each class is added, can obtain this type of sample to describing the contribution of test sample book.For example, suppose a
s..., a
tbe the training sample that belongs to d class, the contribution that d class is done when describing test sample book is g
d=α
sa
s+ ..+ α
ta
t.
Calculate the error e of all categories
d=|| y-g
d||
2(d=1,2 ..., L).Wherein, L is the classification number in database.
Find out the affiliated classification of least error, identification.Classification explanation test sample book (facial image to be identified) and this classification close together that error is less, and when error is less than certain threshold value, think that portrait to be identified is the same with portrait in database.Otherwise refusal identification, enters next time and processes.In threshold value in the present invention, get the decimal between 0.02(0 to 1).
The preferred embodiment of the present invention is: in carrying out the step of people's face camouflage differentiation, before carrying out facial image contrast, also comprise the pretreatment operation to facial image, described pretreatment operation is for to be normalized facial image.
As shown in Figure 2, specific embodiment of the invention process is as follows: technical scheme of the present invention is: build a kind of people's face phase judgement system, comprise the image input block 1 of inputting facial image, according to facial image, carry out the camouflage judgement unit 2 that the camouflage of people's face is differentiated, carry out people's face and know each other other face identification unit 3, described camouflage judgement unit comprise obtain camouflage sorter 22, camouflage model 23 and camouflage discrimination module 21, described face identification unit 3 comprises the face database 32 of storing facial image, recognition of face sorter 31, described camouflage discrimination module 21 is according to camouflage sorter 22, the facial image of 23 pairs of described image input block 1 inputs of camouflage model pretends to differentiate, for described camouflage discrimination module 21, differentiating is while not being the facial image of camouflage, described face identification unit 3 is identified mutually by the facial image of described image input block 1 input and facial image in described face database 32 are carried out to people's face according to recognition of face sorter 31.
Specific embodiment of the invention process is as follows: first by image input block 1, will obtain facial image, the obtaining of facial image derives from and in video, cuts facial image, also can derive from the image that contains people face part in image, the image in the present invention can be the image electronic file that contains people face part on the image electronic file of directly reception or the image electronic file of scanning generation or truncated picture file.In the specific embodiment of the present invention, facial image is lived to people's face according to the size of people's face with rectangle frame and be limited, that is to say and obtain facial image with the large rectangular image of having the face and being lived by rectangle frame of trying one's best.
Secondly, facial image is pretended to differentiate according to camouflage sorter, camouflage model.In the present invention, described people's face camouflage differentiation comprises: being branded as, camouflage is differentiated, wear dark glasses camouflage is differentiated, worn masks or the camouflage differentiation of scarf.Before pretending differentiation, need to generate camouflage sorter 22 and camouflage model 23.Specifically, camouflage sorter 22 in the present invention comprises cap sorter 221, sunglasses sorter 222, described camouflage discrimination module 21 differentiates according to cap sorter whether facial image is the camouflage of being branded as, and whether described camouflage discrimination module 21 is differentiated facial image according to sunglasses sorter 222 is wear dark glasses camouflage.Described camouflage model 23 comprises complexion model 231, and whether described camouflage discrimination module 21 is differentiated facial images according to complexion model 231 is to wear masks or the camouflage of scarf.
Finally, the facial image of differentiating for not being camouflage for described camouflage discrimination module 21, described face identification unit 3 is identified mutually by the facial image of described image input block 1 input and facial image in described face database 32 are carried out to people's face according to recognition of face sorter 31.
The behavior that inventor's face phase judgement system pretends for facial image is reacted in time, and recognition effect is better.
As shown in Figure 2, the preferred embodiment of the present invention is: described people's face phase judgement system also comprises facial image retrieval unit 4, and described facial image retrieval unit 4 is retrieved the facial image in described face database 32 according to the condition of input.Facial image retrieval unit 4 in the present invention, according to the facial image of user's input, contrasts retrieval to the image in described face database 32 by described face identification unit 3.Facial image retrieval unit 4 of the present invention can also carry out facial image retrieval according to conditions such as the people's of input sex, the ranges of age.
As shown in Figure 3, technical scheme of the present invention is: build a kind of public safety system, described public safety system comprises people's face phase judgement system, described face database is suspect's image data base 33 of storage suspect facial image, for described camouflage discrimination module 21, differentiate when not being the facial image of camouflage, described face identification unit 3 is carried out people's face by described facial image and facial image in described suspect's image data base 33 and is identified mutually.
Its specific works process, with the course of work of above-mentioned people's face phase recognition system, only defines suspect's image data base 33 by common face database here.
As shown in Figure 3, the preferred embodiment of the present invention is: described public safety system also comprises alarm unit 5, and for described camouflage discrimination module 21, differentiating is while being the facial image of camouflage, and described alarm unit 5 is reported to the police; For described face identification unit 3, described facial image is identified as to the facial image in described suspect's image data base 33, described alarm unit 5 is reported to the police.
The preferred embodiment of the present invention is: described public safety system also comprises suspect's image retrieval unit, and described suspect's image retrieval unit is retrieved the facial image in described suspect's image data base 33 according to the condition of input.Suspect's image retrieval unit in the present invention, according to the facial image of user's input, contrasts retrieval to the image in described suspect's image data base 33 by described face identification unit 3.Suspect's image retrieval of the present invention unit can also carry out facial image retrieval according to conditions such as the people's of input sex, the ranges of age.Suspect's image retrieval cell operation process described here is the same with described facial image retrieval unit 4 courses of work, and only the database of its retrieval is suspect's image data base 33.
Technique effect of the present invention is: inventor's face is sentenced method for distinguishing, system and public safety system mutually, by carry out people's face before identifying mutually advanced pedestrian's face camouflage differentiate, the behavior of pretending for facial image is reacted in time.
Above content is in conjunction with concrete preferred implementation further description made for the present invention, can not assert that specific embodiment of the invention is confined to these explanations.For general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, can also make some simple deduction or replace, all should be considered as belonging to protection scope of the present invention.