Acuant iOS Mobile SDK v5.9.3
2019年11月
==================
介绍
Acuant Web Services 支持从驾照、州身份证、其他政府发行的身份证、定制身份证、驾照、条形码、护照和医疗保险卡中提取数据。它还支持文档验证和面部识别来验证和认证身份。
Acuant Mobile SDK 框架是一个 Cocoa 框架。CocoaPods 是 Objective-C 的依赖管理器,它自动化并简化了在项目中使用类似 Acuant Mobile SDK 的第三方库的过程。请参阅使用 CocoaPods 安装 SDK。
本文件包含对开发者需要与 Acuant iOS Mobile SDK 集成的所有功能的详细描述。Acuant iOS Mobile SDK 需要有效的许可证密钥。请联系[email protected]以获取许可证密钥。
注意 该框架不会修改应用的状态栏。
##操作系统和设备要求 Acuant iOS Mobile SDK API 支持以下操作系统和设备
操作系统: iOS 8.0 或更高版本
设备: iPhone 4S 或更高版本、iPad 3 或更高版本、iPad mini、iPod Touch 5G 或更高版本
注意 扫描卡片的图像必须在可接受的光照条件下进行,以避免眩光和天花板灯光。卡片应尽量适应相机屏幕上的夹具,以便能够以最大分辨率拍照。
Cocoapods 部署 SDK
本节介绍如何使用 Cocoapods 安装 Acuant iOS Mobile SDK。
注意 GitHub 最近更改了大型文件的版本。要从 GitHub 或 Cocoapods 仓库克隆大文件,请确保在构建机器上安装了 git-lfs。有关 git-lfs 的更多信息,请参阅 https://git-lfs.github.com/。在安装 git-lfs 后,克隆并更新我们的 SDK 仓库 仅限 此。
在克隆仓库后,运行以下命令以确保拉取所有文件
git lfs pull
常见 构建 错误
如果没有设置 git-lfs,GitHub 将不会下载大文件。因此,如果在构建 iOS 应用时出现以下构建错误,则意味着某些文件丢失。
ld: warning: ignoring file ../com.acuant.plugin.AcuantMobileSDK/AcuantMobileSDK.framework/AcuantMobileSDK, file was built for unsupported file format ( 0x76 0x65 0x72 0x73 0x69 0x6F 0x6E 0x20 0x68 0x74 0x74 0x70 0x73 0x3A 0x2F 0x2F ) which is not the architecture being linked (armv7): ../com.acuant.plugin.AcuantMobileSDK/AcuantMobileSDK.framework/AcuantMobileSDK
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_AcuantCardProcessRequestOptions", referenced from:
objc-class-ref in AcuantMobileSDK.o
"_OBJC_CLASS_$_AcuantMobileSDKController", referenced from:
objc-class-ref in AcuantMobileSDK.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
如果您在发布/导出应用程序时发生以下错误,则说明在 XCode 构建设置中未正确设置架构。您必须设置有效的 CPU 架构或使用 "lipo" 命令行工具删除不受支持的架构库。
lipo -remove i386 <Path to the file> -o <Output file path>
lipo -remove x86_64 <Path to the file> -o <Output file path>
创建 Podfile
-
创建一个包含以下行的 Podfile:
platform :ios, '8.0' pod 'PPpdf417', '~> 5.1.0' pod 'AcuantMobileSDK', '~> 5.9.3'
-
运行
pod install
添加 AcuantMobileSDK。
查看以下视频了解使用 COCOAPOD 的集成
在 Objective-C 桥接 文件 中添加 导入 (可选)
如果这是一个 Swift 项目,请将以下导入添加到 Objective-C 桥接文件中。 (Apple 参考: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html)
@protocol AcuantFacialCaptureDelegate;
@class AcuantMobileSDKController;
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "AcuantMobileSDK/AcuantCardProcessRequestOptions.h"
#import "AcuantMobileSDK/AcuantCardRegion.h"
#import "AcuantMobileSDK/AcuantCardResult.h"
#import "AcuantMobileSDK/AcuantCardType.h"
#import "AcuantMobileSDK/AcuantDeviceLocationTestResult.h"
#import "AcuantMobileSDK/AcuantDriversLicenseCard.h"
#import "AcuantMobileSDK/AcuantError.h"
#import "AcuantMobileSDK/AcuantFacialCaptureDelegate.h"
#import "AcuantMobileSDK/AcuantFacialData.h"
#import "AcuantMobileSDK/AcuantFacialRecognitionViewController.h"
#import "AcuantMobileSDK/AcuantMedicalInsuranceCard.h"
#import "AcuantMobileSDK/AcuantMobileSDKController.h"
#import "AcuantMobileSDK/AcuantPassaportCard.h"
添加AcuantMobileSDK.embeddedframework (可选)
如果您不使用CocoaPods,则需要将AcuantMobileSDK.embeddedframework添加到您的每个项目中。
- 从GitHub下载Acuant iOS移动SDK和embeddedframework https://github.com/Acuant/AcuantiOSMobileSDK。
- 将AcuantMobileSDK.embeddedframework文件夹拖入您的项目文件结构中。
添加本地框架和库
- 转到目标。
- 点击构建阶段。
- 展开与二进制链接的库。
- 点击Xcode工具图标(+)以添加以下框架和库。
框架
- CoreLocation.framework
库
- libc++.tdb
- libiconv.tdb
- libz.tdb
注意:对于低于7.0版本的Xcode,请使用.dylib。
- libc++.dylib
- libiconv.dylib
- libz.dylib
将Microblink捆绑和框架添加到项目中
-
从AcuantMobileSDK.embeddedframework/Resources下下载Microblink.bundle和Microblink.framework文件。
-
然后选择MicroBlink.framework作为嵌入的二进制文件。
在构建设置中更改目标
-
转到目标。
-
点击 构建设置。
-
更改以下目标
Set “C Language Dialect” with GNU99 Set “C++ Language Dialect” with Compiler Default Set “C++ Standard Library” with Compiler Default
-
更改以下标志
Add on “GCC_PREPROCESSOR_DEFINITIONS” = CVLIB_IMG_NOCODEC
与 Swift 集成
在将此 SDK 与 Swift 项目集成之前,您必须首先创建一个 Objective-C 桥接头,以便将这些文件暴露给 Swift。添加 Objective-C 文件后,Xcode 会提示您创建头文件。
与 Objective-C 集成
将以下导入头文件添加到您的 appDelegate 头文件中
#import <AcuantMobileSDK/AcuantMobileSDKController.h>
Objective-C 示例应用
Objective-C 示例应用 AcuantiOSMobileSampleSDK.xcodeproj 位于 Sample-Objective-C-App 文件夹中
注意: 您需要一个来自 Acuant 的许可证密钥来运行示例应用。联系 Acuant 技术支持以获取许可证密钥。
Swift 示例应用
Swift 示例应用位于 Sample-Swift-App 文件夹中
注意: 您需要一个来自 Acuant 的许可证密钥来运行示例应用。联系 Acuant 技术支持以获取许可证密钥。
AssureID Connect Objective-C 示例应用
AssureID Connect Objective-C 示例应用位于
注意: 您需要一个来自 Acuant 的许可证密钥来运行示例应用。联系 Acuant 技术支持以获取许可证密钥。
AssureID Connect Swift 示例应用
AssureID Connect Swift 示例应用位于
注意:要运行示例应用,您需要适当的 AssureID Connect 凭据。请联系 Acuant 获取凭据。
使用 AcuFill FRM 示例应用进行数据捕获
本示例应用演示了使用 AssureID Connect Web 服务进行数据捕获和面部匹配识别(FRM)。此示例应用位于
注意:要运行示例应用,您需要适当的 AssureID Connect 凭据和 AcuFill 许可证密钥。请联系 Acuant 获取凭据和许可证信息。
使用许可证密钥初始化并创建 SDK 实例
使用以下调用验证许可证密钥并创建 SDK 实例
//Obtain the main controller instance
_instance = [AcuantMobileSDKController initAcuantMobileSDKWithLicenseKey:@"MyLicensekey"
andDelegate:self];
注意 此方法验证许可证密钥是否有效,并返回一个实例,可用来引用方法。Acuant 建议您为每个会话 创建一个实例 以优化资源。
使用许可证密钥和云地址初始化和创建SDK实例
在以下调用中,验证许可证密钥并创建实例(如果您在自己的数据中心托管Acuant Web服务,则需指定云地址)。默认情况下,iOS MobileSDK与Acuant数据中心通信。
//Obtain the main controller instance
_instance = [AcuantMobileSDKController
initAcuantMobileSDKWithLicenseKey:@"MyLicensekey" delegate:self
andCloudAddress:@"cloud.myAddress.com"];
注意 不要将“https://”作为云地址的一部分。正确的格式是:cloud.myAddress.com
注意: 此方法验证许可证密钥是否有效,并返回一个可用于引用方法的实例。Acuant建议您为优化资源,请在每个会话中创建一个实例。
如果已创建实例,则使用此调用
//Obtain the main controller instance
_instance = [AcuantMobileSDKController initAcuantMobileSDK];
检查许可证密钥验证是否成功
为了验证许可证密钥验证是否完成或是否成功,请在创建MobileSDK实例后调用以下方法
-(void)mobileSDKWasValidated:(BOOL)wasValidated{
_wasValidated = wasValidated;
}
检查SDK控制器验证
要检查是否已使用许可证密钥验证了SDK控制器,请调用以下方法
BOOL validated = [_instance isSDKValidated];
卡片捕获
根据卡片类型,选择手动捕获界面或条形码捕获界面以显示相机界面。以下列表描述了每种卡片类型支持的捕获方法。
- AcuantCardTypeMedicalInsuranceCard -- 仅手动
- AcuantCardTypePassportCard -- 仅手动
- AcuantCardTypeDriversLicenseCard -- 仅手动或条形码(根据区域)
- 美国和加拿大 -- 正面仅手动;背面条形码或手动
- 美洲、欧洲、亚洲、澳大利亚和非洲 -- 前后面板手册
- AcuantCardTypeAuto -- 如果设置了 AcuantCardTypeAuto,则在 didCaptureCropImage 的最后一个参数将包含自动检测到的卡片类型。如果设置了类似于 AcuantCardTypeDriversLicenseCard 的卡片类型,而检测到的是不同类型的卡片,例如 AcuantCardTypePassportCard,则会出现 AcuantErrorIncorrectDocumentScanned 错误。
为卡片捕获接口配置 SDK
-
将以下导入添加到头文件
#import <AcuantMobileSDK/AcuantMobileSDKController.h>
-
在同一头文件中,实现 AcuantMobileSDKControllerCapturingDelegate
@interface ISGViewController ()<AcuantMobileSDKControllerCapturingDelegate, AcuantMobileSDKControllerProcessingDelegate>
卡片捕获接口方法
使用以下方法之一捕获卡片图像。
####初始化 SDK 并显示相机界面
使用以下方法初始化 SDK 并在相同步骤中显示相机界面
[AcuantMobileSDKController initAcuantMobileSDKWithLicenseKey:licenseKey
AndShowCardCaptureInterfaceInViewController:self delegate:self
typeCard:_cardType region:_region isBarcodeSide:_isBarcodeSide];
注意 在使用任何自定义方法之前,您应该创建 SDK 的先前的实例,以便设置相机自定义。
示例
_instance = [AcuantMobileSDKController initAcuantMobileSDK];
[_instance setWidth:1250];
[AcuantMobileSDKController initAcuantMobileSDKWithLicenseKey:licenseKey
AndShowCardCaptureInterfaceInViewController:self
delegate:self
typeCard:_cardType region:_region isBarcodeSide:_isBarcodeSide];
不初始化 SDK 即使用手动卡片捕获接口
在已经初始化 SDK 后调用此函数。首先创建 SDK 的实例以调用函数(参见 AcuantMobileSDKController 实例示例)。
[_instance showManualCameraInterfaceInViewController:self delegate:self
cardType:_cardType region:_region andBackSide:YES];
不初始化 SDK 即使用条码捕获接口
在已经初始化 SDK 后调用此函数。首先创建 SDK 的实例以调用函数(参见 AcuantMobileSDKController 实例示例)。
[_instance showBarcodeCameraInterfaceInViewController:self delegate:self
cardType:_cardType region:_region];
指定卡片大小
如果未设置正确的卡片大小,MobileSDK 将无法处理卡片。
指定驾照卡片大小
-(void)showCameraInterface{
if(_instance.isAssureIDAllowed){ //If AssureId is enabled
[_instance setWidth:2024];
}else{
[_instance setWidth:1250]; //If AssureId is not enabled
}
}
指定医疗保舰卡卡片大小
-(void)showCameraInterface{
[_instance setWidth:1500];
}
指定护照文档卡片大小
-(void)showCameraInterface{
[_instance setWidth:1478];
}
自定义相机屏幕上的显示和信息
默认初始化信息为:“对齐并点击” 或 “点击对焦”。您可以为您想报酬证正面、驾驶证背图、医疗保舰和护照自定义此消息。
[_instance setInitialMessage:@"Initial Message" frame:CGRectMake(0, 0, 0, 0)
backgroundColor:[UIColor blueColor] duration:5.0
orientation:AcuantHUDLandscape];
默认捕捉信息为:“保持稳定”。您可以为您想报酬证正面和医疗保舰卡自定义此消息。
[_instance setCapturingMessage:@"Capturing Message"
frame:CGRectMake(0,0,0, 0) backgroundColor:[UIColor blueColor] duration:5.0
orientation:AcuantHUDLandscape];
截图的可选方法
以下是一些可选方法,您可以使用这些方法启用裁剪(默认情况下禁用)。
裁剪条码图像
使用 setCanCropBarcode 方法来启用裁剪条码图像
[_instance setCanCropBarcode:YES];
使用 canCropBarcodeOnBackPressed 方法来在超时或取消时启用裁剪条码图像
- (BOOL)canCropBarcodeOnBackPressed{
return NO;
}
注意事项 裁剪后的条码图像将通过 didCaptureImage 代理方法接收。
启用条码相机界面上显示的初始消息
使用可选方法 setCanShowMessage 来启用在条码相机界面上显示的初始消息(默认情况下禁用)。
[_instance setCanShowMessage:YES];
####启用暂停条码相机扫描:使用可选方法 pauseScanningBarcodeCamera 来暂停条码相机扫描。
[_instance pauseScanningBarcodeCamera];
####启用恢复条码相机扫描:使用可选方法 resumeScanningBarcodeCamera 来恢复条码相机扫描。
[_instance resumeScanningBarcodeCamera];
###启用不带用户预览连续扫描条形码:使用以下可选方法在不带用户预览的情况下启动或停止连续扫描。
// To Start Barcode scanning :
- (void)startContinousBarcodeCaptureWithDelegate:(UIViewController<AcuantMobileSDKControllerCapturingDelegate>*)
delegate;
// To stop scanning :
-(void)StopContinousBarcodeCapture;
###点击捕获二维码
默认情况下,当条码出现在相机前时,条码会自动捕获。如果需要在用户点击屏幕后捕获条码,则可以进行以下配置。
-(BOOL)startScanningBarcodeAfterTap{
return YES; // Default is NO
}
使用 AcuantMobileSDKControllerCapturingDelegate 协议
本节描述了 AcuantMobileSDKControllerCapturingDelegate 协议使用的方 法。
###didCaptureCropImage 方法###
使用 didCaptureCropImage 方法来配置图像裁剪。
注意事项 所有卡片捕获界面 必须 使用此方法。
-(void)didCaptureCropImage:(UIImage **)cardImage scanBackSide:(BOOL)scanBackSide andCardType:(AcuantCardType)cardType withImageMetrics:(NSDictionary )imageMetrics
{
_isCameraTouched = NO;
[_instance dismissCardCaptureInterface];
_isBarcodeSide = scanBackSide;
switch (_sideTouch) {
case FrontSide:
[_frontImage setImage:cardImage];
break;
case BackSide:
[_backImage setImage:cardImage];
[_frontImageLabel setText:@""];
[_backImageLabel setText:@""];
[self cardHolderPositions];
_frontImage.layer.masksToBounds = YES;
_frontImage.layer.cornerRadius = 10.0f;
_frontImage.layer.borderWidth = 1.0f;
_backImage.layer.masksToBounds = YES;
_backImage.layer.cornerRadius = 10.0f;
_backImage.layer.borderWidth = 1.0f;
[_backImage setUserInteractionEnabled:YES];
break;
default:
break;
}
[_sendRequestButton setEnabled:YES];
[_sendRequestButton setHidden:NO];
if (scanBackSide) {
_sideTouch = BackSide;
[UIAlertController showSimpleAlertWithTitle:@"AcuantiOSMobileSDKSample"
Message:@"Scan the backside of the license."
FirstButton:ButtonOK
SecondButton:nil
FirstHandler:^(UIAlertAction *action) {
_sideTouch = BackSide;
_isCameraTouched = YES;
[self showCameraInterface];
}
SecondHandler:nil
Tag:1
ViewController:self];
}
}
参数 ImageMetrics指定了裁剪图像的清晰度和眩光阈值。清晰度等级为 0.4f 或以上被认为是清晰图像。一般来说,GLARE_GRADE 级别为 1 表示没有眩光,0 表示有可能在捕获的图像中有眩光。用户可以根据需求设置阈值
BOOL isSharp = [[imageMetrics objectForKey:@"IS_SHARP"] boolValue];
float sharpnessGrade = [[imageMetrics objectForKey:@"SHARPNESS_GRADE"] floatValue];
BOOL hasGlare = [[_imageMetrics objectForKey:@"HAS_GLARE"] boolValue]
float glareGrade = [[_imageMetrics objectForKey:@"GLARE_GRADE"] floatValue];
注意事项 对于 AcuantCardTypeMedicalInsuranceCard,捕获背面是可选的,但对于 AcuantCardTypeDriverLicenseCard,捕获背面是必需的。
didCaptureOriginalImage 方法
使用 didCaptureOriginalImage 方法检索由卡片捕获接口捕获的原始图像。
-(void)didCaptureOriginalImage:(UIImage *)cardImage{
_originalImage = cardImage;
}
didCaptureData 代理方法
使用 didCaptureData 方法检索 AcuantCardTypeDriverLicenseCard 的条形码捕获接口捕获的条形码字符串。
-(void) didCaptureData:(NSString *)data{
self.barcodeString = data;
}
didCaptureCropImage:andData:scanBackSide: 代理方法
使用 didCaptureCropImage 方法检索 AcuantCardTypeDriverLicenseCard 的条形码捕获接口捕获的条形码字符串和背面图像。
-(void)didCaptureCropImage:(UIImage *)cardImage andData:(NSString *)data
scanBackSide:(BOOL)scanBackSide{
}
注意
- 只有当 canCropBarcode 设置为 (例如,
[self.instance setCanCropBarcode:YES];
) 时,才会调用此代理。 - 不要实现两个代理,即 didCaptureData 和 didCaptureCropImage:andData:scanBackSide。
didFailWithError 代理方法
为了通知扫描或处理失败,您必须使用以下方法
-(void)didFailWithError:(AcuantError *)error{
NSString *message;
switch (error.errorType) {
case AcuantErrorTimedOut:
message = error.errorMessage;
break;
case AcuantErrorUnknown:
message = error.errorMessage;
break;
case AcuantErrorUnableToProcess:
message = error.errorMessage;
break;
case AcuantErrorInternalServerError:
message = error.errorMessage;
break;
case AcuantErrorCouldNotReachServer:
if (_isCameraTouched) {
showAlert = NO;
}
message = error.errorMessage;
break;
case AcuantErrorUnableToAuthenticate:
message = error.errorMessage;
break;
case AcuantErrorAutoDetectState:
message = error.errorMessage;
break;
case AcuantErrorWebResponse:
message = error.errorMessage;
break;
case AcuantErrorUnableToCrop:
message = error.errorMessage;
break;
case AcuantErrorInvalidLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorInactiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorAccountDisabled:
message = error.errorMessage;
break;
case AcuantErrorOnActiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorValidatingLicensekey:
message = error.errorMessage;
break;
case AcuantErrorCameraUnauthorized:
message = error.errorMessage;
break;
default:
break;
}
if (showAlert) {
[UIAlertController showSimpleAlertWithTitle:@"AcuantiOSMobileSDK"
Message:message
FirstButton:ButtonOK
SecondButton:nil
FirstHandler:^(UIAlertAction *action) {
if (tag == 1) {
_sideTouch = BackSide;
_isCameraTouched = YES;
[self showCameraInterface];
}else if(tag == 7388467) {
[[UIApplication sharedApplication] openURL:[NSURL
URLWithString:UIApplicationOpenSettingsURLString]];
}
}
SecondHandler:nil
Tag:tag
ViewController:self];
}
}
可选代理方法
didTakeCardPhoto 方法
使用 didTakeCardPhoto 方法通知代理图像捕获过程开始了。
-(void)didTakeCardPhoto{
NSLog(@"didTakeCardPhoto");
//Custom code here.
}
barcodeScanTimeOut 方法
使用 barcodeScanTimeOut 方法通知代理条码扫描超时
-(void)barcodeScanTimeOut:(UIImage*)croppedImage withImageMetrics:(NSDictionary *)imageMetrics andOriginalImage:(UIImage *)originalImage
}
参数 ImageMetrics指定了裁剪图像的清晰度和眩光阈值。清晰度等级为 0.4f 或以上被认为是清晰图像。一般来说,GLARE_GRADE 级别为 1 表示没有眩光,0 表示有可能在捕获的图像中有眩光。用户可以根据需求设置阈值
BOOL isSharp = [[imageMetrics objectForKey:@"IS_SHARP"] boolValue];
float sharpnessGrade = [[imageMetrics objectForKey:@"SHARPNESS_GRADE"] floatValue];
BOOL hasGlare = [[_imageMetrics objectForKey:@"HAS_GLARE"] boolValue]
float glareGrade = [[_imageMetrics objectForKey:@"GLARE_GRADE"] floatValue];
didCancelToCaptureData 方法
使用 didCancelToCaptureData 方法通知代理条码屏幕已被取消:**注意**对于包含图片的参数,代理必须实现 -(BOOL)canCropBarcodeOnBackPressed 方法,并必须返回 **是**。
-(void)didCancelToCaptureData:(UIImage*)croppedImage withImageMetrics:(NSDictionary *)imageMetrics andOriginalImage:(UIImage *)originalImage{
}
showiPadBrackets 方法
使用 showiPadBrackets 方法启用或禁用在卡捕获界面显示 iPad 括号
-(BOOL)showiPadBrackets{
return YES;
}
参数 ImageMetrics指定了裁剪图像的清晰度和眩光阈值。清晰度等级为 0.4f 或以上被认为是清晰图像。一般来说,GLARE_GRADE 级别为 1 表示没有眩光,0 表示有可能在捕获的图像中有眩光。用户可以根据需求设置阈值
BOOL isSharp = [[imageMetrics objectForKey:@"IS_SHARP"] boolValue];
float sharpnessGrade = [[imageMetrics objectForKey:@"SHARPNESS_GRADE"] floatValue];
BOOL hasGlare = [[_imageMetrics objectForKey:@"HAS_GLARE"] boolValue]
float glareGrade = [[_imageMetrics objectForKey:@"GLARE_GRADE"] floatValue];
didPressBackButton 方法
使用 didPressBackButton 方法通知代理用户按下了 返回 按钮
-(void)didPressBackButton{
[_instance dismissCardCaptureInterface];
}
imageForBackButton 方法
使用 imageForBackButton 方法设置卡捕获界面中显示的返回按钮图像
-(UIImage*)imageForBackButton{
UIImage *image = [UIImage imageNamed:@"BackButton.png"];
return image;
}
frameForBackButton 方法
使用 frameForBackButton 方法设置屏幕中返回按钮的位置
-(CGRect)frameForBackButton{
return CGRectZero;
}
showBackButton 方法
使用 showBackButton 方法启用或禁用在卡片捕获界面显示返回按钮
-(BOOL)showBackButton{
return YES;
}
cameraPrefersStatusBarHidden 方法
使用 cameraPrefersStatusBarHidden 方法控制当此视图控制器显示时状态栏的属性
-(BOOL)cameraPrefersStatusBarHidden{
return YES;
}
showFlashlightButton 方法
使用 showFlashlightButton 方法启用或禁用在卡片捕获界面显示手电筒按钮
-(BOOL)showFlashlightButton{
return YES;
}
frameForFlashlightButton 方法
使用 frameForFlashlightButton 方法设置屏幕中手电筒按钮的位置:调用设置屏幕中手电筒按钮位置的函数
-(CGRect)frameForFlashlightButton{
return CGRectZero;
}
imageForFlashlightButton 方法
使用 imageForFlashlightButton 方法设置当打开相机闪光灯时,卡片捕获界面中显示的手电筒按钮的图片
-(UIImage*)imageForFlashlightButton{
UIImage *image = [UIImage imageNamed:@"FlashlightButton.png"];
return image;
}
为关闭手电筒按钮图像方法
使用 为关闭手电筒按钮图像方法 设置在关闭相机闪光灯时在卡片捕获界面显示的手电筒按钮图像
-(UIImage*)imageForFlashlightOffButton{
UIImage *image = [UIImage imageNamed:@"FlashlightOffButton.png"];
return image;
}
为帮助图像视图图像方法
使用 为帮助图像视图图像方法 设置在卡片捕获界面显示的帮助图像
-(UIImage*)imageForHelpImageView{
UIImage *image = [UIImage imageNamed:@"PDF417"];
return [image imageByApplyingAlpha:0.7];
}
为帮助图像视图框架方法
使用 为帮助图像视图框架方法 设置在屏幕上的帮助图像位置
-(CGRect)frameForHelpImageView{
UIImage *image = [UIImage imageNamed:@"PDF417"];
CGRect frame = CGRectMake(self.view.frame.size.width/2 -
image.size.width/2, self.view.> frame.size.height/2 -
image.size.height/3 , image.size.width, image.size.height);
return frame;
}
为水印标签字符串方法
使用 为水印标签字符串方法 设置在卡片捕获界面显示的水印消息
-(NSString*)stringForWatermarkLabel{
NSString *string = @"Powered by Acuant";
return string;
}
为水印图像视图框架方法
使用 为水印图像视图框架方法 设置水印标签在屏幕上的位置
-(CGRect)frameForWatermarkImageView{
UIImage *image = [UIImage imageNamed:@"Logo.png"];
CGRect frame = CGRectMake(self.view.frame.size.width/2-
image.size.width/2, self.view.> frame.size.height/2 -
image.size.height/2 + 20 , image.size.width, image.size.height);
return frame;
}
为条码错误消息方向方法
使用 orientationForBarcodeErrorMessage 方法设置在条码捕获界面中显示的条码错误信息的方向
-(UIDeviceOrientation)orientationForBarcodeErrorMessage{
return UIDeviceOrientationPortrait;
}
stringForBarcodeErrorMessage 方法
使用 stringForBarcodeErrorMessage 方法设置在条码捕获界面中显示的条码错误信息
-(NSString *)stringForBarcodeErrorMessage{
NSString *string = @"Unable to scan the barcode?";
return string;
}
stringForBarcodeTitleError 方法
使用 stringForBarcodeTitleError 方法设置在条码捕获界面中显示的条码标题错误
-(NSString *)stringForBarcodeTitleError{
NSString *string = @"Title Sample";
return string;
}
timeForBarcodeErrorMessage 方法
使用 timeForBarcodeErrorMessage 方法设置在条码捕获界面中显示错误信息的持续时间
-(NSString *)stringForBarcodeFirstButton{
NSString *string = @"Yes";
return string;
}
stringForBarcodeSecondButton 方法
使用 stringForBarcodeSecondButton 方法设置在条码警告中显示的第二个按钮的条码按钮文本
-(NSString *)stringForBarcodeSecondButton{
NSString *string = @"Try Again";
return string;
}
卡片处理
本节描述了卡捕获界面的SDK配置和卡处理方法。
SDK配置
按照以下步骤配置卡捕获界面。
-
将在进行解析的头部文件中添加以下导入
#import <AcuantMobileSDK/AcuantMobileSDKController.h>
-
在同一个头文件中,实现 AcuantMobileSDKControllerProcessingDelegate。
@interface ISGViewController () <AcuantMobileSDKControllerCapturingDelegate, **AcuantMobileSDKControllerProcessingDelegate**>
配置SDK以使用卡片捕获接口。
卡片处理方法
本节详细介绍了驾照、医疗保险卡和护照的卡片处理方法。
驾照卡片处理
使用以下值来配置 AcuantCardTypeDriverLicenseCard 的卡片处理
-(IBAction)sendRequest:(id)sender {
self.view.userInteractionEnabled = NO;
[SVProgressHUD showWithStatus:@"Sending Request"];
//Obtain the front side of the card image
UIImage *frontSideImage = [self frontSideCardImage];
//Obtain the back side of the card image
UIImage *backSideImage =[self backSideCardImage];
//Obtain the default AcuantCardProcessRequestOptions object for the type of
card you want to process (Driver’s License card for this example)
AcuantCardProcessRequestOptions *options = [AcuantCardProcessRequestOptions
defaultRequestOptionsForCardType: AcuantCardTypeDriversLicenseCard];
//Optionally, configure the options to the desired value
options.autoDetectState = YES;
options.stateID = -1;
options.reformatImage = YES;
options.reformatImageColor = 0;
options.DPI = 150.0f;
options.cropImage = NO;
options.faceDetection = YES;
options.signatureDetection = YES;
options.region = _regionID;
// Now, perform the request
[_instance processFrontCardImage:frontSideImage
BackCardImage:backSideImage
andStringData:_barcodeString
withDelegate:self
withOptions:options];
}
###参数
####region 用于区域ID的整数参数。 值:美国 – 0 | 澳大利亚 – 4 | 亚洲 – 5 | 加拿大 – 1 | 美洲 – 2 | 欧洲 – 3 | 非洲 – 7 | 一般文件 – 6
####autoDetectState 表示是否自动检测身份证状态的布尔值。 值:True | False (SDK不会自动检测身份证状态,并使用ProcState整数的值)
####stateID 身份证所属州的整数值
- If **AutoDetectState** is True, then the SDK automatically detects the state of the ID and **stateID** value is ignored.
- If **AutoDetectState** is False, then the SDK uses the **stateID** integer value for processing.
**Note** For a complete list of the different countries supported by the SDK and their different State integer values, see the ScanW document: <http://www.id-reader.com/ftp/applications/sdk/docs/ScanW.pdf>
####faceDetection 表示是否返回人脸图像的布尔值。 值:True | False
####signatureDetection 表示是否返回签名图像的布尔值。 值:True | False
####reformatImage 表示是否返回格式化图像的布尔值。 值:True | False (忽略 ReformatImageColor 和 ReformatImageDpi 的值)
####reformatImageColor 指定用于重新格式化图像的颜色值的整数。 值:图像颜色相同 – 0 | 黑白 – 1 | 灰度256 – 2 | 彩色256 – 3 | 真彩色 – 4 | 增强图像 – 5
####DPI 表示用于重新格式化图像的DPI值的整数。 值:范围是150 - 600。图像的大小取决于DPI值。使用较低的值(150)以获得较小的图像。
####cropImage 表示是否裁剪原始图像的布尔值。 值:True | False
**Note:** MobileSDK crops the image; therefore, leave this flag set to **False**.
####logtransaction 表示是否将交易响应保存到Acuant云上以便将来检索,如果开启许可密钥的记录功能。 值:True | False
####imageSettings imageSettings 的默认值为 -1。除非Acuant技术支持指示,否则不要调整此值。
医疗保险卡卡片处理
使用以下值配置 AcuantCardTypeMedicalInsuranceCard 的卡片处理。
-(IBAction)sendRequest:(id)sender {
self.view.userInteractionEnabled = NO;
[SVProgressHUD showWithStatus:@"Sending Request"];
//Obtain the front side of the card image
UIImage *frontSideImage = [self frontSideCardImage];
//Optionally, Obtain the back side of the image
UIImage *backSideImage =[self backSideCardImage];
//Obtain the default AcuantCardProcessRequestOptions object for the type of card
you want to process (Medical Insurance card for this example)
AcuantCardProcessRequestOptions *options = [AcuantCardProcessRequestOptions
defaultRequestOptionsForCardType: AcuantCardTypeMedicalInsuranceCard];
//Optionally, configure the options to the desired value
options.reformatImage = YES;
options.reformatImageColor = 0;
options.DPI = 150.0f;
options.cropImage = NO;
// Now, perform the request
[_instance processFrontCardImage:frontSideImage
BackCardImage:backSideImage andStringData:nil withDelegate:self
withOptions:options];
}
###参数
####reformatImage 表示是否返回格式化图像的布尔值。 值:True | False (忽略 ReformatImageColor 和 ReformatImageDpi 的值)
####reformatImageColor 指定用于重新格式化图像的颜色值的整数。 值:图像颜色相同 – 0 | 黑白 – 1 | 灰度256 – 2 | 彩色256 – 3 | 真彩色 – 4 | 增强图像 – 5
####DPI 表示用于重新格式化图像的DPI值的整数。 值:范围是150 - 600。图像的大小取决于DPI值。使用较低的值(150)以获得较小的图像。
####cropImage 表示是否裁剪原始图像的布尔值。 值:True | False
**Note:** MobileSDK crops the image; therefore, leave this flag set to **False**.
护照卡片处理
使用以下值配置 AcuantCardTypePassportCard 的卡片处理。
-(IBAction)sendRequest:(id)sender {
self.view.userInteractionEnabled = NO;
[SVProgressHUD showWithStatus:@"Sending Request"];
//Obtain the front side of the card image
UIImage *frontSideImage = [self frontSideCardImage];
//Obtain the default AcuantCardProcessRequestOptions object for the type
of card you want to process (Passport card for this example)
AcuantCardProcessRequestOptions *options =
[AcuantCardProcessRequestOptions defaultRequestOptionsForCardType:
AcuantCardTypePasssportCard];
//Optionally, configure the options to the desired value
options.reformatImage = YES;
options.reformatImageColor = 0;
options.DPI = 150.0f;
options.cropImage = NO;
options.faceDetection = YES;
options.signatureDetection = YES;
// Now, perform the request
[_instance processFrontCardImage:frontSideImage BackCardImage:nil
andStringData:nil withDelegate:self withOptions:options];
}
###参数
####faceDetection 布尔值,指定是否返回人脸图像。 值: 真实 | 假
####signatureDetection 布尔值,指定是否返回签名图像。 值: 真实 | 假
####reformatImage 表示是否返回格式化图像的布尔值。 值:True | False (忽略 ReformatImageColor 和 ReformatImageDpi 的值)
####reformatImageColor 指定用于重新格式化图像的颜色值的整数。 值:图像颜色相同 – 0 | 黑白 – 1 | 灰度256 – 2 | 彩色256 – 3 | 真彩色 – 4 | 增强图像 – 5
####DPI 表示用于重新格式化图像的DPI值的整数。 值:范围是150 - 600。图像的大小取决于DPI值。使用较低的值(150)以获得较小的图像。
####cropImage 布尔值,指示是否裁剪原始图像。 值: 真实 | 假 注意: MobileSDK 会裁剪图像,因此请将此标志设置为 假。
使用 AcuantMobileSDKControllerProcessingDelegate 协议
本节描述了使用 AcuantMobileSDKControllerProcessingDelegate 协议处理驾驶证、医疗保险卡和护照的配置。
处理驾驶证卡
为 AcuantCardTypeDriversLicenseCard 添加以下代码
#pragma mark -
#pragma mark CardProcessing Delegate
-(void)didFinishProcessingCardWithResult:(AcuantCardResult *)result{
self.view.userInteractionEnabled = YES;
[SVProgressHUD dismiss];
NSString *message;
UIImage *faceimage;
UIImage *signatureImage;
UIImage *frontImage;
UIImage *backImage;
AcuantDriversLicenseCard *data = (AcuantDriversLicenseCard*)result;
message [NSString stringWithFormat:@"First Name - %@ \nMiddle Name - %@ \nLast Name - %@ \nName Suffix - %@ \nAuthentication Result - %@ \nAunthentication Summary - %@ \nID - %@ \nLicense - %@ \nDOB Long - %@ \nDOB Short - %@ \nDate Of Birth Local - %@ \nIssue Date Long - %@ \nIssue Date Short - %@ \nIssue Date Local - %@ \nExpiration Date Long - %@ \nExpiration Date Short - %@ \nEye Color - %@ \nHair Color - %@ \nHeight - %@ \nWeight - %@ \nAddress - %@ \nAddress 2 - %@ \nAddress 3 - %@ \nAddress 4 - %@ \nAddress 5 - %@ \nAddress 6 - %@ \nCity - %@ \nZip - %@ \nState - %@ \nCounty - %@ \nCountry Short - %@ \nCountry Long - %@ \nClass - %@ \nRestriction - %@ \nSex - %@ \nAudit - %@ \nEndorsements - %@ \nFee - %@ \nCSC - %@ \nSigNum - %@ \nText1 - %@ \nText2 - %@ \nText3 - %@ \nType - %@ \nDoc Type - %@ \nFather Name - %@ \nMother Name - %@ \nNameFirst_NonMRZ - %@ \nNameLast_NonMRZ - %@ \nNameLast1 - %@ \nNameLast2 - %@ \nNameMiddle_NonMRZ - %@ \nNameSuffix_NonMRZ - %@ \nDocument Detected Name - %@ \nDocument Detected Name Short - %@ \nNationality - %@ \nOriginal - %@ \nPlaceOfBirth - %@ \nPlaceOfIssue - %@ \nSocial Security - %@ \nIsAddressCorrected - %d \nIsAddressVerified - %d", data.nameFirst, data.nameMiddle, data.nameLast, data.nameSuffix,data.authenticationResult,[self arrayToString:data.authenticationResultSummaryList], data.licenceId, data.license, data.dateOfBirth4, data.dateOfBirth, data.dateOfBirthLocal, data.issueDate4, data.issueDate, data.issueDateLocal, data.expirationDate4, data.expirationDate, data.eyeColor, data.hairColor, data.height, data.weight, data.address, data.address2, data.address3, data.address4, data.address5, data.address6, data.city, data.zip, data.state, data.county, data.countryShort, data.idCountry, data.licenceClass, data.restriction, data.sex, data.audit, data.endorsements, data.fee, data.CSC, data.sigNum, data.text1, data.text2, data.text3, data.type, data.docType, data.fatherName, data.motherName, data.nameFirst_NonMRZ, data.nameLast_NonMRZ, data.nameLast1, data.nameLast2, data.nameMiddle_NonMRZ, data.nameSuffix_NonMRZ, data.documentDetectedName, data.documentDetectedNameShort, data.nationality, data.original, data.placeOfBirth, data.placeOfIssue, data.socialSecurity, data.isAddressCorrected, data.isAddressVerified];
if (_region == AcuantCardRegionUnitedStates || _region == AcuantCardRegionCanada) {
message = [NSString stringWithFormat:@"%@ \nIsBarcodeRead - %hhd \nIsIDVerified - %hhd \nIsOcrRead - %hhd", message, data.isBarcodeRead, data.isIDVerified, data.isOcrRead];
}
faceimage = [UIImage imageWithData:data.faceImage];
signatureImage = [UIImage imageWithData:data.signatureImage];
frontImage = [UIImage imageWithData:data.licenceImage];
backImage = [UIImage imageWithData:data.licenceImageTwo]
}
-(void)didFailWithError:(AcuantError *)error{
self.view.userInteractionEnabled = YES;
[SVProgressHUD dismiss];
NSString *message;
switch (error.errorType) {
case AcuantErrorTimedOut:
message = error.errorMessage;
break;
case AcuantErrorUnknown:
message = error.errorMessage;
break;
case AcuantErrorUnableToProcess:
message = error.errorMessage;
break;
case AcuantErrorInternalServerError:
message = error.errorMessage;
break;
case AcuantErrorCouldNotReachServer:
message = error.errorMessage;
break;
case AcuantErrorUnableToAuthenticate:
message = error.errorMessage;
break;
case AcuantErrorAutoDetectState:
message = error.errorMessage;
break;
case AcuantErrorWebResponse:
message = error.errorMessage;
break;
case AcuantErrorUnableToCrop:
message = error.errorMessage;
break;
case AcuantErrorInvalidLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorInactiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorAccountDisabled:
message = error.errorMessage;
break;
case AcuantErrorOnActiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorValidatingLicensekey:
message = error.errorMessage;
break;
case AcuantErrorCameraUnauthorized:
message = error.errorMessage;
break;
default:
break;
}
[UIAlertController showSimpleAlertWithTitle:@"AcuantiOSMobileSDK"
Message:message
FirstButton:ButtonOK
SecondButton:nil
FirstHandler:^(UIAlertAction *action) {
if (tag == 1) {
_sideTouch = BackSide;
_isCameraTouched = YES;
[self showCameraInterface];
}else if(tag == 7388467) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
}
SecondHandler:nil
Tag:tag
ViewController:self];
}
处理医疗保险卡
为 AcuantCardTypeMedicalInsuranceCard 添加以下代码
#pragma mark -
#pragma mark CardProcessing Delegate
-(void)didFinishProcessingCardWithResult:(AcuantCardResult *)result{
self.view.userInteractionEnabled = YES;
[SVProgressHUD dismiss];
NSString *message;
UIImage *faceimage;
UIImage *signatureImage;
UIImage *frontImage;
UIImage *backImage;
AcuantMedicalInsuranceCard *data = (AcuantMedicalInsuranceCard*)result;
message =[NSString stringWithFormat:@"First Name - %@ \nLast Name - %@ \nMiddle Name - %@ \nMemberID - %@ \nGroup No. - %@ \nContract Code - %@ \nCopay ER - %@ \nCopay OV - %@ \nCopay SP - %@ \nCopay UC - %@ \nCoverage - %@ \nDate of Birth - %@ \nDeductible - %@ \nEffective Date - %@ \nEmployer - %@ \nExpire Date - %@ \nGroup Name - %@ \nIssuer Number - %@ \nOther - %@ \nPayer ID - %@ \nPlan Admin - %@ \nPlan Provider - %@ \nPlan Type - %@ \nRX Bin - %@ \nRX Group - %@ \nRX ID - %@ \nRX PCN - %@ \nTelephone - %@ \nWeb - %@ \nEmail - %@ \nAddress - %@ \nCity - %@ \nZip - %@ \nState - %@", data.firstName, data.lastName, data.middleName, data.memberId, data.groupNumber, data.contractCode, data.copayEr, data.copayOv, data.copaySp, data.copayUc, data.coverage, data.dateOfBirth, data.deductible, data.effectiveDate, data.employer, data.expirationDate, data.groupName, data.issuerNumber, data.other, data.payerId, data.planAdmin, data.planProvider, data.planType, data.rxBin, data.rxGroup, data.rxId, data.rxPcn, data.phoneNumber, data.webAddress, data.email, data.fullAddress, data.city, data.zip, data.state];
frontImage = [UIImage imageWithData:data.reformattedImage];
backImage = [UIImage imageWithData:data.reformattedImageTwo];
}
-(void)didFailWithError:(AcuantError *)error{
self.view.userInteractionEnabled = YES;
[SVProgressHUD dismiss];
NSString *message;
switch (error.errorType) {
case AcuantErrorTimedOut:
message = error.errorMessage;
break;
case AcuantErrorUnknown:
message = error.errorMessage;
break;
case AcuantErrorUnableToProcess:
message = error.errorMessage;
break;
case AcuantErrorInternalServerError:
message = error.errorMessage;
break;
case AcuantErrorCouldNotReachServer:
message = error.errorMessage;
break;
case AcuantErrorUnableToAuthenticate:
message = error.errorMessage;
break;
case AcuantErrorAutoDetectState:
message = error.errorMessage;
break;
case AcuantErrorWebResponse:
message = error.errorMessage;
break;
case AcuantErrorUnableToCrop:
message = error.errorMessage;
break;
case AcuantErrorInvalidLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorInactiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorAccountDisabled:
message = error.errorMessage;
break;
case AcuantErrorOnActiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorValidatingLicensekey:
message = error.errorMessage;
break;
case AcuantErrorCameraUnauthorized:
message = error.errorMessage;
break;
default:
break;
}
[UIAlertController showSimpleAlertWithTitle:@"AcuantiOSMobileSDK"
Message:message
FirstButton:ButtonOK
SecondButton:nil
FirstHandler:^(UIAlertAction *action) {
if (tag == 1) {
_sideTouch = BackSide;
_isCameraTouched = YES;
[self showCameraInterface];
}else if(tag == 7388467) {
[
[UIApplication sharedApplication] openURL: [NSURL
URLWithString:UIApplicationOpenSettingsURLString]
];
}
}
SecondHandler:nil
Tag:tag
ViewController:self];
}
处理护照
为以下代码添加 AcuantCardTypePassportCard
#pragma mark -
#pragma mark CardProcessing Delegate
-(void)didFinishProcessingCardWithResult:(AcuantCardResult *)result{
self.view.userInteractionEnabled = YES;
[SVProgressHUD dismiss];
NSString *message;
UIImage *faceimage;
UIImage *signatureImage;
UIImage *frontImage;
UIImage *backImage;
AcuantPassaportCard *data = (AcuantPassaportCard*)result;
message =[NSString stringWithFormat:@"First Name - %@ \nMiddle Name - %@ \nLast Name
- %@ \nAuthentication Result - %@ \nAunthentication Summary - %@ \nPassport Number -
%@ \nPersonal Number - %@ \nSex - %@ \nCountry Long - %@ \nNationality Long - %@
\nDOB Long - %@ \nIssue Date Long - %@ \nExpiration Date Long - %@ \nPlace of Birth -
%@", data.nameFirst, data.nameMiddle, data.nameLast,data.authenticationResult,[self
arrayToString:data.authenticationResultSummaryList], data.passportNumber,
data.personalNumber, data.sex, data.countryLong, data.nationalityLong,
data.dateOfBirth4, data.issueDate4, data.expirationDate4, data.end_POB];
faceimage = [UIImage imageWithData:data.faceImage];
frontImage = [UIImage imageWithData:data.passportImage];
}
-(void)didFailWithError:(AcuantError *)error{
self.view.userInteractionEnabled = YES;
[SVProgressHUD dismiss];
NSString *message;
switch (error.errorType) {
case AcuantErrorTimedOut:
message = error.errorMessage;
break;
case AcuantErrorUnknown:
message = error.errorMessage;
break;
case AcuantErrorUnableToProcess:
message = error.errorMessage;
break;
case AcuantErrorInternalServerError:
message = error.errorMessage;
break;
case AcuantErrorCouldNotReachServer:
message = error.errorMessage;
break;
case AcuantErrorUnableToAuthenticate:
message = error.errorMessage;
break;
case AcuantErrorAutoDetectState:
message = error.errorMessage;
break;
case AcuantErrorWebResponse:
message = error.errorMessage;
break;
case AcuantErrorUnableToCrop:
message = error.errorMessage;
break;
case AcuantErrorInvalidLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorInactiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorAccountDisabled:
message = error.errorMessage;
break;
case AcuantErrorOnActiveLicenseKey:
message = error.errorMessage;
break;
case AcuantErrorValidatingLicensekey:
message = error.errorMessage;
break;
case AcuantErrorCameraUnauthorized:
message = error.errorMessage;
break;
default:
break;
}
[UIAlertController showSimpleAlertWithTitle:@"AcuantiOSMobileSDK"
Message:message
FirstButton:ButtonOK
SecondButton:nil
FirstHandler:^(UIAlertAction *action) {
if (tag == 1) {
_sideTouch = BackSide;
_isCameraTouched = YES;
[self showCameraInterface];
}else if(tag == 7388467) {
[[UIApplication sharedApplication] openURL:
[NSURL
URLWithString:UIApplicationOpenSettingsURLString]];
}
}
SecondHandler:nil
Tag:tag
ViewController:self];
}
//Function to convert Authentication Summary list to a single NSString object
-(NSString*)*arrayToString:(NSArray*)*array{
NSString* retStr = @"";
for(NSString* str in array){
if([retStr isEqualToString:@""]){
retStr = str;
}else{
retStr = [NSString stringWithFormat:@"%@,%@",retStr,str];
}
}
return retStr;
}
确保ID认证
AuthenticationResult 和 AuthenticationResultSummary 字段包含驾驶证和护照的AssureID认证结果。
-
AuthenticationResult – 返回以下值之一:通过 | 失败 | 注意 | 未知 | 跳过
-
AuthenticationResultSummary – 当 AuthenticationResult 值为“注意”时包含原因。
注意 对于除了“注意”外的任何结果(通过、失败、未知或跳过),AuthenticationResultSummary 的值将为空。
追踪捕获设备位置
需要检测ID/护照捕获位置时,可使用以下代码启用位置追踪:
// 初始化 AcuantMobileSDKController
注意 请在应用程序的.plist文件中添加以下键及其值以启用位置追踪。
NSLocationAlwaysUsageDescription
##位置详细信息
以下方法返回位置详细信息:
/* To get the location details*/
[_instance getDeviceStreetAddress]// Street address of device location
[_instance getDeviceArea] // Area of the device location
[_instance getDeviceCity] // City of the device location
[_instance getDeviceState] // State of the device location
[_instance getDeviceCountry]] // Country of the device location
[_instance getDeviceCountryCode]// Country code of the device location
[_instance getDeviceZipCode] // zipcode of the device location
以下枚举用于位置测试结果:
typedef enum {
AcuantDeviceLocationTestFailed = 0,
AcuantDeviceLocationTestPassed = 1,
AcuantDeviceLocationTestNotAvailable = 2,
} AcuantDeviceLocationTestResult;
以下位置测试字段由 AcuantCardResult 类使用:
@property (nonatomic) AcuantDeviceLocationTestResult idLocationStateTestResult;
@property (nonatomic) AcuantDeviceLocationTestResult
idLocationCountryTestResult;
@property (nonatomic) AcuantDeviceLocationTestResult idLocationCityTestResult;
@property (nonatomic) AcuantDeviceLocationTestResult idLocationZipcodeTestResult;
以下字段返回AssureID认证结果:
-
AuthenticationResult – 返回以下值之一:通过 | 失败 | 注意 | 未知 | 跳过
-
AuthenticationResultSummary – 当 AuthenticationResult 值为“注意”时包含原因。
注意 对于除了“注意”外的任何结果(通过、失败、未知或跳过),AuthenticationResultSummary 的值将为空。
面部识别匹配(FRM)
Acuant 面部识别匹配(FRM)是基于生物特征面部识别的移动设备人员身份验证解决方案,通过将面部生物特征与驾驶证或护照上的面部图像进行匹配来减少欺诈。它是安全、方便且易于集成,能够在几秒钟内进行实时检查和处理。
Acuant FRM 执行以下操作:
- 打开前置相机
- 确保用户正确放置在摄像头前
- 检测到真人
- 通过展示眨眼挑战来检测欺骗攻击
- 获取生物识别样本
- 验证用户的身份
Acuant FRM执行以下检查以识别真实人脸并将人脸生物识别与驾照或护照上的照片匹配。
-
人脸位置检查 - 检查人脸是否被良好检测到,正确居中,并距离摄像头合适的距离。距离到人算法确保人脸距离前摄像头为最佳距离。确保用户只提供正面人脸(侧脸将被拒绝)。
-
追踪眼睑动作作为一个额外的层次来检查人脸的活跃性并避免欺骗攻击。
-
捕获人脸生物识别并将其与驾照或护照上的人脸照片匹配。
以下API/类用于FRM。
AcuantFacialCaptureDelegate类
AcuantFacialCaptureDelegate类用于从SDK接口获得回调。
-
当成功识别到真实人脸时调用。 注意
image
参数包含通过面部识别识别的人脸图像。-(void)didFinishFacialRecognition:(UIImage*)image;
-
当用户取消面部识别时调用
-(void)didCancelFacialRecognition
-
设置面部识别超时时间(以秒为单位)
-(int)facialRecognitionTimeout{ return 20; }
-
当用户点击面部超时警报中的是时,控制到这里。 lastImage参数是超时前的最后一帧图像
-(void)didTimeoutFacialRecognition:(UIImage*)lastImage
-
指定是否显示警报或在面部超时后立即关闭面部界面。
-(BOOL)shouldShowFacialTimeoutAlert{ return true; // true for showing alert , false for not showing alet and dismiss immidiately }
-
为面部屏幕的返回按钮提供自定义图像
-(UIImage*)imageForFacialBackButton
-
红色矩形出现后显示自定义消息
-(NSAttributedString*)messageToBeShownAfterFaceRectangleAppears;
-
指定messageToBeShownAfterFaceRectangleAppears在摄像头屏幕上的位置
-(CGRect)frameWhereMessageToBeShownAfterFaceRectangleAppears;
AcuantFacialRecognitionViewController类
此类包含以下实用方法,可以调用以显示面部识别界面。
+(id)presentFacialCaptureInterfaceWithDelegate
(id<AcuantFacialCaptureDelegate>)delegate withSDK:
(AcuantMobileSDKController*)sdkController inViewController:
(UIViewController*)parentVC withCancelButton:(BOOL)cancelVisible
withCancelButtonRect:(CGRect) cancelRect
withWaterMark:(NSString* )watermarkText
withBlinkMessage:(NSAttributedString*)message
inRect:(CGRect)rect;
###参数
####(id)delegate Delegate:控制返回的位置
####(AcuantMobileSDKController)sdkController SDK控制器
####(UIViewController)parentVC 提供相机界面的父视图控制器
####(BOOL)cancelVisible 指示是否显示 取消 按钮
####(CGRect) cancelRect 取消 按钮的位置
####(NSString)watermarkText 品牌水印文本
####(NSAttributedString)message 指示消息(例如,“慢慢眨眼”)
####(CGRect)rect 在相机界面内显示指示消息的框架
人脸匹配功能调用
/**
Use this method to do facial match.
@param selfieImage The captured selfie Image.
@param IDFaceImage Face Image from ID or Passport card
@param delegate the delegate of the process request
@param options the options of the process request.
@discussion you must always provide a selfieImage and a face image to match
@discussion use the options object to indicate the type as AcuantCardTypeFacial. Processing will fail if you don't provide this parameter.
@discussion you're encourage to provide a delegate to be informed about what happened with your processing request. You can change the delegate using the cardProcessingDelegate property of this class.
@discussion you should call this method only once and wait until your delegate is informed. If you call this method while we're already processing a card, we'll ignore your second call.
*/
-(void)validatePhotoOne:(UIImage *)selfieImage
withImage:(NSData *)IDFaceImage
withDelegate:(id<AcuantMobileSDKControllerProcessingDelegate>)delegate
withOptions:(AcuantCardProcessRequestOptions*)option;
人脸匹配功能调用的方法与其他卡片处理功能调用相同。
示例
//Face Image
UIImage *selfiImage = image;
//DL/Passport Photo
NSData *faceImageData =_resultViewController.faceImageData;
//Obtain the default AcuantCardProcessRequestOptions object for the type of card you want to process (License card for this example)
AcuantCardProcessRequestOptions *options = [AcuantCardProcessRequestOptions defaultRequestOptionsForCardType:AcuantCardTypeFacial];
[self.instance validatePhotoOne:selfieImage withImage:faceImageData withDelegate:<Delegate the control should come back> withOptions:options];
-
第一个参数是回调中返回的人脸图像。
-(void)didFinishFacialRecognition:(UIImage*)image;
-
第二个参数是需要与人脸图像进行匹配的ID/护照中的人脸图像。
-
委托(Delegate)是在函数调用返回后的Web服务委托,其中将控制权传递。
-
AcuantCardProcessRequestOptions是最后一个参数,如上所述,已初始化为卡类型为AcuantCardTypeFacial。
-
函数调用返回后,将调用以下委托方法
- (void)didFinishValidatingImageWithResult:(AcuantCardResult*)cardResult{ AcuantFacialData* result =(AcuantFacialData*)cardResult; }
##AcuantFacialData属性
####isMatch表示是否两个图像匹配
@property (nonatomic, assign) BOOL isMatch ; // If both images matched
####isFacialEnabled表示是否启动了面部特征
@property (nonatomic, assign) BOOL isFacialEnabled;// If facial feature is enabled
####faceLivelinessDetection表示是否检测到活体人脸
@property (nonatomic, assign) BOOL faceLivelinessDetection; // If a live face was detected
####transactionId是指定面部匹配事务ID的字符串
@property (nonatomic, strong) NSString *transactionId; // Facial match transaction id
####errorMessage包含任何服务错误描述的字符串
注意 如果交易成功处理,则该字段将为null。
@property (nonatomic, strong) NSString *errorMessage; // Any service error description. If the transaction has gone through successfully then this field will be null.
####facialMatchConfidenceRating是指出匹配置信水平的一个整数,数值范围从1 - 100
错误类型
可能会产生以下错误
####AcuantErrorCouldNotReachServer = 0 检查互联网连接
####AcuantErrorUnableToAuthenticate = 1 密钥许可证不正确
####AcuantErrorUnableToProcess = 2 服务器收到的图像不可读,请重新拍照
####AcuantErrorInternalServerError = 3 我们服务器出现问题,稍后再试
####AcuantErrorUnknown = 4 发生错误,但我们无法确定原因,稍后再试
####AcuantErrorTimedOut = 5 请求超时,可能是由于互联网连接太慢
####AcuantErrorAutoDetectState = 6 尝试检测状态时发生错误
####AcuantErrorWebResponse = 7 服务器收到的JSON包含错误
####AcuantErrorUnableToCrop = 8 收到的图像无法裁剪
####AcuantErrorInvalidLicenseKey = 9 无效的许可证密钥
####AcuantErrorInactiveLicenseKey = 10 无效的许可证密钥
####AcuantErrorAccountDisabled = 11 账户已禁用
####AcuantErrorOnActiveLicenseKey = 12 激活密钥上存在错误
####AcuantErrorValidatingLicensekey = 13 验证仍在进行中
####AcuantErrorCameraUnauthorized = 14 隐私设置阻止了相机访问
####AcuantErrorOpenCamera = 15 打开相机时发生错误
####AcuantErrorIncorrectDocumentScanned = 16 扫描错误的文档类型时发生错误
版权 © 2003-2019 Acuant Inc. 保留所有权利。
本文件包含Acuant及其相应许可方的专有和机密信息和创意作品。未经Acuant事先明确的书面许可,严禁任何形式的全部或部分使用、复制、出版、分发、展示、修改或传输此类技术。除非Acuant书面明确提供,否则拥有此信息不应解释为授予在任何Acuant知识产权下的任何许可或权利,无论是基于禁止反言、推定或任何其他原因。
AssureID和i-Dentify是Acuant Inc.的商标。本文件中提到的其他Acuant产品或服务名称或标志是Acuant的商标或注册商标。
所有3M商标是Gemalto Inc.的商标。
Windows®是微软公司的注册商标。
本文件可能提及除Acuant以外的公司的产品、服务或公司名称,仅为目的识别。这些名称经常被声明为商标或服务标记。在Acuant知道任何索赔的情况下,该名称以大写字母显示器。但是,您应联系相关公司以获取关于此类名称及其注册状态的更完整信息。
2019年11月
Acuant Inc.
6080 Center Drive, Suite 850
洛杉矶,CA 90045