How to Quickly Recognize Fake Faces
Have you ever wondered whether unlocking your phone with facial recognition is really safe?
Join the DZone community and get the full member experience.Join For Free
Have you ever wondered whether unlocking your phone with facial recognition is really safe? What if someone masqueraded as you by using photos or videos of you, could your phone detect that it's not you in front of the camera? Well, thanks to ML Kit's liveness detection capability, it can! This feature accurately distinguishes between real faces and fake ones. Whether it’s a photo, video, or mask, liveness detection can immediately expose those fake faces!
Liveness detection is generally used to perform a face match. First, it will determine whether the person in front of the camera is a real person, instead of a person holding a photo or a mask. Then, face match will compare the current face to the one it has on record, to see if they are the same person. Liveness detection is useful in a huge range of situations. For example, it can prevent people from unlocking your phone and accessing your personal information.
It can be used for real-name authentication. It determines whether the person in front of the camera is a real person, and then compares their face with the photo on the ID card, to confirm that the person handling the service is the same person on the ID card.
And ML Kit's liveness detection also supports silent detection, where it can determine whether the user’s face is real without them having to do anything. Pretty convenient, right? Now, I'll show you how to quickly integrate liveness detection.
Liveness Detection Development
You can find detailed information about the preparations you need to make on the HUAWEI Developers-Development Process.
Here, we'll just look at the most important procedures.
1.1 Configure the Maven Repository Address in the Project-Level build.gradle File
1.2 Configure SDK Dependencies in the App-Level build.gradle File
1.3 Add Configurations to the File Header
1.4 Add these Statements to the AndroidManifest.xml File so the Machine Learning Model can Update Automatically
1.5 Apply for Camera Permission
For detailed procedures about how to apply for camera permission, please refer to HUAWEI Developers-Assigning Permissions.
2. Code Development
2.1 Create a Liveness Detection Result Callback to Obtain the Detection Results
2.2 Create a Liveness Detection Instance and Start the Detection
Below, you can see how the liveness detection capability differentiates between a real face and face mask. Isn't it great?
To find out more, take a look at our official website: HUAWEI ML Kit.
Opinions expressed by DZone contributors are their own.