feat:引入人脸识别sdk

This commit is contained in:
ctw committed 2025-11-29 01:17:29 +08:00
1 parent ce16eaf82e
commit 158d012eff
331 files changed
+13539

No files matched your search

@@ -0,0 +1,77 @@
//
// APFBaseTask.h
// APFaceDetectBiz
//
// Created by 晗羽 on 8/25/16.
// Copyright © 2016 DTF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <BioAuthEngine/IBioAuthTask.h>
#import <BioAuthEngine/APBTaskContext.h>
#import <BioAuthEngine/APBLogger.h>
#import <BioAuthEngine/AFEAlertView.h>
#import <APBToygerFacade/APBToygerUtils.h>
#import <DTFUtility/APBToygerRemoteConfig.h>
#import <BioAuthEngine/APBToygerBehavlogManager.h>
//#import "APBToygerDataCenter.h"
#import <BioAuthEngine/BioAuthCommonSetting.h>
#import <APBToygerFacade/APBToygerViewController.h>
@class DTFLogMonitor,APBToygerDataCenter;
typedef void (^APFAlertExtraAction)();
@interface APBToygerBaseTask : NSObject <IBioAuthTask>
//协议定义的属性
@property(nonatomic, copy)NSString *taskName; //任务名
@property(nonatomic, strong)APBTaskContext *context; //任务数据
@property(nonatomic, weak)NSMutableDictionary *pipeInfo; //共享数据
//公用属性
@property(nonatomic, weak)UIViewController *parentViewController; //父viewController
@property(nonatomic, weak)APBToygerViewController *currentViewController; //当前viewController
@property(nonatomic, weak)UIView *currentView; //当前显示的界面
@property(nonatomic, copy)commandBlock bioCommandBlock; //对框架进行操作的block
@property(nonatomic, strong)APBToygerRemoteConfig * bisConfig; //bis下放的配置参数
@property(nonatomic, strong)APBToygerDataCenter * dataCenter; //行为日志
@property(nonatomic, copy)NSString *bisToken; //bisToken
@property(nonatomic, assign)NSInteger currentRetryCnt; //当前重试次数
@property(nonatomic, assign)BOOL soundStatus; //当前声音状态
//@property(nonatomic, assign)BOOL isLoginMode; //当前场景是否为登录场景
@property(nonatomic, assign)BOOL isMYBank; //是否是网商银行
@property(nonatomic, strong)DTFLogMonitor *monitor; //埋点
@property(nonatomic, weak) id<BioAuthTaskDelegate> delegate;
- (void)exitWithResult:(APBResultType)result failReason:(NSString *)failReason retCodeSub:(NSString *)retCodeSub retMessageSub:(NSString *)retMessageSub;
- (void)eventQuitWithCompletionCallback:(BioAuthExecCallback)callback;
/**
* 刷脸重试
*/
- (void)handleRetryActionWithScene:(NSString *)scene
buttonTitle:(NSString *)title
retryIncrement:(BOOL)retryIncrement;
/**
* 用户选择退出
*/
- (void)handleExitActionWithScene:(NSString *)scene
buttonTitle:(NSString *)title
exitReason:(APBResultType)reason
extAction:(APFAlertExtraAction)action;
/**
* 用户选择继续
*/
- (void)handleContinueActionWithScene:(NSString *)scene
buttonTitle:(NSString *)title
extaction:(APFAlertExtraAction)action;
/**
* 消除VC的方式,加菲和樱桃不同
*/
- (void)dismissViewControllerAnimated: (BOOL)flag completion:(void (^ __nullable)(void))completion;
@end
@@ -0,0 +1,28 @@
//
// APFCherryDetectTask.h
// APBToygerFacade
//
// Created by richard on 01/02/2018.
// Copyright © 2018 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <BioAuthEngine/AFEStatusBar.h>
#import <APBToygerFacade/APBToygerBaseTask.h>
#import <BioAuthEngine/BioAuthEngine.h>
#import <DTFUtility/CameraService.h>
#define kFaceCameraPreviewWidth 480
#define kFaceCameraPreviewHeight 640
#define kFaceAVCaptureSessionPreset AVCaptureSessionPreset640x480
@interface APBToygerCherryDetectTask : APBToygerBaseTask <DTFCameraServiceDelegate, DTFFaceViewDelegate, ToygerServiceInstanceDelegate>
@property (nonatomic, assign) BOOL photinusFlags;
@property (nonatomic, strong) DTFCameraService *cameraService;
@property (nonatomic, strong) id instance; //Toyger对象
@property (nonatomic, assign) BOOL useNativePhotinus;
- (void)onButtonCancel;
@end
@@ -0,0 +1,26 @@
//
// APFCherryUploadTask.h
// APFaceDetectBiz
//
// Created by yukun.tyk on 28/11/2016.
// Copyright © 2016 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <APBToygerFacade/APBToygerUploadTask.h>
#import <BioAuthEngine/APBToygerDataCenter.h>
typedef NS_ENUM(NSInteger, APBToygerRemoteCommand)
{
APBToyger_REMOTE_COMMAND_PASS = 1001, //比对通过
APBToyger_REMOTE_COMMAND_CONTINUE = 1002, //需要继续采集
APBToyger_REMOTE_COMMAND_FAIL = 2001, //比对失败
APBToyger_REMOTE_COMMAND_RETRY = 2002, //需要重试
};
@interface APBToygerCherryUploadTask : APBToygerUploadTask <APBToygerDataCenterDelegate>
- (APBToygerRemoteCommand)remoteCommandFromString:(NSString *)code;
@end
@@ -0,0 +1,36 @@
//
// APFaceFacade.h
// APFaceDetectBiz
//
// Created by 晗羽 on 8/25/16.
// Copyright © 2016 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <BioAuthEngine/IBioAuthFactor.h>
@interface APBToygerFacade : NSObject <IBioAuthFactor>
+(void)setTokenid:(NSString*)info;
+(NSString*)getTokenid;
@end
#import <APBToygerFacade/APBToygerCherryDetectTask.h>
#import <APBToygerFacade/APBToygerBaseTask.h>
#import <APBToygerFacade/APBToygerPresentTask.h>
#import <APBToygerFacade/APBToygerCherryUploadTask.h>
#import <APBToygerFacade/APBToygerUtils.h>
#import <APBToygerFacade/APBToygerUploadTask.h>
#import <APBToygerFacade/APBToygerFacadeDefine.h>
#import <DTFUtility/APBToygerRemoteConfig.h>
#import <BioAuthEngine/APBToygerBehavlogManager.h>
#import <BioAuthEngine/APBToygerDataCenter.h>
#import <APBToygerFacade/APBToygerViewController.h>
#import <UIKit/UIKit.h>
//! Project version number for APBToygerFacade.
FOUNDATION_EXPORT double APBToygerFacadeVersionNumber;
//! Project version string for APBToygerFacade.
FOUNDATION_EXPORT const unsigned char APBToygerFacadeVersionString[];
@@ -0,0 +1,130 @@
//
// APFCherryDefine.h
// APBToygerFacade
//
// Created by shouyi.www on 27/02/2017.
// Copyright © 2017 DTF. All rights reserved.
//
#ifndef APBToygerFacadeDefine_h
#define APBToygerFacadeDefine_h
static float normalized_distance(float current_value, float best_value, float range) {
return fabsf((current_value - best_value) / range);
}
//typedef struct toyger_status_evaluator_t {
// float pitch;
// float yaw;
// float width;
//
// float best_pitch;
// float best_yaw;
// float best_width;
// float pitch_range;
// float yaw_range;
// float width_range;
// float pitch_weight;
// float yaw_weight;
// float width_weight;
//
// toyger_status_evaluator_t(float pitch_ = -0.3, float pitch_range_ = 0.7, float best_pitch_ = 0, float pitch_weight_ = 1,
// float yaw_ = -0.6, float yaw_range_ = 0.6, float best_yaw_ = 0, float yaw_weight_ = 1,
// float width_ = 0.2, float width_range_ = 1.2, float best_width_ = 0.7, float width_weight_ = 1){
// pitch = pitch_;
// yaw = yaw_;
// width = width_;
// pitch_range = pitch_range_;
// yaw_range = yaw_range_;
// width_range = width_range_;
// best_pitch = best_pitch_;
// best_yaw = best_yaw_;
// best_width = best_width_;
// pitch_weight = pitch_weight_;
// yaw_weight = yaw_weight_;
// width_weight = width_weight_;
// }
//
// void reset(){
// pitch = -0.3;
// yaw = -0.6;
// width = 0.2;
// }
//
// void update(float pitch_, float yaw_, float width_) {
// pitch = pitch_;
// yaw = yaw_;
// width = width_;
// }
//
// float evaluateProgress(float pitch_, float yaw_, float width_){
// return
// (normalized_distance(pitch_, best_pitch, pitch_range) * pitch_weight +
// normalized_distance(yaw_, best_yaw, yaw_range) * yaw_weight +
// normalized_distance(width_, best_width, width_range) * width_weight) /
// (pitch_weight + yaw_weight + width_weight);
// }
//
// float evaluate(){
// return 1 -
// (normalized_distance(pitch, best_pitch, pitch_range) * pitch_weight +
// normalized_distance(yaw, best_yaw, yaw_range) * yaw_weight +
// normalized_distance(width, best_width, width_range) * width_weight) /
// (pitch_weight + yaw_weight + width_weight);
// }
//
//}ToygerStatusEvaluator;
typedef struct apbtoyger_tip_evaluator_t {
bool pose_end;
bool has_face;
bool did_blink;
bool pos_okay;
bool quality_okay;
bool under_exposure;
bool face_width_too_small;
bool face_width_too_big;
bool integrity_fail;
bool yaw_fail;
bool pitch_fail;
bool tremble_fail;
bool did_checkSeven;
int tip_timer_wait_cnt;
bool tip_show_switch;
int tip_message;
apbtoyger_tip_evaluator_t(){
reset();
}
void reset(){
has_face = false;
did_blink = false;
pos_okay = false;
under_exposure = false;
face_width_too_small = false;
integrity_fail = false;
pitch_fail = false;
face_width_too_big = false;
yaw_fail = false;
tremble_fail = false;
tip_timer_wait_cnt = 0;
tip_show_switch = true;
did_checkSeven = false;
quality_okay = false;
pose_end = false;
tip_message =0;
}
}APBToygerTipEvaluator;
//UI样式
typedef enum : NSUInteger {
APBToygerUIStyleFPPCherry = 991, //991 FPP樱桃(废弃)
APBToygerUIStyleCherry, //992 zFace樱桃
APBToygerUIStyleGarfield, //993 加菲
} APBToygerUIStyle;
#endif
@@ -0,0 +1,25 @@
//
// APFPresentTask.h
// APFaceDetectBiz
//
// Created by 晗羽 on 8/26/16.
// Copyright © 2016 DTF. All rights reserved.
//
#import <APBToygerFacade/APBToygerBaseTask.h>
#import <DTFUtility/CameraService.h>
#import <BioAuthEngine/DTFFaceViewProtocol.h>
/**
* @author Skye Ying, 16-08-26 13:08:04
*
* 新建VC,启动整个view
*/
@interface APBToygerPresentTask : APBToygerBaseTask
@property(nonatomic, strong) id<DTFFaceViewProtocol> faceView;
-(void) postCameraPresentwithCamera:(DTFCameraService *) cameraService;
-(void) presentAnimated: (BOOL)flag completion:(void (^ __nullable)(void))completion;
@end
@@ -0,0 +1,27 @@
//
// APBToygerUploadTask.h
// APBToygerFacade
//
// Created by Dan Cong on 29/1/2018.
// Copyright © 2018 DTF. All rights reserved.
//
#import <APBToygerFacade/APBToygerBaseTask.h>
/**
上传基类,用于下沉多种UI(樱桃和加菲)下通用的逻辑
*/
@interface APBToygerUploadTask : APBToygerBaseTask
- (void)uploadImage;
- (void)didFinishUploadWithSuccess:(BOOL)success
retCode:(NSString *)retCode
retMessage:(NSString *)msg
extInfo:(NSString *)ext;
- (void)handleFailWithRetCodeSub:(NSString *)retCodeSub retMessageSub:(NSString *)retMessageSub;
- (void)requestAgain;
@end
@@ -0,0 +1,65 @@
//
// APFUtils.h
// APFaceDetectBiz
//
// Created by 晗羽 on 8/25/16.
// Copyright © 2016 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <APBToygerFacade/APBToygerFacadeDefine.h>
//#import "APFaceDetectBizFacade.h"
//主线程同步操作
#define SYNC_MAINTHREAD_BEGIN_APBT [APBToygerUtils APBToygerMainThread:^{
#define SYNC_MAINTHREAD_END_APBT }];
#define LOCK(locker, ...) dispatch_semaphore_wait(locker, DISPATCH_TIME_FOREVER); \
__VA_ARGS__; \
dispatch_semaphore_signal(locker);
@class MGLivenessDetectionFrameEncodedData;
@interface APBToygerUtils : NSObject
+ (void)APBToygerMainThread:(dispatch_block_t)block;
+ (NSString *)getTextContentforKey:(NSString*)keyName;
+ (NSString *)localizedTextForKey:(NSString *)key;
+ (NSBundle *)getBundle;
+ (int)getCodefrom:(NSString *)bisToken withLength:(int)codeLen;
//+ (NSString *)getActionNoticeByActionType:(APFLiveActionType) actionType;
//检查文件是否存在
+ (BOOL) checkFileunderPath:(NSString *) filePath;
//写入文件
//如果文件存在,不重写,返回失败。
//如果文件不再在,写入,返回写入结果
+ (BOOL) writeFileunderPath:(NSString *) filePath;
//删除文件
+ (BOOL) removeFileunderPath:(NSString *) filePath;
//随机文件名
+ (NSString *)randomString:(NSInteger)len;
+ (NSString *)localizedStringForKey:(NSString *)key;
+ (UIImage *)loadImageFromBundleNamed:(NSString *)imageName;
+ (UIWindow *)lastWindow;
+ (APBToygerTips *)toygerTipsConfig;
+ (BOOL)useElemeEquipmentUI:(APBToygerRemoteConfig *)config;
+ (BOOL)useNearFarLiveness:(APBToygerRemoteConfig *)config;
@end
@@ -0,0 +1,31 @@
//
// APFViewController.h
// APFaceDetectBiz
//
// Created by 晗羽 on 8/25/16.
// Copyright © 2016 DTF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <ToygerService/ToygerService.h>
#import <BioAuthEngine/DTFFaceViewProtocol.h>
#import <BioAuthEngine/DTFBaseViewController.h>
@interface APBToygerViewController : DTFBaseViewController
@property(nonatomic, strong) id<DTFFaceViewProtocol> faceView;
- (void)startFaceRecognition:(AVCaptureVideoPreviewLayer *)layer;
- (void)handleFaceStateChange:(ToygerMessage)state
stateTips:(NSString *)tips
actionGuideType:(ToygerStaticMessage)guideType
actionGuide:(NSString *)guide
progress:(CGFloat)progress
extInfo:(NSDictionary *)extInfo;
- (void)faceDectectComplete;
- (void)setPhotinusColor:(UIColor *)color;
- (void)showBlur:(UIImage *)image;
@end
@@ -0,0 +1,6 @@
framework module APBToygerFacade {
umbrella header "APBToygerFacade.h"
export *
module * { export * }
}