Skip to main content

🚗 Thai Driver License OCR

🚗 ใบขับขี่ไทย

Version Status New

Welcome to Thai Driver License OCR API, version 1.1, an AI product developed by iApp Technology Co., Ltd. Our API is designed to extract text information from the front face of Thai Driver License card images with high accuracy and speed. Our API supports JPEG, JPG, PNG file formats and can process a driver license image in 1-2 seconds.

Try Demo

Visit our API Portal to test the Thai Driver License OCR API with your own images.

Getting Started

  1. Prerequisites

    • An API key from iApp Technology
    • Thai driver license images (front)
    • Supported file formats: JPEG, JPG, PNG
    • Maximum file size: 10MB
  2. Quick Start

    • Fast processing (1-2 seconds per card)
    • High accuracy text extraction (95.14% at character level)
    • Support for multiple file formats
  3. Key Features

    • Detailed field extraction including:
      • License number
      • Full name (Thai and English)
      • Date of birth
      • Issue and expiry dates
      • ID number
      • Registrar information
    • Support for front side of driver license
    • Option to return face photo in base64 format
    • Flexible JSON response format
  4. Security & Compliance

    • GDPR and PDPA compliant
    • No data retention after processing
How to get API Key?

Please visit API Portal to view your existing API key or request a new one.

Example

Thai Driver License Example (Front side)

Request:

curl -X POST https://api.iapp.co.th/thai-driver-license-ocr \
-H "apikey: YOUR_API_KEY" \
-F "file=@/path/to/driver_license.jpg"

Response:

{
"driving_license_type2": "Detected",
"driving_license_type6": "Detected",
"en_country": "Kingdom of Thailand",
"en_dob": "1 March 1987",
"en_expiry": "26 March 2024",
"en_issue": "18 May 2006",
"en_license_no": "00000000",
"en_name": "Mr. iApp Technology",
"en_type": "Private Car Driving License",
"face": "Detected",
"file_name": "thai-driver-license-ocr-example.png",
"flag": "Detected",
"id_no": "1111111111111",
"inference": "0.523",
"message": "Success",
"registrar": "นายทะเบียนจังหวัด กรุงเทพมหานคร Bangkok",
"sign": "Detected",
"status_code": 200,
"text_is_white": "Detected",
"th_country": "ประเทศไทย",
"th_dob": "1 มีนาคม 2530",
"th_expiry": "26 มีนาคม 2567",
"th_issue": "1 มกราคม 2562",
"th_license_no": "000000000",
"th_name": "นาย ไอแอพพ์ เทคโนโลยี",
"th_type": "ใบอนุญาติขับรถยนต์ส่วนบุคคล"
}

Features & Capabilities

Core Features

  • High accuracy text extraction (95.14% character-level accuracy)
  • Fast processing time (1-2 seconds per card)
  • Support for multiple file formats (JPEG, JPG, PNG)
  • Automatic card detection
  • Optional face photo extraction in base64 format
  • Support for both Thai and English text extraction

Supported Fields

FieldTypeDescription
en_countryStringCountry name in English
en_expiryStringExpiry date in English
en_issueStringIssue date in English
en_nameStringFull name in English
en_license_noStringLicense number in English
en_typeStringLicense type in English
faceStringFace detection status
id_noStringID card number
th_countryStringCountry name in Thai
th_expiryStringExpiry date in Thai
th_issueStringIssue date in Thai
th_nameStringFull name in Thai
th_license_noStringLicense number in Thai
th_typeStringLicense type in Thai
registrarStringRegistrar information

API Reference

Recognizing Thai Driver License

This endpoint processes Thai driver license images and returns the extracted data in a structured format.

POST https://api.iapp.co.th/thai-driver-license-ocr

Request Headers

NameTypeRequiredDescription
apikeystringYesYour API key

Request Body (multipart/form-data)

ParameterTypeRequiredDescription
fileFileYesThe binary data of the driver license image
fieldsStringNoOptional fields (e.g., "photo" for face photo)

Code Examples

Python

import requests

url = "https://api.iapp.co.th/thai-driver-license-ocr"

payload = {
'fields': 'photo'
}

files = [
('file',('driver_license.jpg',open('path/to/driver_license.jpg','rb'),'image/jpeg'))
]

headers = {
'apikey': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.json())

JavaScript

const axios = require("axios")
const FormData = require("form-data")
const fs = require("fs")

const form = new FormData()
form.append("file", fs.createReadStream("path/to/driver_license.jpg"))
form.append("fields", "photo")

const config = {
method: "post",
url: "https://api.iapp.co.th/thai-driver-license-ocr",
headers: {
apikey: "YOUR_API_KEY",
...form.getHeaders(),
},
data: form,
}

axios(config)
.then((response) => console.log(JSON.stringify(response.data)))
.catch((error) => console.log(error))

PHP

<?php
$curl = curl_init();

$post_data = array(
'file'=> new CURLFile('path/to/driver_license.jpg'),
'fields' => 'photo'
);

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.iapp.co.th/thai-driver-license-ocr',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_HTTPHEADER => array(
'apikey: YOUR_API_KEY'
),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>

Swift

import Foundation

let headers = [
"apikey": "YOUR_API_KEY"
]

let parameters = [
[
"name": "file",
"fileName": "path/to/driver_license.jpg"
],
[
"name": "fields",
"value": "photo"
]
]

let boundary = "Boundary-\(UUID().uuidString)"
var body = ""
var error: Error? = nil

for param in parameters {
if let fileName = param["fileName"] {
let fileContent = try? String(contentsOfFile: fileName, encoding: .utf8)
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(param["name"] ?? "")\""
body += "; filename=\"\(fileName)\"\r\n"
body += "Content-Type: image/jpeg\r\n\r\n"
body += fileContent ?? ""
} else {
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(param["name"] ?? "")\"\r\n\r\n"
body += param["value"] ?? ""
}
}

let postData = body.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://api.iapp.co.th/thai-driver-license-ocr")!,timeoutInterval: Double.infinity)
request.addValue("YOUR_API_KEY", forHTTPHeaderField: "apikey")
request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}

task.resume()

Kotlin

import okhttp3.*
import java.io.File

val client = OkHttpClient()

val mediaType = MediaType.parse("image/jpeg")
val file = File("path/to/driver_license.jpg")
val body = MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file", file.name, RequestBody.create(mediaType, file))
.addFormDataPart("fields", "photo")
.build()

val request = Request.Builder()
.url("https://api.iapp.co.th/thai-driver-license-ocr")
.addHeader("apikey", "YOUR_API_KEY")
.post(body)
.build()

client.newCall(request).execute().use { response ->
println(response.body()?.string())
}

Java

import java.io.File;
import okhttp3.*;

public class Main {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient().newBuilder().build();

MediaType mediaType = MediaType.parse("image/jpeg");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file", "driver_license.jpg",
RequestBody.create(mediaType, new File("path/to/driver_license.jpg")))
.addFormDataPart("fields", "photo")
.build();

Request request = new Request.Builder()
.url("https://api.iapp.co.th/thai-driver-license-ocr")
.method("POST", body)
.addHeader("apikey", "YOUR_API_KEY")
.build();

try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
} catch(Exception e) {
e.printStackTrace();
}
}
}

Dart

import 'package:http/http.dart' as http;

void main() async {
var request = http.MultipartRequest('POST',
Uri.parse('https://api.iapp.co.th/thai-driver-license-ocr'));

request.files.add(await http.MultipartFile.fromPath(
'file', 'path/to/driver_license.jpg'));

request.fields['fields'] = 'photo';

request.headers.addAll({
'apikey': 'YOUR_API_KEY'
});

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
} else {
print(response.reasonPhrase);
}
}

Limitations and Best Practices

Limitations

  • Maximum file size: 10MB
  • Supported formats: JPEG, JPG, PNG
  • Front side only

Best Practices

  1. Ensure good image quality
  2. Check inference score in response
  3. Handle error messages appropriately
  4. Validate license number format
  5. Consider using fields parameter for specific needs

Accuracy & Performance

Overall Accuracy

  • Character-level accuracy: 95.14%
  • Field-specific accuracies:
    • Face detection: 100%
    • License number: 97.37%
    • English name: 99.13%
    • Thai name: 95.62%

Processing Speed

  • Average: 1-2 seconds
  • May vary based on image size and quality

Factors Affecting Accuracy

  1. Image Quality
    • Resolution
    • Lighting
    • Focus
  2. Card Condition
    • Physical damage
    • Reflections
    • Text clarity

History

VersionRelease DateAccuracyKey Improvements
1.1Jan 202395.14%Added face photo extraction, Increased accuracy
1.0Dec 202290%Initial Release

Pricing

AI API Service NameEndpointIC Per RequestOn-Premise
Thai Driver License Card OCR [v1.1]iapp_thai_driver_license_ocr1.25 IC/RequestContact