Liveness Verify
1. Thực hiện eKYC sử dụng ảnh chụp chân dung người dùng ở 3 góc độ với đầu vào URL ảnh
API:
| Method | URL | 
|---|---|
| GET | https://demo.computervision.com.vn/api/v2/ekyc/verify_liveness | 
Params:
| Key | Value | Mô tả | 
|---|---|---|
| portrait_left | https://example.com/left.png | URL ảnh quay trái | 
| portrait_mid | https://example.com/mid.png | URL ảnh chụp chính diện | 
| portrait_right | https://example.com/right.png | URL ảnh quay phải | 
| format_type | url | Loại data truyền vào, nhận các giá trị: url,file,base64 | 
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"portrait_left = 'link_url_portrait_left'portrait_mid = 'link_url_portrait_mid'portrait_right = 'link_url_portrait_right'response = requests.get("https://demo.computervision.com.vn/api/v2/ekyc/verify_liveness?portrait_left=%s&portrait_mid=%s&portrait_right=%s&format_type=%s"% (portrait_left, portrait_mid, portrait_right, 'url'),auth=(api_key, api_secret))print(response.json())
2. Thực hiện eKYC sử dụng ảnh chụp chân dung người dùng ở 3 góc độ với đầu vào file ảnh
API:
| Method | URL | content-type | 
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ekyc/verify_liveness | multipart/form-data | 
Params:
| Key | Value | Mô tả | 
|---|---|---|
| format_type | file | Loại data truyền vào, nhận các giá trị: url,file,base64 | 
Body:
| Key | Type | Value | Mô tả | 
|---|---|---|---|
| portrait_left | file | example_1.jpg | File ảnh quay trái của người dùng | 
| portrait_mid | file | example_2.jpg | File ảnh chụp chính diện của người dùng | 
| portrait_right | file | example_3.jpg | File ảnh quay phải của người dùng | 
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"img1_path = '/path/to/your/example_1.jpg'img2_path = '/path/to/your/example_2.jpg'img3_path = '/path/to/your/example_3.jpg'response = requests.post("https://demo.computervision.com.vn/api/v2/ekyc/verify_liveness?format_type=file",auth=(api_key, api_secret),files={ 'portrait_left': open(img1_path, 'rb'),'portrait_mid': open(img2_path, 'rb'),'portrait_right': open(img3_path, 'rb')})print(response.json())
3. Thực hiện eKYC sử dụng ảnh chụp chân dung người dùng ở 3 góc độ với đầu vào JSON
API:
| Method | URL | content-type | 
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ekyc/verify_liveness | application/json | 
Params:
| Key | Value | Mô tả | 
|---|---|---|
| format_type | base64 | Loại data truyền vào, nhận giá trị: url,file,base64 | 
Body:
{"portrait_left": "iVBORw0KGgoAAAANSU...", // string base64 của ảnh quay trái"portrait_mid": "iVBORw0KGgoAAAANSU...", // string base64 của ảnh chính diện"portrait_right": "iVBORw0KGgoAAAANSU..." // string base64 của ảnh quay phải}
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"portrait_left_path = '/path/to/your/portrait_left.jpg'portrait_mid_path = '/path/to/your/portrait_mid.jpg'portrait_right_path = '/path/to/your/portrait_right.jpg'encode_portrait_left = get_byte_img(Image.open(portrait_left_path))encode_portrait_mid = get_byte_img(Image.open(portrait_mid_path))encode_portrait_right = get_byte_img(Image.open(portrait_right_path))response = requests.post("https://demo.computervision.com.vn/api/v2/ekyc/verify_liveness?format_type=base64",auth=(api_key, api_secret),json={'portrait_left': encode_portrait_left, 'portrait_mid': encode_portrait_mid, 'portrait_right': encode_portrait_right})print(response.json())
4. Thông tin trả về
Thông tin trả về của API Liveness Verify là một JSON với định dạng sau:
{"data": {"invalidCode": string, // Mã cảnh báo"invalidMessage": string, // Cảnh báo nếu ảnh chân dung hoặc ảnh giấy tờ có dấu hiệu làm ảnh hưởng đến kết quả"matching_mid_left": string,"matching_mid_right": string,"valid": string // (True/False)},"errorCode": string, // Mã lỗi"errorMessage": string // Thông báo lỗi}
Bảng mã lỗi:
| Mã lỗi | Message | Mô tả | 
|---|---|---|
| 0 | Success | So khớp thành công | 
| 1 | The photo does not contain content | Upload ảnh bị lỗi khi dùng POST | 
| 2 | Url is unavailable | Download ảnh bị lỗi khi dùng GET | 
| 3 | Incorrect image format | Tồn tại ảnh không có mặt người | 
| 4 | Out of requests | Hết số lượng request | 
| 5 | Incorrect api_key or api_secret | Khi api_key hoặc api_secret sai | 
| 6 | Incorrect format type | Loại format khai báo trong format_type không đúng với ảnh truyền vào | 
Bảng mã lỗi cảnh báo:
| Mã lỗi | Message | Mô tả | 
|---|---|---|
| 0 | Successful | Thành công | 
| 1 | The mid image does not contain face | Ảnh chụp chính diện không chứa khuôn mặt | 
| 2 | The left image does not contain face | Ảnh chụp quay trái không chứa khuôn mặt | 
| 3 | The right image does not contain face | Ảnh chụp quay phải không chứa khuôn mặt | 
| 4 | The mid image and the left image do not match | Khuôn mặt ảnh chụp chính diện và quay trái không cùng một người | 
| 5 | The mid image and the right image do not match | Khuôn mặt ảnh chụp chính diện và quay phải không cùng một người | 
| 6 | Invalid center image | Ảnh chụp chính diện không hợp lệ | 
| 7 | Invalid left image | Ảnh chụp quay trái không hợp lệ | 
| 8 | Invalid right image | Ảnh chụp quay phải không hợp lệ |