护照自动采集
SDK 在实时摄像头画面中找到护照数据页(带照片和机读区 MRZ 的一页),拍下清晰并经透视校正的图像,提交给护照 OCR API:每页 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 result = await DocumentCaptureView.start(
context,
client: client,
documentType: DocumentType.passport,
locale: EkycLocale.en,
);
import { IappEkyc } from '@iapp-technology/ekyc-sdk';
const ekyc = new IappEkyc({ apiKey: 'YOUR_API_KEY' });
const result = await ekyc.captureDocument({
mount: document.getElementById('ekyc-mount'),
documentType: 'passport',
locale: 'en',
});
// iOS (Swift;也支持 Objective-C)
let config = IappEkycConfig(apiKey: "YOUR_API_KEY", flow: .documentCapture)
config.documentType = .passport
IappEkycSdk.present(from: self, config: config) { result in /* result.document?.rawJSON */ }
// Android (Kotlin;也支持 Java)
ekyc.launch(IappEkycRequest.DocumentCapture(config, EkycDocumentType.PASSPORT))
// React Native
<IappEkycFlow flow="documentCapture" documentType="passport" apiKey="YOUR_API_KEY"
onResult={handleResult} onError={handleError} onCancel={close} />
安装:Flutter 与 Web 见入门指南,原生封装与相机权限见 iOS, Android & React Native。
选项
documentType:passport(Flutter 中为DocumentType.passport)。locale:界面语言,en、th或zh(Flutter 中为EkycLocale.en)。
结果
结果包含类型化字段,以及 result.raw 中的原始 OCR 响应(iOS 上为 result.document?.rawJSON),其中包含已解析的 MRZ 字段。字段列表见护照 OCR API。
自动采集如何工作
- 边界:在屏幕引导框内寻找宽高比符合 ID-3 护照数据页 1.42(125 × 88 毫米)的四边形,容差 ±0.25。
- 稳定:页面须在最近多帧中保持稳定,角点漂移小于画面对角线的 2%。
- 清晰度:模糊帧会在消耗任何额度之前被剔除,使细小的 MRZ 字符不受运动模糊影响。
- 透视校正:上传前将角点拉平为约 300 DPI 的平整页面图像(1476 × 1039 像素)。
- 手动拍摄:若 10 秒后仍未自动拍摄,会出现手动快门按钮。
完整的算法规范见 SDK 源代码。