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,58 @@
//
// DTFOCRCaptureView.h
// OCRDetectSDKForTech
//
// Created by jiangzhipeng on 2025/1/6.
// Copyright © 2025 Alipay. All rights reserved.
// 拍照页面。提供拍照功能
#import "DTFOCRComponentView.h"
typedef NS_ENUM(NSUInteger, DTFOCRCaptureViewStyle) {
DTFOCRCaptureViewStylePrepare,//准备拍照
DTFOCRCaptureViewStyleComfirm,//确认照片
};
NS_ASSUME_NONNULL_BEGIN
@interface DTFOCRCaptureView : DTFOCRComponentView
@property (nonatomic, strong) UILabel *desLabel;//描述文字
@property (nonatomic, strong) UIButton *retryButton;//重试按钮
@property (nonatomic, strong) UIButton *completeButton;//完成按钮
@property (nonatomic, strong) UIButton *takeButton;//拍照按钮
@property (nonatomic, strong) UIButton *closeButton;//关闭按钮
@property (nonatomic, strong) UIButton *flashButton;//闪光灯切换按钮
@property (nonatomic, strong) UIImageView *focusImageView;//取景框图片
@property (nonatomic, copy) void(^closeBlock)();//关闭界面回调
@property (nonatomic, copy) void(^confirmImageBlock)(UIImage *anImage);//确认图片回调
@property(nonatomic, assign) CGRect cropRect;//设置取景框尺寸,相对previewLayer的坐标
@property(nonatomic, strong) AVCaptureVideoPreviewLayer *previewLayer;//预览图层
@property (nonatomic, strong, nullable) UIImageView *previewImageView;//照片预览imageView
@property(nonatomic, strong) CAShapeLayer *fillLayer; //单黑色背景
//获取真实的裁剪尺寸,默认返回cropRect
- (CGRect)realCropRect;
//设置取景框大小
- (void)setFocusRect:(CGRect)rect;
//更新UI
- (void)updateUI:(BOOL)isFront;
//切换当前view的样式
- (void)changeToStyle:(DTFOCRCaptureViewStyle)style;
//更新预览图层,
- (void)updatePreviewLayer:(AVCaptureVideoPreviewLayer *)layer;
//拍照
- (void)takePhoto;
//确认照片
- (void)confirm;
//关闭
- (void)close;
//重拍
- (void)retake;
//切换闪光灯状态
- (void)switchFlashMode;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,27 @@
//
// DTFOCRComponentView.h
// OCRDetectSDKForTech
//
// Created by jiangzhipeng on 2025/1/6.
// Copyright © 2025 Alipay. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <BioAuthEngine/DTFOCRViewProtocol.h>
#import <DTFUtility/DTFLanguageCustomConfig.h>
@class DTFOCRComponentView;
NS_ASSUME_NONNULL_BEGIN
@interface DTFOCRComponentView : UIView
//代理操作对象
@property (nonatomic, weak) id <DTFOCRViewDelegate> delegate;
//初始化UI
- (void)prepareUI;
//获取docConfig对象
- (DTFLanguageCustomDocConfig *)docConfig;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,143 @@
//
// DTFOCRInfoView.h
// OCRDetectSDKForTech
//
// Created by jiangzhipeng on 2025/1/6.
// Copyright © 2025 Alipay. All rights reserved.
//
#import "DTFOCRComponentView.h"
#import <BioAuthEngine/DTFOCRViewProtocol.h>
#import "DetectImageForOCRButton.h"
#import "DetectImageForOCRScrollView.h"
#import "DTFOCRCaptureView.h"
#import "DTFOCRVerifyErrorHintView.h"
#import "DTFOCRVerifyResultModel.h"
typedef NS_ENUM(NSUInteger, DTFOCRVerify) {
DTFOCRVerifyFront,//认证身份证正面
DTFOCRVerifyBack,//认证身份证反面
DTFOCRVerifyTransition,//认证完成,过渡。准备跳转到人脸
};
typedef NS_ENUM(NSUInteger, DTFOCRVerifyAlertStyle) {
DTFOCRVerifyAlertStyleOCRFailed,//OCR识别失败
DTFOCRVerifyAlertStyleExit,//退出
DTFOCRVerifyAlertStyleInputError,//身份信息输入错误
DTFOCRVerifyAlertStyleCameraAccess,//相机权限
DTFOCRVerifyAlertStyleAlbumAccess,//相册权限
};
NS_ASSUME_NONNULL_BEGIN
//标题
@interface DTFOCRInfoTitleView : UIView
@property (nonatomic, strong) UIButton *closeButton;//关闭按钮
@property (nonatomic, copy) void(^closeButtonClickedCallback)();
- (void)prepareUI;//在init方法时执行,创建并添加好子view
- (CGSize)viewSize;//返回view的大小
@end
//progressView
@interface DTFOCRInfoProgressView : UIView
@property(nonatomic, strong) UIView *frontToBackVerifyLine;//正面认证到反面认证连接线条
@property(nonatomic, strong) UIView *backToLivenessVerifyLine; //反面认证到活体认证连接线条
@property(nonatomic, strong) UILabel *frontSerialNumberLabel;//正面认证序列号1
@property(nonatomic, strong) UILabel *backSerialNumberLabel;//反面认证序列号2
@property(nonatomic, strong) UILabel *livenessSerialNumberLabel;//活体认证序列号3
@property(nonatomic, strong) UIImageView *frontVerifyStatusImageView;//红点
@property(nonatomic, strong) UIImageView *backVerifyStatusImageView;//第二步红点
@property(nonatomic, strong) UIImageView *livenessVerifyStatusImageView;//第三步红点
@property(nonatomic, strong) UILabel *frontVerifyTipsLabel; //进度条下面的字
@property(nonatomic, strong) UILabel *backVerifyTipsLabel;//进度条下面的字
@property(nonatomic, strong) UILabel *livenessVerifyTipsLabel;//进度条下面的字
- (void)prepareUI;//在init方法时执行,创建并添加好子view
- (CGSize)viewSize;//返回view的大小
@end
//scanview
@interface DTFOCRInfoScanView : UIView
@property(nonatomic, strong) UILabel *infoTipsLabel;//描述信息
@property(nonatomic, strong) UIImageView *baseImageView;//拍摄提示图片或拍摄结果图片展示view
@property(nonatomic, strong) UIButton *takeRequestButton;//拍照要求按钮
@property(nonatomic, strong) UILabel *bottomTipsLabel;//详细描述信息,如:“证件人像面”
@property(nonatomic, strong) UIImageView *takeImageView;//点击会触发拍照
@property (nonatomic, copy) void(^requestButtonClickedCallback)();//拍照要求按钮被点击回调
@property (nonatomic, copy) void(^captureButtonClickedCallback)(void(^completeBlock)());//拍照按钮点击回调
- (void)prepareUI;//在init方法时执行,创建并添加好子view
- (CGSize)viewSize;//返回view的大小
@end
//confirmview
@interface DTFOCRInfoConfirmView : UIView
@property(nonatomic, strong) UITextField *idTextField;//id输入框
@property(nonatomic, strong) UITextField *nameTextField;//姓名输入框
@property(nonatomic, strong) UIView *nameView;//姓名容器
@property(nonatomic, strong) UIView *idView;//ID容器
@property(nonatomic, strong) UIView *noticeContainer; //提醒内容容器
@property(nonatomic, strong) UILabel *noticeLabel;//提醒文字
@property(nonatomic, strong) UIImageView *noticeHintImageView;//提醒图标
@property(nonatomic, strong) UILabel *nameLabel;// 名字标签
@property(nonatomic, strong) UILabel *idLabel;//ID标签
- (void)prepareUI;//在init方法时执行,创建并添加好子view
- (CGSize)viewSize;//返回view的大小
@end
@interface DTFOCRInfoView : DTFOCRComponentView <DTFOCRViewProtocol>
//titleView
@property(nonatomic, strong) DTFOCRInfoTitleView *titleContentView;
//progressView
@property(nonatomic, strong) DTFOCRInfoProgressView *progressContentView;
//scanview
@property(nonatomic, strong) DTFOCRInfoScanView *scanContentView;;
//confirmview
@property(nonatomic, strong) DTFOCRInfoConfirmView *confirmView;
//下一步按钮
@property(nonatomic, strong) DetectImageForOCRButton *nextButton;
//下一步按钮容器
@property(nonatomic, strong) UIView *nextButtonView;
//滚动视图,scanview和confirmview的容器
@property(nonatomic, strong) UIScrollView *contentScrollView;
//拍照View
@property (nonatomic, strong) DTFOCRCaptureView *captureView;
/// 错误提示view
@property (nonatomic, strong) DTFOCRVerifyErrorHintView *tipsErrorView;
//当前认证进度
@property (nonatomic, assign) DTFOCRVerify currentVerify;
//切换到下一个子进度,DTFOCRVerifyFront-DTFOCRVerifyBack-DTFOCRVerifyTransition调整UI
- (void)updateUIWhenEnterNextVerify;
//更新信息,ocr认证结果
- (void)updateVerifyInfo:(DTFOCRVerifyResultDetailModel *)verifyInfo captureImage:(UIImage *)anImage;
//开始loading动画
- (void)showLoading;
//停止loading动画
- (void)hideLoading;
//显示拍照页面
- (void)showCaptureView:(void (^ __nullable)(void))animateCompletion;
- (void)dismissCaptureView:(void (^ __nullable)(void))animateCompletion;
//显示拍照提示
- (void)showCaptureTips;
//显示图片OCR认证失败提示(图片不符合规范导致)
- (void)showVerifyErrorHint;
//身份证正面信息确认有问题时弹窗,如身份证姓名号码不合规范
- (void)showFrontVerifyInfoErrorToast:(NSString *)errorMsg;
//显示alert提示
- (void)showAlertWithTitle:(NSString *)title message:(nullable NSString *)message alertStyle:(DTFOCRVerifyAlertStyle)style;
//关闭按钮事件
- (void)close;
//下一步按钮事件,如正面验证完成进反面验证
- (NSError *)next;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,44 @@
//
// DTFOCRVerifyErrorHintView.h
// OCRDetectSDKForTech
//
// Created by jiangzhipeng on 2025/1/6.
// Copyright © 2025 Alipay. All rights reserved.
//
#import "DTFOCRComponentView.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, DTFOCRVerifyErrorHintViewStyle) {
DTFOCRVerifyErrorHintViewStyleTips,//仅拍照提示
DTFOCRVerifyErrorHintViewStyleError,//拍照提示 + 跳转拍照
};
@interface DTFOCRVerifyErrorHintView : DTFOCRComponentView
@property (nonatomic, strong) UIView *containerView;//展示内容view
//头部
@property (nonatomic, strong) UILabel *titleLabel;//标题label
@property (nonatomic, strong) UIButton *closeButton;//关闭按钮
@property (nonatomic, strong) UILabel *errorLabel;//错误文本
@property (nonatomic, strong) UILabel *hintLabel;//错误提示文本
@property (nonatomic, strong) UIView *footerDividingLine;//分割线
@property (nonatomic, strong) UIButton *retakeButton;//重拍按钮
@property (nonatomic, strong) UIImageView *baseImageView;//底图
//事件回调
@property (nonatomic, copy) void (^closeActionBlock)();
@property (nonatomic, copy) void (^retakeActionBlock)();
//更新UI样式
- (void)updateContent:(DTFOCRVerifyErrorHintViewStyle)style;
- (void)updateContent:(DTFOCRVerifyErrorHintViewStyle)state title:(NSString *)title;
//关闭界面
- (void)close;
//重拍
- (void)retake;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,48 @@
//
// DTFOCRVerifyResultModel.h
// OCRDetectSDKForTech
//
// Created by jiangzhipeng on 2025/2/12.
// Copyright © 2025 Alipay. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface DTFOCRVerifyResultDetailModel : NSObject
@property (nonatomic, copy) NSString *CertName;//姓名
@property (nonatomic, copy) NSString *CertNo;//身份证号
@property (nonatomic, copy) NSString *NowDate;//当前日期
@property (nonatomic, copy) NSString *EndDate;//身份证有效截止日志
@property (nonatomic, copy) NSString *StartDate;//身份证有效开始日期
/// 裁剪区域 高度
@property (nonatomic, assign) CGFloat cardHeight;
/// 裁剪区域 左边距离
@property (nonatomic, assign) CGFloat cardLeft;
/// 裁剪区域 顶部距离
@property (nonatomic, assign) CGFloat cardTop;
/// 裁剪区域 宽度
@property (nonatomic, assign) CGFloat cardWidth;
/// 是否有裁剪区域信息
- (BOOL)isHaveCardCropInfo;
@end
@interface DTFOCRVerifyResultModel : NSObject
@property (nonatomic, copy) NSString *RetCode;//信息码
@property (nonatomic, copy) NSString *RetCodeSub;//信息z码
@property (nonatomic, copy) NSString *RetMessageSub;//信息返回值
@property (nonatomic, strong) DTFOCRVerifyResultDetailModel *OcrInfo;//ocr识别信息
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,21 @@
//
// DetectImageForOCRButton.h
// DTFIdentityManager
//
// Created by 053508 on 2020/7/7.
// Copyright © 2020 DTF. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface DetectImageForOCRButton : UIButton
+(NSString *) fileFromPath:(NSString*)fileName;
-(void)setBackgroundColorWithColor:(UIColor*)color forState:(UIControlState)state;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,17 @@
//
// DetectImageForOCRScrollView.h
// DTFIdentityManager
//
// Created by 053508 on 2020/6/28.
// Copyright © 2020 DTF. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface DetectImageForOCRScrollView : UIScrollView
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,27 @@
//
// ToygerOCRViewController.h
// OCRDetectSDKForTech
//
// Created by jiangzhipeng on 2025/1/3.
// Copyright © 2025 Alipay. All rights reserved.
// OCR UI自定义容器
#import <UIKit/UIKit.h>
#import <BioAuthEngine/DTFOCRViewProtocol.h>
#import <BioAuthEngine/DTFUICustom.h>
NS_ASSUME_NONNULL_BEGIN
@class ZimRpcManager;
@interface ToygerOCRViewController : UIViewController
@property (nonatomic, strong) id<DTFOCRViewProtocol> ocrView;
@property (nonatomic, copy) NSString *certifyId;
@property (nonatomic, strong) ZimRpcManager * rpcManager;
@property (nonatomic, copy) void(^OCRDetectBlock)(BOOL success,NSObject *result);//回调
@property (nonatomic, assign) BOOL isClose;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,20 @@
//
// ZimAliCloudOCRResponse.h
// DTFIdentityManager
//
// Created by 053508 on 2020/6/22.
// Copyright © 2020 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ZimOCRResponse.h"
NS_ASSUME_NONNULL_BEGIN
@interface ZimAliCloudOCRResponse : NSObject
@property(nonatomic,strong)ZimOCRResponse *ResultObject;
@property(nonatomic,strong)NSString * RequestId;
@property(nonatomic,strong)NSString * Code;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,25 @@
//
// ZimOCRForTechResponse.h
// DTFIdentityManager
//
// Created by 053508 on 2020/8/26.
// Copyright © 2020 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZimOCRForTechResponse : NSObject
@property (nonatomic,strong) NSString* zimId;
@property (nonatomic,strong) NSString* side;
@property (nonatomic,strong) NSString* ocrInfo;
@property (nonatomic,strong) NSString* retCodeSub;
@property (nonatomic,strong) NSString* retMessageSub;
@property (nonatomic,strong) NSString* externInfo;
@property (nonatomic,strong) NSString* retCode;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,23 @@
//
// ZimOCRRequest.h
// DTFIdentityManager
//
// Created by 053508 on 2020/8/26.
// Copyright © 2020 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZimOCRRequest : NSObject
@property (nonatomic,strong)NSString *zimId;
@property (nonatomic,strong)NSString *dataType; //数据类型:OSS_ADDR/BASE64_JPG
@property (nonatomic,strong)NSString *dataContext;
@property (nonatomic,strong)NSString *side;/*face: 身份证正面 back: 身份证反面 缺省值是:face*/
@property (nonatomic,strong)NSString *externParam; //扩展信息,预留字段,Map的json格式
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,23 @@
//
// ZimOCRResponse.h
// DTFIdentityManager
//
// Created by 053508 on 2020/6/22.
// Copyright © 2020 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZimOCRResponse : NSObject
@property (nonatomic,strong) NSString* RetCode;//SInt32 productRetCode ;
@property (nonatomic,strong) NSDictionary* OcrInfo;//extParams ;
@property (nonatomic,strong) NSString* RetCodeSub;//retCodeSub ;
@property (nonatomic,strong) NSString* RetMessageSub;//retMessageSub ;
+ (Class)OcrInfoElementClass;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,22 @@
//
// ZimOCRVerifyResult.h
// DTFIdentityManager
//
// Created by 053508 on 2020/6/23.
// Copyright © 2020 DTF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ZimOCRVerifyResult : NSObject
@property (nonatomic,strong) NSString* RetCode;//SInt32 productRetCode ;
@property (nonatomic,strong) NSString* nameString;
@property (nonatomic,strong) NSString* idString;
@property (nonatomic,strong) NSString* startTime;
@property (nonatomic,strong) NSString* endTime;
@property (nonatomic,strong) NSString* RetCodeSub;//retCodeSub ;
@property (nonatomic,strong) NSString* RetMessageSub;//retMessageSub ;
@property (nonatomic,assign) BOOL abnormalDismiss;
@end