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.
Post-check results
The post-check process will check the integrity in the information extracted from the document (1 side or 2 sides). For example: date of birth format, date of issuing format, ID number should match date of birth and address, etc. (check below for the details). If all the post-check tests are passed, the result will be:
{
    "post_check_result": {
        "result": "Passed",
        "message": ""
    }
}
In the case of not passing any tests, the result will be "Failed" and include the failing message. For example:
{
    "post_check_result": {
        "result": "Failed",
        "message": "Passport has been expired"
    }
}
Post-check process
List of post-check error messages:
| Mesage | Description (Vietnamese) | 
|---|---|
| Passed | Kiểm tra thành công | 
| There is a NULL field | Có một trường thông tin nào đó bị trống | 
| Passport number format is not correct | Cấu trúc số passport không đúng | 
| Name cannot contain digits | Tên không thế chứa chữ số | 
| DoB format is not correct | Cấu trúc của ngày sinh không đúng | 
| DoB is later than today | Ngày sinh không thể sau ngày hôm nay | 
| ID number format is not correct | Cấu trúc số ID không đúng | 
| DoI format is not correct | Cấu trúc của ngày phát hành không đúng | 
| DoI is later than today | Ngày phát hành không thể sau ngày hôm nay | 
| DoE format is not correct | Cấu trúc của ngày hết hạn không đúng | 
| DoE cannot be later than DoI + 10 years | Ngày hết hạn không thể quá 10 năm kể từ ngày cấp | 
| Cannot find pob code | Không tìm thấy mã nơi sinh | 
| PoB code does not match | Mã nơi sinh không khớp với số ID | 
| Year in DoB is not match with ID number | Năm sinh không khớp với số ID | 
| Passport has been expired | Giấy tờ hết hạn | 
| Gender code is not match | Giới tính không khớp với mã trong số ID | 
Errors
The system uses the error codes as follows:
| Error Code | Meaning | 
|---|---|
| -1 | Undefined error -- Undefined error from system (this error should not happened in normal cases) | 
| 0 | No error -- This is a successful call, no error | 
| 1 | Invalid Parameters or Values! -- Wrong parameter in the request (e.g. no key or image in the request body). | 
| 3 | Unable to find ID card in the image -- The system cannot find the passport in the image or the image is of poor quality (too blur, too dark/bright). | 
| 5 | No URL in the request -- The request uses the image_url key but the value is left blank. | 
| 6 | Failed to open the URL! -- The request uses the image_url key but the system cannot open this URL. | 
| 7 | Invalid image file -- The uploaded file is not an image file. | 
| 8 | Bad data -- The uploaded image file is corrupted or the format is not supported. | 
| 9 | No string base64 in the request -- The request uses image_base64 key but the value is left blank. | 
| 10 | String base64 is not valid -- The request uses image_base64 key but the provided string is invalid. |