身份证自动采集
SDK 在实时摄像头画面中找到泰国国民身份证,拍下清晰并经透视校正的图像,提交给泰国身份证 OCR API:正面 1.25 IC,背面 0.75 IC。
调用
- Flutter
- Web
- iOS
- Android
- React Native
import 'package:iapp_ekyc_sdk/iapp_ekyc_sdk.dart';
final client = IappEkycClient(apiKey: 'YOUR_API_KEY');
// 正面
final front = await DocumentCaptureView.start(
context,
client: client,
documentType: DocumentType.thaiIdFront,
locale: EkycLocale.th,
);
// 背面(激光码)
final back = await DocumentCaptureView.start(
context,
client: client,
documentType: DocumentType.thaiIdBack,
);
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',
});
// iOS (Swift; 也支持 Objective-C)
let config = IappEkycConfig(apiKey: "YOUR_API_KEY", flow: .documentCapture)
config.documentType = .thaiIdFront
IappEkycSdk.present(from: self, config: config) { result in /* result.document?.rawJSON */ }
// Android (Kotlin; 也支持 Java)
ekyc.launch(IappEkycRequest.DocumentCapture(config, EkycDocumentType.THAI_ID_FRONT))
// React Native
<IappEkycFlow flow="documentCapture" documentType="thaiIdFront" apiKey="YOUR_API_KEY"
onResult={handleResult} onError={handleError} onCancel={close} />
安装:Flutter 与 Web 见入门指南,原生封装与相机权限见 iOS, Android & React Native。
选项
documentType:正面为thaiIdFront,带激光码的背面为thaiIdBack(Flutter 中为DocumentType.thaiIdFront)。locale:界面语言,en、th或zh(Flutter 中为EkycLocale.th)。
结果
结果包含类型化字段,以及 result.raw 中的原始 OCR 响应(iOS 上为 result.document?.rawJSON)。字段列表见泰国身份证 OCR API。
自动采集如何工作
- 边界:在屏幕引导框内寻找宽高比符合 ID-1 卡片 1.586(85.60 × 53.98 毫米)的四边形,容差 ±0.25。
- 稳定:卡片须在最近多帧中保持稳定,角点漂移小于画面对角线的 2%。
- 清晰度:模糊帧会在消耗任何额度之前被剔除。
- 透视校正:上传前将角点拉平为约 300 DPI 的平整卡片图像(1011 × 637 像素)。
- 手动拍摄:若 10 秒后仍未自动拍摄,会出现手动快门按钮。
完整的算法规范见 SDK 源代码。