三证一卡

1. 三证一卡 SDK 说明文档

1.1 简介

三证一卡扫描SDK用于扫描是 身份证、银行卡、行驶证、驾驶证,并返回OCR识别结果。工作的原理为SDK从摄像头取得视频流,并分析每一帧图片是否清晰,是否为目标证件,如果是则抽取当前帧图片,发送到服务端返回OCR识别结果。

服务端接口介绍:

类型 接口
身份证 /ocr/idcard
银行卡 /ocr/bankcard
行驶证 /ocr/vehicle_license
驾驶证 /ocr/driving_license
VIN码 /ocr/vin

1.2 当前版本

最新版本是 v1.0.4,2020年9月25日更新。
支持armv7、arm64的两种CPU架构。
此版安装包增量为3.9M(两个架构)。
支持 iOS9.0 以上系统。

更新日志

日期 内容
2020年9月25日 修复已经bug
2020年9月25日 调整封装接口,返回是否是复印件
2020年9月24日 调整封装接口
2020年9月23日 发布V1.0.0版本,ipa增量3.9M(双架构)

2. 三证一卡 SDK 集成说明

2.1 注意事项

license文件(DFLicense)用以控制程序的包名和有效时间(时间范围可以直接查看文件内容获取),请用户一定要确认程序的包名是否与 license 绑定的包名一致,请确保程序运行设备的系统时间在 license 的有效时间内。

2.2 SDK目录结构

目录

2.3 将SDK集成到开发环境

2.3.1. 导入SDK包

使用SDK前,首先需要将其集成到您的开发环境中。 将libDFCardsDetector文件夹(包含 libCardsDetector.a、df_cards_detector.bundle、.h、.m等) copy 一份到项目工程目录下,拖拽到 xcode 打开的工程中,勾选 copy,点击 Finish 按钮。

注:本 SDK 不支持 CocoaPods 的方式导入。

示例介绍图

2.3.2 配置开发环境

2.3.2.1 需要手动关闭Bitcode。

步骤: TARGETS -> BuildSettings -> Enable Bitcode 设置为 NO。

示例介绍图

2.3.2.2 添加相关引用库。

步骤: TARGETS ->Build Phases中添加相关引用库 示例介绍图

2.3.2.3 调试iOS9以上系统时,调用相机功能时,在info.plist文件下添加隐私权限。
 <key>NSCameraUsageDescription</key>
 <string>cameraDesciption</string>
 <key> NSPhotoLibraryUsageDescription </key>
 <string>cameraDesciption</string>

2.4 开始检测(DFHomeController)

2.4.1遵守协议DFCaptureControllerDelegate并实现代理方法

初始化回调

- (void)initCompletedWithErrorCode:(int)errorCode
{
    [self showErrorAlertWithTitle:@"初始化失败" message:[NSString stringWithFormat:@"错误码: %d", errorCode]];
}

卡证检测完成回调(autoRecognize为NO时回调)

- (void)detectFinished:(UIImage *)image cardSideType:(DFCardDetectedSide)cardSideType isCopy:(BOOL)isCopy
{
    // 参考DFRecognizeController调用公有云接口,获取识别结果
}

卡证检测成功并自动上传识别成功回调(autoRecognize为YES时回调)

- (void)recognizeSucessfully:(UIImage *)image cardSideType:(DFCardDetectedSide)cardSideType isCopy:(BOOL)isCopy result:(nonnull NSDictionary *)result
{
    [self handleResult:image cardSideType:cardSideType isCopy:isCopy result:result];
}

卡证检测成功并自动上传识别失败回调(autoRecognize为YES时回调)

- (void)recognizeFailed:(UIImage *)image cardSideType:(DFCardDetectedSide)cardSideType isCopy:(BOOL)isCopy errorMessage:(nonnull NSString *)errorMessage
{
    DFResultViewController *resultVC = [[DFResultViewController alloc] init];
    resultVC.errorMessage = errorMessage;
    resultVC.isCopy = isCopy;
    resultVC.title = self.navigationController.title;
    [resultVC setResultImage:image];
    [self.navigationController pushViewController:resultVC animated:YES];
}

2.4.2 调起检测页面

身份证
- (IBAction)detectIDCard:(id)sender
{
    [self detectWithType:DFCardDetectedTypeIDCard];
}
银行卡
- (IBAction)detectBankCard:(id)sender
{
    [self detectWithType:DFCardDetectedTypeBankCard];
}
驾驶证
- (IBAction)detectDrivingLicense:(id)sender
{
    [self detectWithType:DFCardDetectedTypeDrivingLicense];
}
行驶证
- (IBAction)detectVehileLicense:(id)sender
{
    [self detectWithType:DFCardDetectedTypeVehicleLicense];
}
自动检测卡证类型
- (IBAction)detectCards:(id)sender
{
    [self detectWithType:DFCardDetectedTypeAutoCard];
}

2.4.3 push检测页面

  • filterCopy:是否过滤复印件
  • autoRecognize:是否自动上传检测到的卡证图片获取识别结果
- (void)detectWithType:(DFCardDetectedType)type
{
    self.detectType = type;
    [DFCaptureController pushCaptureControllerWithCardType:type filterCopy:NO delegate:self autoRecognize:YES navigationController:self.navigationController];
}

results matching ""

    No results matching ""