Face Matching
Matching service is an AI system that allows to compare the similarity between the face in the identity card, the owner's identity card with the face taken directly of the same person.
1. Match photo face on ID card, citizen ID and portrait photo with photo URL input
API:
Method | URL |
---|---|
GET | https://cloud.computervision.com.vn/api/v2/ekyc/face_matching |
Params:
Key | Value | Description |
---|---|---|
img1 | https://example.com/card.png | ID card photo URL |
img2 | https://example.com/portrait.png | Face photo URL to match |
type1 | portrait /card | Data type of image 1, get values: portrait , card |
format_type | url | Type of data to pass in, receive values: url , file , base64 |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"img_card = 'link_url_img_card'img_portrait = 'link_url_portrait'response = requests.get("https://cloud.computervision.com.vn/api/v2/ekyc/face_matching?img1=%s&img2=%s&type1=%s&format_type=%s"% (img_card, img_portrait, 'card', 'url'),auth=(api_key, api_secret))print(response.json())
2. Match photo face on ID card, citizen ID and portrait with image file input
API:
Method | URL | content-type |
---|---|---|
POST | https://cloud.computervision.com.vn/api/v2/ekyc/face_matching | multipart/form-data |
Params:
Key | Value | Description |
---|---|---|
type1 | portrait /card | Data type of image 1, get values: portrait , card |
format_type | file | Type of data to pass in, receive values: url , file , base64 |
Body:
Key | Type | Value | Description |
---|---|---|---|
img1 | file | example_card.jpg | ID photo file |
img2 | file | example_portrait.jpg | Face image file to match |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"img_card_path = '/path/to/your/img_card.jpg'img_portrait_path = '/path/to/your/img_portrait.jpg'response = requests.post("https://cloud.computervision.com.vn/api/v2/ekyc/face_matching?type1=%s&format_type=%s"% ('card', 'file'),auth=(api_key, api_secret),files={'img1': open(img_card_path, 'rb'), 'img2': open(img_portrait_path, 'rb')})print(response.json())
3. Match photo face on ID card, citizen ID and portrait with JSON input
API:
Method | URL | content-type |
---|---|---|
POST | https://cloud.computervision.com.vn/api/v2/ekyc/face_matching | application/json |
Params:
Key | Value | Description |
---|---|---|
type1 | portrait /card | Data type of image 1, get values: portrait , card |
format_type | base64 | Type of data to pass in, receive values: url , file , base64 |
Body:
{"img1": "iVBORw0KGgoAAAANSU...", // string base64 of ID card photo"img2": "iVBORw0KGgoAAAANSU..." // string base64 of the face image to match}
Demo Python:
import base64import ioimport requestsfrom PIL import Imagedef get_byte_img(img):img_byte_arr = io.BytesIO()img.save(img_byte_arr, format='PNG')encoded_img = base64.encodebytes(img_byte_arr.getvalue()).decode('ascii')return encoded_imgapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"img_card_path = '/path/to/your/img_card.jpg'img_portrait_path = '/path/to/your/img_portrait.jpg'encode_card = get_byte_img(Image.open(img_card_path))encode_portrait = get_byte_img(Image.open(img_portrait_path))response = requests.post("https://cloud.computervision.com.vn/api/v2/ekyc/face_matching?type1=%s&format_type=%s"% ('card', 'base64'),auth=(api_key, api_secret),json={'img1' : encode_card, "img2" : encode_portrait})print(response.json())
4. Response
For ID card face matching service, the response has the following format:
{"data": {"matching": string, // Percentage similarity between two input images"face1": string, // Face ID photo"face2": string, // Portrait face photo"face1_score": string, // Confidence of face1"face2_score": string, // Confidence of face2"invalidCode": string,"invalidMessage": string,"match": string // 1 if percentage matching > 75%, 0 if percentage matching between [65%, 75%], otherwise -1},"errorCode": string,"errorMessage": string}
Error code table:
Code | Message |
---|---|
0 | Success |
1 | The photo does not contain content |
2 | Url is unavailable |
3 | Incorrect image format |
4 | Out of requests |
5 | Incorrect api_key or api_secret |
6 | Incorrect format type |
Warning error code table:
Code | Message |
---|---|
0 | Successful |
1 | The ID card photo is not existed |
2 | The picture is a photocopy version of the id card |
3 | The ID card photo is suspected of tampering |
4 | The ID card photo does not contain a face |
5 | The portrait photo does not contain a face |
6 | Photo contains more than one face |
7 | Wearing sunglasses |
8 | Wearing a hat |
9 | Wearing a mask |
10 | Photo taken from picture, screen, blurred noise or sign of fraud |
11 | The face in the picture is too small |
12 | The face in the portrait photo is too close to the margin |