In our previous article on Automatic information extraction from personal ID with FPT.AI API, Mr. Tran Duc Long had listed detailed instructions on how to connect API OCR using NodeJs. In this article, the author will introduce how to use Facematch easily and effectively with FPT.AI’s API Facematch.

Face identification is applicable in various input procedures of various fields, including finance-banking, telecommunications, traveling, and hospitability. Notable applications include: Opening bank accounts, opening banking cards, phone registration, hotel booking, flight check-in, and so on.

Before calling API, we will need to standardize images in accordance with the following requirements:

  • Image format must be either .jpg or .jpeg.
  • Image must not be over 5 MB, with definition of at least 640×480 to ensure accuracy.
  • The face must account for at least a quarter of the total image size.

Basic API information:

1. Request

Request Url
POST https://api.fpt.ai/dmp/checkface/v1/


2. Request Headers

Parameter Requirement Default Description
API Key Yes Your API_Key (from console.fpt.ai )


3. Request Body

FormData includes 2 images to be reviewed.

Parameter Requirement
file[] Yes
file[] Yes

Notice: add “file[]” field twice.

4. Sample Request

5. Response (JSON)

  • isMatch: Shows if 2 images were of the same person (80% benchmark).
  • similarity: Similarity of 2 pictures.
  • isBothImgIDCard: Shows if 2 images were an ID Card.
6. Response Code

Code Ý nghĩa
200 Success
407 Face cannot be identified
408 Input image was in the wrong format
409 There are more or less faces (2) to be identified


7. Sample Response: Success

8. Sample Response: Error

Following is how to perform an API connection and several tips in entity application with NodeJS and ReactJs.

a. Building user interface

With ReactJS, the author will use one user form and introduce the procedure step by step:

Case 1:

Case 2:

Case 3:

Case 4:

Here, the author uses the “step” state, which can be increased or decreased per each user step. The steps, respectively, are: Go to LandingPage, Take Photo of ID (ID TakeShot), Re-Confirm Information (ConfirmInfo), and Facematching (FaceMatch).

To increase/decrease the “step” state, we will use nextStep and prevStep, and users will be allowed to move onto the next step or go back to the previous step during Facematching.

// Proceed to next step

 

// Go back to prev step

After IDTakeShot, we will have the ID information (ConfirmInfo) via FPT.AI’s API OCR. Next, we will see if the ID and portrait is of the same person (FaceMatch).

b. Connect API Facematch

After taking a photo of the ID card, confirming information, and take a selfie, we will start to call API Facematch.

We can see that file 1 is a base64 image, transferred from the IDTakeShot form, while file 2 is the selfie to be facematched.

Notice that normally, the selfie image size tends to be quite large, while the API can facematch without such large sizes. Therefore, before sending the image to servers, we will need to reduce the image size.

In React we will have the ‘react-image-file-resizer’ library.

The image had been resized to 400px Height, 400px Width and 90% Quality. Furthermore, we will also need to check if the file uploaded were an image.

After finishing the server, we will move on to server with NodeJS.

First, we will need to import some libraries:

Then, we need to identify the input:

Notice: API Facematch current accepts file inputs only, therefore we will need to reform the image from base64 to file before transferring.

Then, call API Facematch:

The returned response will be in JSON, and shall include the following information:

  • isMatch: Shows if 2 images were of the same person (80% benchmark).
  • similarity: Similarity of 2 pictures.
  • isBothImgIDCard: Shows if 2 images were an ID Card.

We will use the returned information in accordance with the requirements of practical problems.

KYC – Know Your Customer is a vital element for financial organizations, especially when in opening bank accounts. Along with technological advancements to simplify papers and procedures to bring more convenience for customers, various banks of many different countries have now received approvals from authorities to identify their customers via eKYC.

Tran Duc Long – FPT Head Office

Related posts: