Skip to main content

🪪 ID Card Auto-Capture

The SDK automates the entire Thai National ID card photo workflow: it detects the card boundary in the live camera feed, waits for a sharp and stable frame, perspective-corrects the crop, and submits it to the Thai National ID Card OCR API1.25 IC per front page, 0.75 IC per back page. No manual framing, no blurry retakes.

Flutter

import 'package:iapp_ekyc_sdk/iapp_ekyc_sdk.dart';

final client = IappEkycClient(apiKey: 'YOUR_API_KEY');

// Front side
final front = await DocumentCaptureView.start(
context,
client: client,
documentType: DocumentType.thaiIdFront,
locale: EkycLocale.th,
);

// Back side (laser code)
final back = await DocumentCaptureView.start(
context,
client: client,
documentType: DocumentType.thaiIdBack,
);

Web

import { IappEkyc } from '@iapp-technology/ekyc-sdk';

const ekyc = new IappEkyc({ apiKey: 'YOUR_API_KEY' });

const front = await ekyc.captureDocument({
mount: document.getElementById('ekyc-mount'),
documentType: 'thaiIdFront',
locale: 'th',
});

const back = await ekyc.captureDocument({
mount: document.getElementById('ekyc-mount'),
documentType: 'thaiIdBack',
});

The result exposes typed accessors plus the raw OCR response (result.raw) — see the Thai National ID Card OCR field reference.

How auto-capture works

  • Boundary detection — adaptive Canny edge detection and contour analysis (OpenCV) find a convex quadrilateral matching the ID-1 card aspect ratio (1.586, i.e. 85.60 × 53.98 mm, ±0.25 tolerance) inside the on-screen guide.
  • Stability — capture only triggers after the card has been steady across a sliding window of recent frames (corner drift under 2% of the frame diagonal).
  • Sharpness — Laplacian-variance scoring rejects blurry frames before any credit is spent.
  • Perspective correction — the detected corners are warped to a flat ~300 DPI card image (1011 × 637 px) before upload, which measurably improves OCR accuracy.
  • Manual fallback — a manual shutter button appears after 10 seconds if auto-capture has not fired.

Learn more