The AI reads passport images and converts them into Thai-English data.
Beta version: The platform is in a development stage of the final version, which may be less stable than usual. The efficiency of platform access and usage might be limited. For example, the platform might crash, some features might not work properly, or some data might be lost.
The OCR passport model consists of three main components: a detector, recognizer, and parsing rules. Overall, the input image is sent to the detector, recognizer, and post-processing rules respectively, resulting in a key-value pair of information present in the ID card in a JSON format.
We use CER to evaluate an OCR passport model. Generally, the lower CER means better performance.
The API endpoint receives an HTTP POST request in a multi-part form data format. The returned output will be a JSON object specifying each extracted information.
The input should be images e.g., JPEG, JPG, and PNG formats, and should be sent to the API in a multipart format. Users can also specify whether to detect whether we are using a front or back side of the ID card, and the specified sides should strictly match the number of images sent. In case the user does not specify the detection sides, all of the images will be automatically set as a front side. The code example for Python can be found below:
from typing import Any, Dict, List
import requests
def extract_id_visai(img_paths: List[str], sides: List[str]) -> Dict[str, Any]:
"""""Use VISAI IDCARD API to extract information from given ID cards
Arguments:
img_paths: List[str]
Path to image files to extract
sides: List[str]
Side of each image. Can be either "front" or "back" only
"""
assert len(img_paths) == len(sides), "Number of sides and image path should be equal"
files = [
("files", ("file", open(_img, "rb"), "image/png"))
for _img in img_paths]
# sides were joined into one string using "," as a delimiter
data = {"side": ",".join([_side for _side in sides])}
r = requests.post(f"{self.base_url}/predict", files=files, data=data)
# close any opened files
for _, (_, f, _) in files:
f.close()
result = r.json()
return result
idcard_imgs = ["/path/to/image1.jpg", "/path/to/image2.png"]
results = extract_id_visai(idcard_imgs, ["front", "back"])
```
The output is a structured JSON containing 2 main parts:
The example of output is shown below.
{
"status": “success”,
"data": {
"fields": {
"name": "xxx",
"surname": "xxx",
"date_of_birth": "xx xxx xxxx",
"gender": "M",
"country_code": "THA",
"country_name": "Thailand",
"identification_number": "xxxxxxxxxxxxx",
"passport_number": "xxxxxxxxx",
"passport_type": "P",
"date_of_expiry": "02 FEB 2026"
},
"confidence": 0.9994
}
}