类介绍
DFActionLivenessDetector
DFActionLivenessDetector 用于构造对输入图像数据进行检测的对象。
初始化
/**
 *  初始化方法
 *
 *  @param dDurationPerModel    每个动作模块的超时时间 0代表无超时
 *  @param strBundlePath        资源文件路径
 *  @param strLicensePath       授权文件路径
 *
 *  @return detector instance
 */
- (instancetype)initWithDuration:(double)dDurationPerModel
             resourcesBundlePath:(NSString *)strBundlePath
                     licensePath:(NSString *)strLicensePath;
参数设置
/**
 *  设置参数
 *
 *  @param delegate     回调代理
 *  @param queue        回调队列
 *  @param arrDetection 动作序列, 例: @[@(LIVE_HOLDSTILL), @(LIVE_BLINK), @(LIVE_MOUTH), @(LIVE_NOD), @(LIVE_YAW)], 参考 DFLivenessEnumType.h
 *  @param arrThreshold 阈值, 例: @[@(0.7), @(0.7), @(0.7), @(0.7), @(0.7)]
 */
- (void)setDelegate:(id <DFActionLivenessDetectorDelegate>)delegate
      callBackQueue:(dispatch_queue_t)queue
  detectionSequence:(NSArray *)arrDetection
 detectionThreshold:(NSArray *)arrThreshold;
/**
 设置参数
 @param region 人脸检测区域
 @param faceMaxSizeRatio 待检测人脸大小占相机返回buffer图片的最大比例
 */
- (void)setFaceDetectedRegion:(CGRect)region faceMaxSizeRatio:(float)faceMaxSizeRatio;
/**
 *
 *  @param iOutputType 输出类型, 目前仅支持 LIVE_OUTPUT_MULTI_IMAGE
 */
- (void)setOutputType:(LivefaceOutputType)iOutputType;
检测
/**
 *  持续检测
 *
 *  @param sampleBuffer    相机回调sampleBuffer
 *  @param faceOrientation 人脸方向
 */
- (void)trackAndDetectWithCMSampleBuffer:(CMSampleBufferRef)sampleBuffer
                         faceOrientation:(LivefaceOrientation)faceOrientation;
开始检测
/**
 *  开始检测
 */
- (void)startDetection;
取消检测
/**
 *  取消检测
 */
- (void)cancelDetection;
版本号
/**
 *  获取版本号
 *
 *  @return SDK Version
 */
+ (NSString *)getSDKVersion;
DFActionLivenessDetectorDelegate
检测回调
/**
 *  动作活体检测回调
 */
@protocol DFActionLivenessDetectorDelegate <NSObject>
@optional
/**
 *  每个动作开始检测的回调
 *
 *  @param iDetectionType  当前检测动作类型
 *  @param iDetectionIndex 当前检测动作index.
 */
- (void)livenessDidStartDetectionWithDetectionType:(LivefaceDetectionType)iDetectionType
                                    detectionIndex:(int)iDetectionIndex;
/**
 *  每帧回调, 当设置超时时间后返回当前动作已经检测的时长
 *
 *  @param dPast             Current module detects elapsed time
 *  @param dDurationPerModel Current module detection total time
 */
- (void)livenessTimeDidPast:(double)dPast
           durationPerModel:(double)dDurationPerModel;
/** 帧率 */
- (void)videoFrameRate:(int)rate;
/**
 每帧回调
 @param faceCount 人脸数
 @param faceRectStatus 人脸状态
 @param iDetectionType  当前检测动作类型
 */
- (void)livenessDectectingFaceCount:(int)faceCount faceRectStatus:(LivefaceRectStatus)faceRectStatus detectionType:(LivefaceDetectionType)iDetectionType;
@required
动作活体检测成功
/**
 *  成功回调
 *
 *  @param data       检测成功后的加密数据
 *  @param arrDFImage 图片 参考 DFImage.h
 *  @param dfVideoData 视频data(暂为nil)
 */
- (void)livenessDidSuccessfulGetData:(nullable NSData *)data
                            dfImages:(nullable NSArray *)arrDFImage
                         dfVideoData:(nullable NSData *)dfVideoData;
动作活体检测失败
/**
 *  失败回调
 *
 *  @param iErrorType      失败类型
 *  @param iDetectionType  动作类型
 *  @param iDetectionIndex 动作index
 *  @param data            加密文件(nil)
 *  @param arrDFImage      图片 参考DFImage.h
 *  @param dfVideoData     视频data(暂为nil)
 */
- (void)livenessDidFailWithErrorType:(LivefaceErrorType)iErrorType
                       detectionType:(LivefaceDetectionType)iDetectionType
                      detectionIndex:(int)iDetectionIndex
                                data:(nullable NSData *)data
                            dfImages:(nullable NSArray *)arrDFImage
                         dfVideoData:(nullable NSData *)dfVideoData;
动作活体取消回调
/**
 *  取消回调
 *
 *  @param iDetectionType  动作类型
 *  @param iDetectionIndex 动作index
 */
- (void)livenessDidCancelWithDetectionType:(LivefaceDetectionType)iDetectionType
                            detectionIndex:(int)iDetectionIndex;
LivefaceErrorType
错误类型枚举
| 类型 | 
说明 | 
| LIVENESS_INIT_FAILD | 
初始化失败 | 
| LIVENESS_CAMERA_ERROR | 
相机权限错误 | 
| LIVENESS_FACE_CHANGED | 
人脸丢失或变更 | 
| LIVENESS_TIMEOUT | 
动作超时 | 
| LIVENESS_WILL_RESIGN_ACTIVE | 
应用进入后台 | 
| LIVENESS_INTERNAL_ERROR | 
内部错误 | 
| LIVENESS_BUNDLEID_ERROR | 
包名错误 | 
| LIVENESS_AUTH_EXPIRE | 
授权文件错误 | 
| LIVENESS_SEQUENCE_ERROR | 
动作序列错误 | 
| LIVENESS_FACE_MORE_THAN_ONE_ERROR | 
多人脸错误 | 
LivefaceDetectionType
检测动作类型枚举
| 类型 | 
说明 | 
| LIVE_BLINK | 
眨眼 | 
| LIVE_MOUTH | 
张嘴 | 
| LIVE_YAW | 
摇头 | 
| LIVE_NOD | 
点头 | 
| LIVE_HOLDSTILL | 
静默 | 
LivefaceOrientation
人脸方向枚举
| 类型 | 
说明 | 
| LIVE_FACE_UP | 
上 | 
| LIVE_FACE_LEFT | 
左 | 
| LIVE_FACE_DOWN | 
下 | 
| LIVE_FACE_RIGHT | 
右 | 
LivefaceOutputType
输出类型枚举
| 类型 | 
说明 | 
| LIVE_OUTPUT_MULTI_IMAGE | 
多图 | 
LivefaceRectStatus
人脸状态枚举
| 类型 | 
说明 | 
| LivefaceRectStatusNone | 
无 | 
| LivefaceRectStatusSuccess | 
成功 | 
| LivefaceRectStatusLarge | 
过大 |