SSFaceProcessManager.h
5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//
// SSFaceVideoCaptureDevice.h
// SSDKLib
//
// Created by Gong,Jialiang on 2021/4/27.
// Copyright © 2021 Baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import "SSFaceSDK.h"
/**
* 流程返回结果类型
*/
typedef NS_ENUM(NSInteger, SSFaceProcessStatus) {
SSFaceProcessStatusSuccess = 1, // 成功
SSFaceProcessStatusIsRunning = -101, // 正在采集图像
SSFaceProcessStatusCancel = -102, // 取消
SSFaceProcessStatusSDKNotInit = -103, // SDK未初始化
SSFaceProcessStatusResultFail = -301, // 构建数据异常
SSFaceProcessStatusCameraError = -302, // 没有授权镜头
SSFaceProcessStatusVideoRecordingFail = -303, // 视频录制失败
SSFaceProcessStatusCropImageError = -305, // 抠图失败
SSFaceProcessStatusEncryptFail = -311, // 加密失败
SSFaceProcessStatusSystemVideoFail = -313, // 视频录制失败-系统异常
SSFaceProcessStatusTimeout = -401, // 超时
SSFaceProcessStatusColorMatchFailed = -402, // 炫彩色彩错误
SSFaceProcessStatusVideoColorScoreFailed = -403, // 炫彩分数错误
SSFaceProcessStatusDetectSilentNoPass = -404, // 静默活体分数未通过
SSFaceProcessStatusLivenessSilentNoPass = -405, // 动作活体分数未通过
};
/**
* 活体检测过程中,返回活体总数,当前成功个数,当前活体类型
*/
typedef void (^LivenessProcess) (float numberOfLiveness, float numberOfSuccess, LivenessActionType currenActionType);
@protocol SSFaceProcessDelegate <NSObject>
- (void)onBegin;
- (void)onBeginCollectFaceInfo;
- (void)onLivenessActionWithCode:(LivenessRemindCode)code imageInfo:(NSDictionary *)imageInfo faceInfo:(FaceInfo *)faceInfo;
- (void)onDetectionActionWithCode:(DetectRemindCode)code imageInfo:(NSDictionary *)imageInfo faceInfo:(FaceInfo *)faceInfo;
- (void)onColorfulActionWithCode:(ColorRemindCode)code imageInfo:(NSDictionary *)imageInfo faceInfo:(FaceInfo *)faceInfo;
- (void)onBeginBuildData;
- (void)onEnd:(SSFaceProcessStatus)status result:(NSDictionary *)result;
- (void)captureOutputSampleBuffer:(UIImage *)image;
@end
__attribute__((visibility("default")))
@interface SSFaceProcessManager : NSObject
// 图像返回帧处理代理
@property (nonatomic, weak) id<SSFaceProcessDelegate> delegate;
// 采集流程运行状态
@property (nonatomic, assign, readonly) BOOL runningStatus;
// AVCaptureSessionPreset类型枚举,支持低版本所以使用NSString
@property (nonatomic, copy) NSString *sessionPresent;
// 采集图像区域
@property (nonatomic, assign) CGRect previewRect;
// 探测区域
@property (nonatomic, assign) CGRect detectRect;
// 是否开启声音提醒
@property (nonatomic, assign) BOOL enableSound;
// 设置使用镜头,前置/后置,默认前置
@property (nonatomic, assign) AVCaptureDevicePosition devicePosition;
// 设置录像结果是否镜像翻转,默认翻转
@property (nonatomic, assign) BOOL videoMirrored;
// 返回图片类型
@property (nonatomic, assign) SSFaceProcessImageType outputImageType;
// 输出图片数量,默认1(支持炫彩流程)
@property (nonatomic, assign) NSInteger successImageCount;
// BDFaceDetectionTypeColorfulLiveness流程中是否开启动作活体
@property (nonatomic, assign) BOOL enableLivenessInColorfulFlow;
// 录制长度,默认60s,范围1~60
@property (nonatomic, assign) NSInteger recordingDuration;
// iOS13及以下版本,是否开启自定义配置,默认NO
@property (nonatomic, assign) BOOL enableUseDefinedCameraL13;
// 是否允许录制的视频文件不存在,默认false
@property (nonatomic, assign) BOOL enableVideoFileEmpty;
// 是否支持保存检测异常时的视频文件
@property (nonatomic, assign) BOOL enableFaceFailVideo;
+ (instancetype)sharedInstance;
- (void)connectPreviewLayer:(AVCaptureVideoPreviewLayer*)pLayer;
/**
* 创建视频录制参数
* @param enableVideoSound 是否开启声音录制
* @param videoFileName 视频文件名称
* @param imageWidth 视频宽度
* @param imageHeight 视频高度
* */
- (NSDictionary *)createVideoRecordParametersWithEnableVideoSound:(BOOL)enableVideoSound
videoFileName:(NSString *)videoFileName
imageWidth:(NSUInteger)imageWidth
imageHeight:(NSUInteger)imageHeight;
/**
* 开始当前人脸校验流程,供视频录制时传入参数使用
* @param flowType 操作流程,人脸采集、人脸活体、炫彩
* @param videoParameters 视频参数
* @param vc 展现的UIViewController
*/
- (void)startFaceProcessWithFaceFlow:(SSFaceProcessType)flowType videoParameters:(NSDictionary *)videoParameters viewController:(UIViewController *)vc;
/**
* 取消当前人脸校验流程
*/
- (void)cancelFaceProcess;
/**
* 开始视频录制
*/
- (void)startRecordingVideo;
/**
* 活体检测过程中,返回活体总数,当前成功个数,当前活体类型
*/
-(void)livenessProcessHandler:(LivenessProcess)process;
/**
* 返回无黑边的方法
* @param array 活体动作数组
* @param order 是否顺序执行
* @param numberOfLiveness 活体动作个数
*/
- (void)livenesswithList:(NSArray *)array order:(BOOL)order numberOfLiveness:(NSInteger)numberOfLiveness;
/**
* 设置炫彩活体颜色顺序
* @param colorGroup 颜色顺序,如“RGB”
*/
- (void)setColorLivenessColors:(NSString *)colorGroup;
@end