Not long ago Iphone X release , It's revolutionary TouchID( fingerprint identification ), And added something cooler FaceID( Face recognition ) modular ,FaceID
Not easy to use in unlocking , You can also pay , Application in scenes such as expression , Bring more cool and rich applications to developers ,Iphone X
Under the support of multiple hardware sensors , Can be collected 3 Ten thousand points to perceive the facial features of users .

We know that face recognition has been widely used in recent years , Face attendance , Face social , Face payment , It's all about the influence of black technology , Especially in recent years, machine learning is popular , It makes the application and accuracy of face recognition reach a higher level .

Now I'm going to bring you to the bottom of this black technology .

1, Face recognition process

Face recognition is composed of a series of related problems :

* First find all the faces in a picture .
* For every face , Whether the light is dark or facing away , It still recognizes the same person's face .
* Be able to identify unique features on each face that can be used to distinguish others , How big are your eyes , How long is the face and so on .
* Finally, the features of this face are compared with all known faces , To determine who this person is .
Step 1 : Find all the faces

Obviously, in the process of face recognition, we have to find the face in the picture first . We all have portrait mode when we use mobile phones or cameras to take pictures , It can easily detect the position of human face , Help the camera focus quickly .

We have to thank you Paul · viola (Paul Viola) And Michael · Jones (Michael
Jones) stay 2000 A face detection method that can run on cheap camera quickly was invented in , The application of face detection in camera becomes the mainstream . But now we have a more reliable solution HOG(Histogram
of Oriented Gradients) Direction gradient histogram , An algorithm for detecting the contour of an object .

First of all, we grayed out the picture , Because color information is useless for face detection .

We analyze each pixel and the pixels around it , Draw an arrow according to the brightness , The direction of the arrow represents the direction in which the pixel is gradually darkened , If we repeat each pixel , Eventually pixels will be replaced by arrows . These arrows are called gradients (gradients), They show how images flow from bright to dark .

It's a bit of a cost-effective for us to analyze every pixel , Because it's too detailed , We may get lost in the ocean of pixels , We should observe the flow of light and shade from a higher angle .

So we split the image into 16x16 Small squares of pixels . In each small square , Calculate how many shavings there are in each main direction ( How many points up , Point right up , Point right etc ). Then use the most directional arrow to replace the original small square .

final result , Let's turn the original image into a very simple one HOG Form of expression , It can easily capture the basic structure of the face .

In order to HOG Face found in image , What we need to do is , With some known HOG In the pattern , The most similar part . these ones here HOG Patterns are extracted from other facial training data .

Step 2 : Different positions of the face

We have found the face in the picture , So how to identify faces facing different directions ?

Facing different faces is different for computers , So we have to adjust the face in the distorted picture , Make the eyes and mouth always overlap with the tested person .

To achieve this, we will use a facial feature point estimation (face landmark
estimation) Algorithm of . In fact, there are many algorithms that can be done , But we're using Wahid this time · Kazimi (Vahid Kazemi) And Josephina · Sullivan (Josephine
Sullivan) stay 2014 Method invented in .

The basic idea of this algorithm is to find 68 A common spot on a person's face ( Called feature points , landmark).

* Chin contour 17 Points [0-16]
* Left eyebrow 5 Points [17-21]
* Right eyebrow 5 Points [22-26]
* bridge of the nose 4 Points [27-30]
* nose 5 Points [31-35]
* left eye 6 Points [36-41]
* right eye 6 Points [42-47]
* Outer lip 12 Points [48-59]
* Inner lip 8 Points [60-67]
With this 68 Points , We can easily know where the eyes and mouth are , We will rotate the picture later , Zoom and miscut , Keep your eyes and mouth as close to the center as possible .

Now the faces are basically aligned , This makes the next step more accurate .

Step 3 : Code face

We still have a core problem , That's how to distinguish different faces .

The easiest way is to compare the unknown face we found in step 2 with the known face . When we find that an unknown face looks similar to a previously labeled face , You can identify them as the same person .

We humans can get through the size of our eyes , Hair color and other information can easily distinguish two different faces , But how can computers tell ? you 're right , We have to quantify them , Measure their differences , How do we do that ?

actually , It's easy to distinguish the information of human face , But for computers , These values are of little value . In fact, the most accurate way is to let the computer find out the measurement he wants to collect . Deep learning is more important than human understanding which facial measurements are more important .

therefore , The solution is to train a deep convolution neural network , Training to make it for the face 128 Measurements .

Three different facial images should be observed in each training :

* Load a face training image of a known person
* Load another photo of the same person
* Load another person's photo
then , The algorithm looks at its own measurements generated for these three images . And then , Adjust the neural network slightly , To ensure that the measurements generated in the first and second sheets are close , The second and the third generate slightly different measurements .

We need to constantly adjust the sample , Repeat the above steps millions of times , It's a big challenge , But once it's done , It can easily find out the face .

Fortunately OpenFace The God above has done this , And they've released several networks that they've trained to use directly , We can learn without deploying complex machines , Out of the box , Thank you for the open source spirit .

this 128 What's a measurement ?

Actually, we don't care , It doesn't matter to us either . What we care about is , When you see two different pictures of the same person , Our network needs to be able to get almost the same value .

Step 4 : Find a person's name from the code

The last step is actually the simplest , What we need to do is find the person in the database that is closest to the measurement value of our test image .

How to do it , We use some ready-made mathematical formulas , Calculate two 128D Numerical Euclidean distance .

So we get a Euclidean distance , The system will give it a threshold of Euclidean distance for the same person , Beyond that threshold, we assume that they are with ( lose ) One ( scattered ) individual ( Brother ) people ( Younger brother ).

So that's how face recognition works , Let's review the next process :

* use HOG Find out the location of all the faces in the picture .
* Calculate the 68 Feature points and adjust face position appropriately , Align faces .
* Put the facial image from the previous step into the neural network , obtain 128 Characteristic measurements , And save them .
* Calculate the Euclidean distance together with the measurements we have previously saved , Get the Euclidean distance , Compare values , Can get the same person .
2, Face recognition application scenario

Face recognition is divided into two steps , Face detection and recognition , Their application scenarios are also different .

The purpose of face detection is to find out the face , Get the position of the face , We can be in beauty , skin peeler , Matting , Face change
It is used in some scenes of . We can use the system API Calling camera to complete real-time rendering of preview needle , We can play with those black technologies .

Face recognition can be used by members , Used in payment and other scenarios , Bring users cooler use scenarios , Let's try .

©2019-2020 Toolsou All rights reserved,
ELementUI select Multi select drop-down box to get all properties of the selected item Novices play hiss HI3520D Development board ( One , upgrade ) Obviously post Why does the request display parameters in the address bar ?C#/.NET System optimization (redis Chapter 6 data structure 【List】)element-ui+vue-treeselect Verification of drop down box Thread.getContextClassLoader And Thread.getClassLoader() difference Java Thread of Sleep() Summary of usage golang One line of code converts the slice into a semicolon separated string ( Essence )2020 year 7 month 30 day Wechat applet Use of modules ( Essence )2020 year 6 month 26 day C# Class library Log help class