zoukankan      html  css  js  c++  java
  • 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,超过后返回 报错

  • 相关阅读:
    jQuery选择器大全(48个代码片段+21幅图演示)
    抽象和模型
    什么叫做精通,我来给大家解释一下
    设置浏览器固定大小的固定位置的方法
    selenium对浏览器属性操作的方法
    selenium 最大化浏览器是解决浏览器和驱动不匹配的方法如下
    java selenium手动最大化chrome浏览器的方法
    java selenium启动火狐浏览器报错:Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z
    mygenerator().next() AttributeError: 'generator' object has no attribute 'next'
    马的遍历 搜索
  • 原文地址:https://www.cnblogs.com/xujiahui/p/9771008.html
Copyright © 2011-2022 走看看