Passport Recognition
Requirements
- The input image must have 4 clear angles or all main components of a passport such as photocard, document title.
- All information fields must be visible, readable, unmodified, not blurred.
- The input image size does not exceed 5 MB and the minimum resolution is approximately 960x720 to ensure the confident rate.
- The ratio of passport area must be at least 1/3 of the total image area.
Request
Request Url
POST https://api.fpt.ai/vision/passport/vnm?fraud_check=1&integrity_check=1&post_check=1
Request Headers
| Parameter | Required | Default | Description |
|---|---|---|---|
| api_key | Yes | Your api key ( get from console.fpt.ai ) |
Request Body
In order to recognize an passport on the photo, a single image or image URL must be sent with the request by using one in two keys below:
| Parameter | Required | Type | Description |
|---|---|---|---|
| image | No. Set either this parameter or image_url. | File | Image file |
| image_url | No. Set either this parameter or image or image_base64. | String | Image URL. Currently, HTTP/HTTPS URLs are supported |
Sample Request
curl --location --request POST 'https://api.fpt.ai/vision/passport/vnm?fraud_check=1&integrity_check=1&post_check=1' \
--header 'api_key: xxxxxxx' \
--form 'image=@/path/to/image'
or
curl --location --request POST 'https://api.fpt.ai/vision/passport/vnm?fraud_check=1&integrity_check=1&post_check=1' \
--header 'api_key: xxxxxxx' \
--form 'image_url="link/to/image"'
Response
JSON
{
"errorCode" : x,
"errorMessage" : "xxxx",
"data" : [xxxx]
}
The system is able to extract the information of passport plus several checking results to make sure the integrity of the ID card image. The checking result includes fraud check before the OCR process has finished and post check after the OCR process has finished.
After successfully sending the request, the system will return a json file that includes text information about the image quality using the format below:
- errorCode: value is 0 if the request was successful with no error occurred
- errorMessage: value is equal to empty string if the request was successful with no error occurred
- data: includes all information about the content in the ID card and the checking results if the request succeeds without errors or return empty list [] if an error occurs. Also included with the information returned is the probability that indicates the reliability of the returned results. Besides, the data field also includes pre-check results and post-check results (check the details below).
(The detail of the errors that might occure include both errorCode and errorMessage is described on Errors)
Response details
Success response
{
"errorCode" : 0,
"errorMessage" : "",
"data": [
{
"name": "xxxx",
"name_prob": "97.34",
"nationality": "xxxx",
"nationality_prob": "95.24",
"dob": "xxxx",
"dob_prob": "97.14",
"pob": "xxxx",
"pob_prob": "99.59",
"sex": "xxxx",
"sex_prob": "98.23",
"doe": "xxxx",
"doe_prob": "97.20",
"poi": "xxxx",
"poi_prob": "98.37",
"mrz_1": "xxxx",
"mrz_1_prob": "97.64",
"mrz_2": "xxxx",
"mrz_2_prob": "97.65",
"passport_class": "P",
"passport_class_prob": "96.96",
"country_code": "xxxx",
"country_code_prob": "99.99",
"passport_number": "xxxx",
"passport_number_prob": "96.14",
"id_number": "xxxx",
"id_number_prob": "98.03",
"doi": "xxxx",
"doi_prob": "97.47",
"overall_score": "96.96",
"face": "xxxx",
"face_base64": "xxxx",
"cropped_idcard": "xxxx",
"cropped_idcard_base64": "xxxx",
"low_score_result": [],
"type": "new",
"post_check_result": {
"result": "Passed",
"message": ""
},
"mrz_check_result": {
"result": "Passed",
"mrz_ocr_result": [
"xxxx",
"xxxx"
],
"mrz_ocr_result_prob": [
"97.64",
"97.65"
]
},
"face_check_result": {
"result": "Passed",
"prob": "1.00"
},
"corner_cut_check_result": {
"result": "Passed",
"prob": [
"0.00",
"0.00"
]
},
"recaptured_check_result": {
"result": "Passed",
"prob": "0.00"
},
"photocopied_check_result": {
"result": "Passed",
"prob": "0.73"
},
"perforated_check_result": {
"result": "Passed",
"prob": "0.00"
},
"edited_result": {
"result": "Passed",
"prob": "0.00"
}
}
]
}
The API responses composes of 3 types of information:
- OCR result
- Pre-check result
- Post-check result
OCR result includes 13 data fields:
| Field | Description |
|---|---|
| passport_class | Passport class |
| passport_number | Passport number |
| name | Name |
| nationality | Nationality |
| dob | Date of birth |
| pob | Place of birth |
| poi | Issuing place |
| sex | Gender |
| id_number | ID number |
| doi | Date of issue |
| doe | Expiry date |
| country_code | Country code of passport |
| mrz_1 | Machine readable information line 1 |
| mrz_2 | Machine readable information line 2 |
| type | Type of passport (including values: old / new / foreign) |
| face | Link to face image |
| face_base64 | Face image in base64 |
| cropped_idcard | Link to cropped passport image |
| cropped_idcard_base64 | Cropped passport image in base64 |
Pre-check results
The pre-check results includes 5 fields of information:
| Error code | Field | Description |
|---|---|---|
| FC02 | recaptured_check_result | Checking result of recapturing passport from a LCD screen |
| FC07 | mrz_check_result | Checking result of the passport if its MRZ is covered/missing |
| FC04 | corner_cut_check_result | Checking result of the passport if its corner is cut |
| FC05 | face_check_result | Checking result of the passport if the human face on it is covered/missing |
| FC01 | photocopied_check_result | Checking result of the document if it is a photocopied version (color or black-and-white) |
| FC03 | edited_result | Checking result of the document if it is edited |
| FC14 | low_score_result | List of fields contain low-score characters |
| FC20 | perforated_check_result | Checking result of the passport if it has been perforated |
The results of following criteria are in Passed/Failed, so good image should has all-Passed results.
- recaptured_check_result: is "Passed" if "prob"
<= 0.5, otherwise "Failed" ("prob" is the probability of the passport being recaptured from a LCD screen and in range from 0 to 1). - mrz_check_result: is "Passed" if "mrz_ocr_result_prob"
>= 50, otherwise "Failed" ("mrz_ocr_result_prob" is the probability of the MRZ being OCRed and in range from 0 to 100). - corner_cut_check_result: is "Passed" if "prob" of 2 corners
<= 0.5, otherwise "Failed" ("prob" is the probability of the passport being cut and in range from 0 to 1). - face_check_result: is "Passed" if "result" is "Passed", otherwise "Failed".
- photocopied_check_result: is "Passed" if "prob"
>= 0.5, otherwise "Failed" ("prob" is the probability of the passport being a photocopied version and in range from 0 to 1). - edited_result: is "Passed" if "prob"
<= 0.5, otherwise "Failed" ("prob" is the probability of the passport being edited and in range from 0 to 1). - perforated_check_result: is "Passed" if "prob"
<= 0.5, otherwise "Failed" ("prob" is the probability of the passport being perforated and in range from 0 to 1).
The result of criterion low_score_result is the list of fields that contain low-score characters.