|
|
@@ -970,40 +970,84 @@
|
|
|
|
|
|
#pragma mark --- 人脸验证流程
|
|
|
- (void)identify:(NSString*)bestImageStr originImage:(UIImage *)originImage andViewController:(DetectionViewController *)dvc andImageData:(NSData *)imageData{
|
|
|
- __weak typeof(self) weakSelf = self;
|
|
|
- [[NetAccessModel sharedInstance] identifyUserLivenessWithFaceImageStr:bestImageStr completion:^(NSError *error, id resultObject) {
|
|
|
-
|
|
|
- if (resultObject) {
|
|
|
- NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:resultObject options:NSJSONReadingAllowFragments error:nil];
|
|
|
- SLog(@"人脸识别数据:%@",dict);
|
|
|
-
|
|
|
- //先判断接口请求是否成功
|
|
|
- NSString *success = FORMAT(@"%@",dict[@"error_msg"]);
|
|
|
- if ([success isEqualToString:@"SUCCESS"]) {
|
|
|
- //判断人脸库是否存在当前用户
|
|
|
- NSArray *userList = dict[@"result"][@"user_list"];
|
|
|
- if (userList.count == 0) {
|
|
|
- //无此用户走人脸注册流程
|
|
|
- [UASAlertView showWithTitle:nil content:@"您未录入人脸照片,点击“确定”录入系统" sureTitle:@"确定录入" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
+
|
|
|
+ // 设置鉴权
|
|
|
+ NSString* licensePath = [[NSBundle mainBundle] pathForResource:FACE_LICENSE_NAME ofType:FACE_LICENSE_SUFFIX];
|
|
|
+ NSAssert([[NSFileManager defaultManager] fileExistsAtPath:licensePath], @"license文件路径不对,请仔细查看文档");
|
|
|
+ [[FaceSDKManager sharedInstance] setLicenseID:FACE_LICENSE_ID andLocalLicenceFile:licensePath];
|
|
|
+
|
|
|
+ [SVProgressHUD appearance].defaultStyle = SVProgressHUDStyleDark;
|
|
|
+
|
|
|
+ [[NetAccessModel sharedInstance] getAccessTokenWithAK:FACE_API_KEY SK:FACE_SECRET_KEY];
|
|
|
+
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ [[NetAccessModel sharedInstance] identifyUserLivenessWithFaceImageStr:bestImageStr completion:^(NSError *error, id resultObject) {
|
|
|
+
|
|
|
+ if (resultObject) {
|
|
|
+ NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:resultObject options:NSJSONReadingAllowFragments error:nil];
|
|
|
+ SLog(@"人脸识别数据:%@",dict);
|
|
|
+
|
|
|
+ //先判断接口请求是否成功
|
|
|
+ NSString *success = FORMAT(@"%@",dict[@"error_msg"]);
|
|
|
+ if ([success isEqualToString:@"SUCCESS"]) {
|
|
|
+ //判断人脸库是否存在当前用户
|
|
|
+ NSArray *userList = dict[@"result"][@"user_list"];
|
|
|
+ if (userList.count == 0) {
|
|
|
+ //无此用户走人脸注册流程
|
|
|
+ [UASAlertView showWithTitle:nil content:@"您未录入人脸照片,点击“确定”录入系统" sureTitle:@"确定录入" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
+ if (index == 2) {
|
|
|
+ [weakSelf RegisterUserFactToBaiduFaceListWithFaceImageString:bestImageStr andViewController:dvc andImageData:imageData];
|
|
|
+ }
|
|
|
+ if (index == 1) {
|
|
|
+ [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+ }else{
|
|
|
+ NSDictionary *userDic = userList[0];
|
|
|
+ float score = [[userDic objectForKey:@"score"] floatValue];
|
|
|
+ if (score > 85) {
|
|
|
+ //是本人,走打卡流程
|
|
|
+ [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
+
|
|
|
+ [self startPunchCard:imageData];
|
|
|
+ }else{
|
|
|
+ //不是本人
|
|
|
+ [UASAlertView showWithTitle:nil content:@"抱歉,没有认出你哦" sureTitle:@"再试一次" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
+ if (index == 2) {
|
|
|
+ [IDLFaceDetectionManager.sharedInstance reset];
|
|
|
+ [[IDLFaceDetectionManager sharedInstance] startInitial];
|
|
|
+ dvc.hasFinished = NO;
|
|
|
+ [dvc startCapture];
|
|
|
+ }
|
|
|
+ if (index == 1) {
|
|
|
+ [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ([success isEqualToString:@"liveness check fail"]){
|
|
|
+ [UASAlertView showWithTitle:nil content:@"不能拿照片骗我哦" sureTitle:@"再试一次" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
if (index == 2) {
|
|
|
- [weakSelf RegisterUserFactToBaiduFaceListWithFaceImageString:bestImageStr andViewController:dvc andImageData:imageData];
|
|
|
+ [IDLFaceDetectionManager.sharedInstance reset];
|
|
|
+ [[IDLFaceDetectionManager sharedInstance] startInitial];
|
|
|
+ dvc.hasFinished = NO;
|
|
|
+ [dvc startCapture];
|
|
|
}
|
|
|
if (index == 1) {
|
|
|
[dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
}
|
|
|
}];
|
|
|
-
|
|
|
- }else{
|
|
|
- NSDictionary *userDic = userList[0];
|
|
|
- float score = [[userDic objectForKey:@"score"] floatValue];
|
|
|
- if (score > 85) {
|
|
|
- //是本人,走打卡流程
|
|
|
- [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
-
|
|
|
- [self startPunchCard:imageData];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if ([FORMAT(@"%@",[dict objectForKey:@"error_code"])isEqualToString:@"222207"]) {
|
|
|
+ //无此用户走人脸注册流程,先到ERP看是否传过人脸
|
|
|
+ [self getERPhaveFace:bestImageStr originImage:originImage andViewController:dvc andImageData:imageData];
|
|
|
}else{
|
|
|
- //不是本人
|
|
|
- [UASAlertView showWithTitle:nil content:@"抱歉,没有认出你哦" sureTitle:@"再试一次" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
+ [UASAlertView showWithTitle:nil content:success sureTitle:@"再试一次" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
if (index == 2) {
|
|
|
[IDLFaceDetectionManager.sharedInstance reset];
|
|
|
[[IDLFaceDetectionManager sharedInstance] startInitial];
|
|
|
@@ -1017,46 +1061,66 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if ([success isEqualToString:@"liveness check fail"]){
|
|
|
- [UASAlertView showWithTitle:nil content:@"不能拿照片骗我哦" sureTitle:@"再试一次" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
- if (index == 2) {
|
|
|
- [IDLFaceDetectionManager.sharedInstance reset];
|
|
|
- [[IDLFaceDetectionManager sharedInstance] startInitial];
|
|
|
- dvc.hasFinished = NO;
|
|
|
- [dvc startCapture];
|
|
|
- }
|
|
|
- if (index == 1) {
|
|
|
- [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
- }
|
|
|
- }];
|
|
|
- }
|
|
|
- else{
|
|
|
- if ([FORMAT(@"%@",[dict objectForKey:@"error_code"])isEqualToString:@"222207"]) {
|
|
|
- //无此用户走人脸注册流程
|
|
|
- [UASAlertView showWithTitle:nil content:@"您未录入人脸照片,点击“确定”录入系统" sureTitle:@"确定录入" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
- if (index == 2) {
|
|
|
- [weakSelf RegisterUserFactToBaiduFaceListWithFaceImageString:bestImageStr andViewController:dvc andImageData:imageData];
|
|
|
- }
|
|
|
- if (index == 1) {
|
|
|
- [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
- }
|
|
|
- }];
|
|
|
- }else{
|
|
|
- [UASAlertView showWithTitle:nil content:success sureTitle:@"再试一次" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
- if (index == 2) {
|
|
|
- [IDLFaceDetectionManager.sharedInstance reset];
|
|
|
- [[IDLFaceDetectionManager sharedInstance] startInitial];
|
|
|
- dvc.hasFinished = NO;
|
|
|
- [dvc startCapture];
|
|
|
- }
|
|
|
- if (index == 1) {
|
|
|
- [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
- }
|
|
|
- }];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark --- 勉强操作:百度会抽风,所以在ERP做是否传过人脸的标识
|
|
|
+- (void)getERPhaveFace:(NSString*)bestImageStr originImage:(UIImage *)originImage andViewController:(DetectionViewController *)dvc andImageData:(NSData *)imageData{
|
|
|
+
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+
|
|
|
+ NSString *url = [NSString stringWithFormat:@"%@/mobile/getUploadPictureSign.action",g_id];
|
|
|
+
|
|
|
+ NSDictionary *param = @{
|
|
|
+ @"master":g_master,
|
|
|
+ @"em_imid":g_server.myself.userId,
|
|
|
+ @"emcode":g_emcode
|
|
|
+ };
|
|
|
+
|
|
|
+ url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
+
|
|
|
+ UASNetworkManager *mannage = [UASNetworkManager shareManager];
|
|
|
+
|
|
|
+ mannage.responseSerializer = [AFJSONResponseSerializer serializer];
|
|
|
+
|
|
|
+ [mannage request:url method:POST parameters:param progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
|
|
|
+
|
|
|
+ NSString *faceStr = FORMAT(@"%@",responseObject[@"em_uploadsign"]);
|
|
|
+
|
|
|
+ if ([faceStr isEqualToString:@"1"]) {
|
|
|
+
|
|
|
+ [UASAlertView showWithTitle:nil content:@"抱歉,没有认出你哦" sureTitle:@"再试一次" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
+ if (index == 2) {
|
|
|
+ [IDLFaceDetectionManager.sharedInstance reset];
|
|
|
+ [[IDLFaceDetectionManager sharedInstance] startInitial];
|
|
|
+ dvc.hasFinished = NO;
|
|
|
+ [dvc startCapture];
|
|
|
}
|
|
|
- }
|
|
|
+ if (index == 1) {
|
|
|
+ [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ //无此用户走人脸注册流程
|
|
|
+ [UASAlertView showWithTitle:nil content:@"您未录入人脸照片,点击“确定”录入系统" sureTitle:@"确定录入" cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
|
|
|
+ if (index == 2) {
|
|
|
+ [weakSelf RegisterUserFactToBaiduFaceListWithFaceImageString:bestImageStr andViewController:dvc andImageData:imageData];
|
|
|
+ }
|
|
|
+ if (index == 1) {
|
|
|
+ [dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ } failure:^(NSURLSessionDataTask *task, NSError *error) {
|
|
|
+
|
|
|
+
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
@@ -1071,13 +1135,45 @@
|
|
|
//先判断接口请求是否成功
|
|
|
NSString *success = FORMAT(@"%@",dict[@"error_msg"]);
|
|
|
if ([success isEqualToString:@"SUCCESS"]) {
|
|
|
+
|
|
|
[dvc dismissViewControllerAnimated:YES completion:nil];
|
|
|
+ //在ERP上做标识
|
|
|
+ [self changeFaceStateToERP];
|
|
|
//注册成功后,走打卡流程
|
|
|
[self startPunchCard:imageData];
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+#pragma mark --- 百度人脸注册成功后,在ERP上做个标识
|
|
|
+-(void)changeFaceStateToERP
|
|
|
+{
|
|
|
+ NSString *url = [NSString stringWithFormat:@"%@/mobile/updateUploadPictureSign.action",g_id];
|
|
|
+
|
|
|
+ NSDictionary *param = @{
|
|
|
+ @"master":g_master,
|
|
|
+ @"em_imid":g_server.myself.userId,
|
|
|
+ @"emcode":g_emcode,
|
|
|
+ @"em_uploadsign":@"1"
|
|
|
+ };
|
|
|
+
|
|
|
+ url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
+
|
|
|
+ UASNetworkManager *mannage = [UASNetworkManager shareManager];
|
|
|
+
|
|
|
+ mannage.responseSerializer = [AFJSONResponseSerializer serializer];
|
|
|
+
|
|
|
+ [mannage request:url method:POST parameters:param progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
|
|
|
+ // wdddnsstring *string = development ;
|
|
|
+ // whatthefuck *string = velopment ;
|
|
|
+ //
|
|
|
+
|
|
|
+ } failure:^(NSURLSessionDataTask *task, NSError *error) {
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
//2.1导航栏右按钮--设置界面
|
|
|
- (void)pushToSetting
|