Skip to main content

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

ParameterRequiredDefaultDescription
api_keyYesYour 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:

ParameterRequiredTypeDescription
imageNo. Set either this parameter or image_url.FileImage file
image_urlNo. Set either this parameter or image or image_base64.StringImage 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:

  1. OCR result
  2. Pre-check result
  3. Post-check result

OCR result includes 13 data fields:

FieldDescription
passport_classPassport class
passport_numberPassport number
nameName
nationalityNationality
dobDate of birth
pobPlace of birth
poiIssuing place
sexGender
id_numberID number
doiDate of issue
doeExpiry date
country_codeCountry code of passport
mrz_1Machine readable information line 1
mrz_2Machine readable information line 2
typeType of passport (including values: old / new / foreign)
faceLink to face image
face_base64Face image in base64
cropped_idcardLink to cropped passport image
cropped_idcard_base64Cropped passport image in base64

Pre-check results

The pre-check results includes 5 fields of information:

Error codeFieldDescription
FC02recaptured_check_resultChecking result of recapturing passport from a LCD screen
FC07mrz_check_resultChecking result of the passport if its MRZ is covered/missing
FC04corner_cut_check_resultChecking result of the passport if its corner is cut
FC05face_check_resultChecking result of the passport if the human face on it is covered/missing
FC01photocopied_check_resultChecking result of the document if it is a photocopied version (color or black-and-white)
FC03edited_resultChecking result of the document if it is edited
FC14low_score_resultList of fields contain low-score characters
FC20perforated_check_resultChecking 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:

MesageDescription (Vietnamese)
PassedKiểm tra thành công
There is a NULL fieldCó một trường thông tin nào đó bị trống
Passport number format is not correctCấu trúc số passport không đúng
Name cannot contain digitsTên không thế chứa chữ số
DoB format is not correctCấu trúc của ngày sinh không đúng
DoB is later than todayNgày sinh không thể sau ngày hôm nay
ID number format is not correctCấu trúc số ID không đúng
DoI format is not correctCấu trúc của ngày phát hành không đúng
DoI is later than todayNgày phát hành không thể sau ngày hôm nay
DoE format is not correctCấu trúc của ngày hết hạn không đúng
DoE cannot be later than DoI + 10 yearsNgày hết hạn không thể quá 10 năm kể từ ngày cấp
Cannot find pob codeKhông tìm thấy mã nơi sinh
PoB code does not matchMã nơi sinh không khớp với số ID
Year in DoB is not match with ID numberNăm sinh không khớp với số ID
Passport has been expiredGiấy tờ hết hạn
Gender code is not matchGiới tính không khớp với mã trong số ID

Errors

The system uses the error codes as follows:

Error CodeMeaning
-1Undefined error -- Undefined error from system (this error should not happened in normal cases)
0No error -- This is a successful call, no error
1Invalid Parameters or Values! -- Wrong parameter in the request (e.g. no key or image in the request body).
3Unable 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).
5No URL in the request -- The request uses the image_url key but the value is left blank.
6Failed to open the URL! -- The request uses the image_url key but the system cannot open this URL.
7Invalid image file -- The uploaded file is not an image file.
8Bad data -- The uploaded image file is corrupted or the format is not supported.
9No string base64 in the request -- The request uses image_base64 key but the value is left blank.
10String base64 is not valid -- The request uses image_base64 key but the provided string is invalid.