How to use Huawei ML kit-Face Verification feature?
In this article, I am going to give you information about Huawei ML kit’s Face Verification and how to use it in native android applications. Let’s get started :)
Integrating Applications to HMS Core
To start developing an app with Huawei mobile services, you need to integrate your application to the HMS core. Check the link below to integrate your application, also don’t forget to enable the ML kit from AppGallery Connect.
Service Introduction
This service recognizes and extracts key features of the face in the template, compares the features with those of the face in the input image, and then determines whether the two faces belong to the same person based on their similarity.
Use Cases
This service is widely used in many fields of daily life. For example, the service can compare faces in the mobile gallery and classify them according to their similarity. This helps users manage the mobile gallery and find images in it. Face verification is also useful for the financial service sector. When a user tries to open an account remotely using your app, your app can use this service to perform identity authentication, making the opening process fast and secure with controllable risk factors. If your app is for fun, you can leverage the facial similarity provided by this service to develop interesting functions. For example, your app can tell how much its user and another person look like a couple according to the images he/she uploads. Besides, this service can also be used for smart clock-in/out and facial authentication of smart gates in smart campuses.
Precautions
- Currently, the service cannot compare two faces greatly different in age or blocked area proportion (over 30%).
- If a template image contains multiple faces, the biggest one is chosen as the template face. If the input image contains multiple faces, the service extracts the three largest faces for comparison with the template face.
- The service can produce its optimal effect if the following conditions are met.
Preparations for the Code
Let’s try Face verification with a demo application. In this example, I will give 2 images as input and try to learn if those two faces in the images belong to the same person.
The total size of the model is around 6.5 MB.
Java Code of the Face Verification
It is really simple, isn’t it? First, we set images to Imageview, and between lines 24–27, then we create an analyzer and first frame with the input. On line 29 it is essential to check if the input frame contains proper face(s). After this control, we can start the Comparing part. On “startCompare” method we set our second frame to compare with the first image. Finally, in the Successful scenario, we also print the probability.
In conclusion, this feature can be used in many areas like Facial authentication, Face similarity apps, or grouping images according to the person in the image, etc.
Also, Like Huawei Face detection this feature works totally on-device. Therefore it works fast and securely.
Take care of yourself until next time …