LFLivenessEnumType
LFLivenessEnumType类说明了活体检测所用到的枚举类型。
typedef NS_ENUM(NSInteger, LivefaceErrorType)
活体检测失败类型。
类型 | 说明 |
---|---|
LIVENES_INIT_FAILD | 算法SDK初始化失败 |
LIVENESS_CAMERA_ERROR | 相机权限获取失败 |
LIVENESS_TOKEN_INVALID | token验证未通过,无效token |
LIVENESS_TOKEN_UNBOUND | token验证未通过,bundle_id未绑定 |
LIVENESS_TOKEN_ERROR | token验证失败 |
LIVENESS_CAMERA_ERROR | 相机权限获取失败 |
LIVENESS_FACE_CHANGED | 人脸变更 |
LIVENESS_TIMEOUT | 检测动作超时 |
LIVENESS_WILL_RESIGN_ACTIVE | 应用即将被挂起(进入后台) |
LIVENESS_INTERNAL_ERROR | 内部错误 |
LIVENESS_OTHER_ERROR | 其他错误 |
LIVENESS_FACE_CHANGED_WAY | 中途人脸变更 |
示例代码:
- (void)livenessDidFailWithErrorType:(LivefaceErrorType)iErrorType detectionType:(LivefaceDetectionType)iDetectionType detectionIndex:(int)iDetectionIndex data:(NSData *)data lfImages:(NSArray *)arrLFImage lfVideoData:(NSData *)lfVideoData
{
LFMultipleLivenessError iLFMultipleError = 0;
switch (iErrorType) {
case LIVENESS_INIT_FAILD:
{
iLFMultipleError = LFMultipleLivenessInitFaild;
}
break;
case LIVENESS_TOKEN_INVALID:
{
iLFMultipleError = LFMultipleLivenessTokenInvalid;
}
break;
case LIVENESS_TOKEN_UNBOUND:
{
iLFMultipleError = LFMultipleLivenessTokenUnBound;
}
break;
case LIVENESS_TOKEN_ERROR:
{
iLFMultipleError = LFMultipleLivenessTokenError;
}
break;
case LIVENESS_CAMERA_ERROR:
{
iLFMultipleError = LFMultipleLivenessCameraError;
}
break;
case LIVENESS_FACE_CHANGED:
{
iLFMultipleError = LFMultipleLivenessFaceChanged;
}
break;
case LIVENESS_FACE_CHANGED_WAY:
{
iLFMultipleError = LFMultipleLivenessFaceChangedWay;
}
break;
case LIVENESS_INTERNAL_ERROR:
{
iLFMultipleError = LFMultipleLivenessInternalError;
}
break;
case LIVENESS_TIMEOUT:
{
iLFMultipleError = LFMultipleLivenessTimeOut;
}
break;
case LIVENESS_WILL_RESIGN_ACTIVE:
{
iLFMultipleError = LFMultipleLivenessWillResignActive;
}
break;
case LINENESS_OTHER_ERROR:{
iLFMultipleError = LFMultipleLivenessOtherError;
}
break;
default:
break;
}
//第一个动作跟丢不弹框
if (iLFMultipleError == LFMultipleLivenessFaceChanged && iDetectionType == LFDETECTION_NONE) {
[self restart];
return;
}
if (self.delegate && [self.delegate respondsToSelector:@selector(multiLivenessDidFailWithController:errorType:DetectionType:DetectionIndex:Data:lfImages:lfVideoData:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self cancel];
[self.delegate multiLivenessDidFailWithController:self errorType:iLFMultipleError DetectionType:iDetectionType DetectionIndex:iDetectionIndex Data:data lfImages:arrLFImage lfVideoData:lfVideoData];
});
}
}
typedef NS_ENUM(NSInteger, LivefaceChangeValue)
活体检测提示类型。
类型 | 说明 |
---|---|
LIVE_FACE_NO | 没有人脸 |
LIVE_FACE_FAR | 太近了 |
LIVE_FACE_NEAR | 太远了 |
LIVE_FACE_MANY | 多张人脸 |
LIVE_FACE_HAVE | 检测到人脸 |
LIVE_FACE_NOMAL | 人脸符合要求 |
LIVE_FACE_NOENOUGH_LIGHT | 光线太暗了 |
LIVE_FACE_TOO_LIGHT | 光线太亮了 |
LIVE_FACE_POSE_ERROR | 请正对屏幕 |
示例代码:
/**
返回人脸数据是否符合要求和人脸对应的屏幕面积
@param faceChange 人脸光线亮度相关
@param faceArea 人脸面积
*/
- (void)livenessDidFaceChange:(LivefaceChangeValue)faceChange faceArea:(int)faceArea facePose:(LivefaceChangeValue)facePose;
typedef NS_ENUM(NSInteger, LivefaceDetectionType)
检测模块类型。枚举类型定义了眨眼、点头、张嘴、摇头四种。
类型 | 说明 |
---|---|
LIVE_NONE | 未定义类型 |
LIVE_BLINK | 眨眼检测 |
LIVE_NOD | 上下点头检测 |
示例代码:
- (void)livenessDidStartDetectionWithDetectionType:(LivefaceDetectionType)iDetectionType detectionIndex:(int)iDetectionIndex{
可以拿到返回数据类型
}