接入腾讯活体SDK

001 请求接口获取到接入参数 接入 代理 WBFaceVerifyCustomerServiceDelegate

@property (nonatomic, copy) NSString *appid;
@property (nonatomic, copy) NSString *nonce;
@property (nonatomic, copy) NSString *sign;
@property (nonatomic, copy) NSString *orderNO;
@property (nonatomic, copy) NSString *userID;
@property (nonatomic, copy) NSString *licence;
@property (nonatomic, copy) NSString *keyVersion;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *idNo;

@property (nonatomic, copy) NSString *wbfacebaseURLString;
@property (nonatomic, copy) NSString *wbgetFaceIDURLString;

002 发起活体检测

 [WBFaceVerifyCustomerService sharedInstance].delegate = self;
    WBFaceVerifySDKConfig *config = [self getSDKSettings];
    // // 活体检测 + 身份证 + 姓名
    
    NSDictionary *params = @{@"webankAppId":self.appid,
                             @"orderNo":self.orderNO,
                             @"name": self.name,
                             @"idNo": self.idNo,
                             @"userId":self.userID,
                             @"nonce":self.nonce,
                             @"version": @"1.0.0",
                             @"sign": self.sign,
                             @"licence":self.licence
                             };

    NSData *bodydata = [NSJSONSerialization dataWithJSONObject:params options:NSJSONReadingMutableLeaves|NSJSONReadingAllowFragments error:nil];

    NSURLSession *session = [NSURLSession sessionWithConfiguration:NSURLSessionConfiguration.defaultSessionConfiguration];
    NSMutableURLRequest *requst = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.wbgetFaceIDURLString]];
    [requst setHTTPMethod:@"POST"];
    [requst setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    requst.HTTPBody = bodydata;
    NSLog(@"request: %@", requst);

    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:requst completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

        if (error != nil) {
            [SVProgressHUD dismiss];
            NSString *message = [NSString stringWithFormat:@"%@", error.description];
            NSLog(@"error: %@", error);
            [SVProgressHUD showErrorWithStatus:message];
            return ;
        }

        NSError * jsonErr = nil;
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonErr];
        if(jsonErr != nil){
            [SVProgressHUD dismiss];
            NSString *message = [NSString stringWithFormat:@"%@", jsonErr.description];
            NSLog(@"error: %@", error);
            [SVProgressHUD showErrorWithStatus:message];
           
            return ;
        }

        //其他情况, json有数据, json没有faceId
        NSLog(@"dict: %@", [dict objectForKey:@"msg"]);
        NSString *faceId = [dict valueForKeyPath:@"result.faceId"];
//        if (faceId.length <= 0) {
//            [SVProgressHUD dismiss];
//            [SVProgressHUD showErrorWithStatus:dict.description];
//            return ;
//        }

        dispatch_async(dispatch_get_main_queue(), ^{
            // 身份证+姓名接口
        
            [[WBFaceVerifyCustomerService sharedInstance] initSDKWithUserId:self.userID nonce:self.nonce sign:self.sign appid:self.appid orderNo:self.orderNO apiVersion:self.keyVersion licence:self.licence faceId:faceId sdkConfig:config success:^{
                [[WBFaceVerifyCustomerService sharedInstance] startWbFaceVeirifySdk];
                [SVProgressHUD dismiss];

            } failure:^(WBFaceError * _Nonnull error) {
                [SVProgressHUD dismiss];
                if (iOS8Later) {
                    NSString *message = [NSString stringWithFormat:@"%@", error.desc];
                    NSLog(@"error: %@", error);
                    [SVProgressHUD showErrorWithStatus:message];
//
                }
            }];
        });
    }];

    [dataTask resume];
    return;
}


#pragma mark - WBFaceVerifyCustomerServiceDelegate
-(void)wbSDKServiceDidFinishedNotification:(NSNotification *)noti {
    WBFaceVerifyResult *faceVerifyResult = (WBFaceVerifyResult *)[noti.userInfo objectForKey:@"faceVerifyResult"];
    
    if (faceVerifyResult.isSuccess){
        NSString *message = [NSString stringWithFormat:@"liveRate: %@, similarity: %@", faceVerifyResult.liveRate, faceVerifyResult.similarity];
        [SVProgressHUD showSuccessWithStatus:message];
        
        [self requsetCheckFaceVerify];
        
    }else{
        NSString *message = [NSString stringWithFormat:@"%@", faceVerifyResult.error.desc];
        [SVProgressHUD showSuccessWithStatus:message];
    }
}

- (void)requsetCheckFaceVerify{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [AutoSwitchFlag shared].openAFNet = YES;
    [self routeTargetName:Handle actionName:@"checkAuthCerifyAction:" param:dic];
}

-(WBFaceVerifySDKConfig *)getSDKSettings{
    WBFaceVerifySDKConfig *config = [WBFaceVerifySDKConfig sdkConfig];
    config.recordVideo = YES;
    config.theme = WBFaceVerifyThemeLightness;
    config.showSuccessPage = YES;
    config.showFailurePage = YES;
    config.enableCloseEyes = NO;
    return  config;
}


- (void)wbfaceVerifyCustomerServiceDidFinishedWithFaceVerifyResult:(nonnull WBFaceVerifyResult *)faceVerifyResult {
    
    if (faceVerifyResult.isSuccess){
        NSString *message = [NSString stringWithFormat:@"liveRate: %@, similarity: %@", faceVerifyResult.liveRate, faceVerifyResult.similarity];
        [SVProgressHUD showSuccessWithStatus:message];
        
        [self requsetCheckFaceVerify];
        
    }else{
        NSString *message = [NSString stringWithFormat:@"%@", faceVerifyResult.error.desc];
        [SVProgressHUD showErrorWithStatus:message];
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
## 使用前准备​ 1. 前往注册: [腾讯云账号注册](https://cloud.tencent.com/register) (详细指引见 [注册腾讯云](https://cloud.tencent.com/document/product/378/9603)) 2. 取得存储桶名称 **BucketName**: 请前往 [创建存储桶](https://cloud.tencent.com/document/product/460/10637) 3. 取得 **APPID**、**SecretId**、**SecretKey**:请前往 [云API密钥](https://console.cloud.tencent.com/cam/capi) ,点击“新建密钥” ## 快速验 1. 修改文件 src/main/java/com/qcloud/image/demo/Demo.java 的 main() 方法,填入上述申请到的 **APPID**、**SecretId**、**SecretKey**、**BucketName** 2. 导入到 IDE:工程用 Maven 构建,以 Intellij IDEA 为例,导入方式为:Import Project -> 选择工程目录 -> Import project from external model -> Maven 3. 运行:Demo.java 右键,Run Demo.main() ## 使用简介 ### 初始化 ```java ImageClient imageClient = new ImageClient(APPID, SecretId, SecretKey); ``` ### 设置代理 根据实际网络环境,可能要设置代理,例如: ```java Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress("127.0.0.1", 8080)); imageClient.setProxy(proxy); ``` ### 使用 SDK 提供功能如下: **图像识别**:鉴黄,标签 **文字识别(OCR)**:身份证,名片,通用,驾驶证行驶证,营业执照,银行卡,车牌号 **人脸识别**:人脸检测,五官定位,个信息管理,人脸验证,人脸对比及人脸检索 **人脸核身**:照片核身(通过照片和身份证信息),获取唇语验证码(用于核身),核身(通过视频和照片),核身(通过视频和身份证信息) ```java // 调用车牌识别API示例 String imageUrl = "http://youtu.qq.com/app/img/experience/char_general/icon_ocr_license_3.jpg"; String result = imageClient.ocrPlate(new OcrPlateRequest("bucketName", imageUrl)); System.out.println(result); ``` 更多例子详情可参见 [Demo.java](https://github.com/tencentyun/image-java-sdk-v2.0/blob/master/src/main/java/com/qcloud/image/demo/Demo.java) 的代码。 ## 集成到你的项目中 ### 获得 SDK jar 文件 1. 直接使用 release/*-with-dependencies.jar 2. 自行编译:在工程根目录下执行命令 `mvn assembly:assembly`,编译结果见 target/*-with-dependencies.jar ### 导入 jar 文件 根据项目具情况导入 *-with-dependencies.jar
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值