Your Face as a Key
The first time you set up facial unlock, the phone asks you to look at the camera and slowly move your head. It is not learning what you look like in the way a friend would, by remembering a familiar expression. It is doing something more like measuring you. By the time those few seconds are over, the phone has built a private record of your face that it will compare against every time you pick the device up.
Turning a Face Into Numbers
A facial recognition system uses the camera, and on some phones a depth or infrared sensor, to look at the face and pick out very specific features. It measures distances between particular points — the gap between the eyes, the width of the nose, the line of the jaw, the shape of the cheekbones — and turns those measurements into a long sequence of numbers. This number pattern is sometimes called a faceprint, and it is what actually gets stored on the device. The phone is not keeping a photo of you; it is keeping a mathematical summary unique enough to tell you apart from other people.
What Happens at the Lock Screen
When you raise the phone to unlock it, the camera and sensors take a fresh look at your face and quickly build the same kind of number pattern in real time. The phone compares this new pattern to the one it stored during setup. If the two match closely enough, the phone is satisfied that the same person is in front of it and unlocks. If the patterns are too different, it stays locked, and you fall back to a passcode.
Trying to Outsmart It
A flat photograph of someone's face could in theory fool a simple system, so most modern phones add depth and infrared sensing. Infrared light is invisible to the eye, but the phone uses it to map the three-dimensional shape of your face, not just its flat appearance. A photo printed on paper has no depth, and a screen image has the wrong reflections, so they fail the check. This is what makes facial unlock a form of biometric identification: it leans on a physical trait that is hard to fake, the same way a fingerprint scanner uses the unique ridges on your finger.
Source
This article was written using information from Wikipedia.