iOS 使用百度的人脸识别登录验证,解决认证失败不跳转界面连续认证,认证相似度对比...

在使用百度人脸识别出现的问题:小米6调用摄像机是黑白的一个情况,iOS上会出现识别准确性上的问题(多次代开认证,会通过)

人脸识别(活体验证):

1、芝麻认证 : 0.4元/次,需要企业企业认证、不能有与芝麻信用类似的业务,如:保险、、、

2、旷视 : 0.5/次.企业认证、业务限制

3、 百度人脸识别  :免费的---可以同时处理10条认证,  企业认证,

 4、科大讯飞   人脸检测  2000万次   1年 7.2万  活体检测只能上传一段视频来检测 需要和商务沟通

我们使用的百度,,,,

需求:需要在认证中不跳转界面,失败:继续认证、成功:跳转。

 

----------------------------------------------------------

一、在认证结果中促发通知给 DetectionViewController  认证结果,

-(void)baiduVerifiResouts:(NSNotification*)notification{

    

    if ([notification.object isEqualToString:@"yes"]) {

//认证成功

        [self closeAction];

    }else{

        

//认证失败

       

     self.hasFinished = NO;

    [IDLFaceDetectionManager.sharedInstance reset];

   

    [[FaceSDKManager sharedInstance] clearTrackedFaces];

     [[IDLFaceDetectionManager sharedInstance] startInitial];

    [self.videoCapture startSession];

    self.videoCapture.delegate = self;

    self.videoCapture.runningStatus = YES;

        

        

    }

    

}
View Code

 

 

2、 需要将调用 closeAction 方法的地方注释

 

---------------------------------------------------------------------

二、认证相似度对比 

 

在返回识别结果中,会把所有相似的人给返回,需要自己筛选出自己的相似度进行 对比

1、识别结果请求

 

 

[[NetAccessModel sharedInstance] searchFaceWithImageBaseString:bestImageStr userName:UserModelonline.userId completion:^(NSError *error, id resultObject) {

 

                    NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:resultObject options:NSJSONReadingAllowFragments error:nil];

                    NSInteger type = 0;

 

                    NSString* tip = @"识别失败!";

 

                    if ([dict[@"error_code"] intValue] == 0) {

                        //获取层级字典

                        NSDictionary* result = dict[@"result"];

                        NSArray * user_list =result[@"user_list"];

                        

                        //判断相似度符合的人数 大于0 继续

                        if ([result[@"user_list"] count] > 0

                            ) {

 

                            //获取自己的相似度 进行对比

                            NSMutableDictionary * userDict = [NSMutableDictionary dictionary];

 

                            for (int i=0; i<user_list.count; i++) {

 

                                NSDictionary * dict = user_list[i];

                                //根据自己的uid 获取到自己的相似度是多少

                                if ([dict[@"user_id"] isEqualToString:UserModelonline.userId]) {

                              

                                    [userDict setDictionary:dict];

                                    break;

                                }

                                

                            }

                            

                            //相似度进行对比 大于90了 为识别成功

                            if (userDict.allKeys.count > 0) {

                              

                                if ([userDict[@"score"] intValue] > 90) {

                                    type = 1;

                                    tip = @"识别成功";

                                }

                                

                            }else{

                                NSLog(@"----------------------------------没有与自己相似的人啊");

                            }

                            

                            

      

                        } else {

                            tip = @"活体检测识别失败";

                            

                        }

                      

                        

                    } else {

 

                             NSLog(@"失败了%@ = %@,%@,%@",UserModelonline.userId,dict[@"error_code"],dict[@"error_msg"],dict[@"log_id"]);

                    }

 

                              

 

              if(type==1){


                  //成功了

               }else{

                 //失败了

                }

 

 

 

 

 
View Code

 

三、 人脸注册 成功一次上传一张照片,最大上限20,超过后返回 报错

转载于:https://www.cnblogs.com/xujiahui/p/9771008.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值