feat:引入人脸识别sdk
This commit is contained in:
1 parent
ce16eaf82e
commit
158d012eff
331 files changed
+13539
No files matched your search
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// ToygerConfig.h
|
||||
// ToygerAlgorithm
|
||||
//
|
||||
// Created by 王伟伟 on 2018/1/22.
|
||||
// Copyright © 2018年 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ToygerConfig : NSObject
|
||||
|
||||
- (instancetype)initWithConfig:(NSDictionary *)configDict;
|
||||
|
||||
@end
|
||||
|
||||
@interface ToygerDocConfig : NSObject
|
||||
|
||||
@property(nonatomic, assign) int thickness;
|
||||
|
||||
@property(nonatomic, assign) CGRect frame;
|
||||
|
||||
@property(nonatomic, assign) float boundaryThreshold;
|
||||
|
||||
@property(nonatomic, assign) int stackTime;
|
||||
|
||||
@end
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// ToygerDocFrame.h
|
||||
// Toyger
|
||||
//
|
||||
// Created by 王伟伟 on 2018/1/25.
|
||||
// Copyright © 2018年 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <ToygerService/ToygerFrame.h>
|
||||
|
||||
@interface ToygerDocFrame : ToygerFrame
|
||||
|
||||
/**
|
||||
是否有证件
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL hasDoc;
|
||||
|
||||
/**
|
||||
证件是否完整
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL isCompleted;
|
||||
|
||||
/**
|
||||
证件是否反光
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL isReflected;
|
||||
|
||||
/**
|
||||
图像是否模糊
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL isBlur;
|
||||
|
||||
/**
|
||||
是否为复印件
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL isCopy;
|
||||
|
||||
@property(nonatomic, assign) float topScore;
|
||||
@property(nonatomic, assign) float bottomScore;
|
||||
@property(nonatomic, assign) float leftScore;
|
||||
@property(nonatomic, assign) float rightScore;
|
||||
|
||||
@property(nonatomic, assign) BOOL topOK;
|
||||
@property(nonatomic, assign) BOOL bottomOK;
|
||||
@property(nonatomic, assign) BOOL leftOK;
|
||||
@property(nonatomic, assign) BOOL rightOK;
|
||||
|
||||
@end
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// ToygerFaceFrame.h
|
||||
// ToygerAlgorithm
|
||||
//
|
||||
// Created by 王伟伟 on 2018/1/22.
|
||||
// Copyright © 2018年 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <ToygerService/ToygerFrame.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger, ToygerMessage) {
|
||||
TOYGER_Message_Image_Perfect = 0,
|
||||
TOYGER_Message_No_Face,
|
||||
TOYGER_Message_Distance_Too_Far,
|
||||
TOYGER_Message_Distance_Too_Close,
|
||||
TOYGER_Message_Face_Not_In_Center,
|
||||
TOYGER_Message_Bad_Pitch,
|
||||
TOYGER_Message_Bad_Yaw,
|
||||
TOYGER_Message_Is_Moving,
|
||||
TOYGER_Message_Bad_Brightness,
|
||||
TOYGER_Message_Bad_Quality,
|
||||
TOYGER_Message_Bad_Eye_Openness,
|
||||
TOYGER_Message_Blink_Openness,
|
||||
TOYGER_Message_Left_Yaw,
|
||||
TOYGER_Message_Right_Yaw,
|
||||
TOYGER_Message_Mouth_Open,
|
||||
TOYGER_Message_Lip_Move,
|
||||
TOYGER_Message_Photinus,
|
||||
TOYGER_Message_Stack_Time,
|
||||
TOYGER_Message_Face_Too_More,
|
||||
TOYGER_Message_Target_Too_Far,
|
||||
TOYGER_Message_Target_Too_Close,
|
||||
TOYGER_Message_Calibrate_Too_Far,
|
||||
TOYGER_Message_Calibrate_Too_Close,
|
||||
TOYGER_Message_NearFar_Collect,
|
||||
TOYGER_Message_Face_Not_In_Postion
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, ToygerStaticMessage) {
|
||||
TOYGER_Static_Message_NoLiveness = 0,
|
||||
TOYGER_Static_Message_BlinkLiveness,
|
||||
TOYGER_Static_Message_LeftYAWLiveness,
|
||||
TOYGER_Static_Message_RightYawLiveness,
|
||||
TOYGER_Static_Message_LipMoveLiveness,
|
||||
TOYGER_Static_Message_MouthOpenLiveness,
|
||||
TOYGER_Static_Message_PhotinusLiveness,
|
||||
TOYGER_Static_Message_NearFarLiveness,
|
||||
};
|
||||
|
||||
@interface ToygerFaceFrame : ToygerFrame<NSCopying>
|
||||
|
||||
@property (nonatomic, assign) ToygerMessage message;
|
||||
@property (nonatomic, assign) ToygerStaticMessage staticMessage;
|
||||
@property (nonatomic, assign) BOOL has_face;
|
||||
@property (nonatomic, assign) int brightness;
|
||||
@property (nonatomic, assign) int distance;
|
||||
@property (nonatomic, assign) BOOL face_in_center;
|
||||
@property (nonatomic, assign) BOOL is_moving;
|
||||
@property (nonatomic, assign) BOOL good_quality;
|
||||
@property (nonatomic, assign) BOOL good_pitch;
|
||||
@property (nonatomic, assign) BOOL good_yaw;
|
||||
@property (nonatomic, assign) BOOL eyeBlink;
|
||||
@property (nonatomic, assign) CGFloat progress;
|
||||
@property (nonatomic, assign) CGFloat targetFaceRegion;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// ToygerFrame.h
|
||||
// ToygerAlgorithm
|
||||
//
|
||||
// Created by 王伟伟 on 2018/1/22.
|
||||
// Copyright © 2018年 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ToygerFrame : NSObject<NSCopying>
|
||||
|
||||
@property (nonatomic, assign) CGFloat width;
|
||||
@property (nonatomic, assign) CGFloat height;
|
||||
|
||||
@end
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// ToygerAlgorithmPublicDefine.h
|
||||
// ToygerAlgorithm
|
||||
//
|
||||
// Created by 王伟伟 on 2018/1/22.
|
||||
// Copyright © 2018年 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ToygerAlgorithmPublicDefine_h
|
||||
#define ToygerAlgorithmPublicDefine_h
|
||||
|
||||
//#define USE_PB
|
||||
//#define USE_FPP
|
||||
#define LOCALVERIFY
|
||||
//#define USE_SENSOR
|
||||
#define HUMMINGBIRD
|
||||
#define ZDOC
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define TOYGER_EXPORT extern "C"
|
||||
#else
|
||||
#define TOYGER_EXPORT extern
|
||||
#endif
|
||||
|
||||
typedef NSString* const ToygerServiceEventKey;
|
||||
typedef NSNumber* const ToygerServiceSerializeType;
|
||||
typedef NSString* const ToygerFaceFrameTypeKey;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, ToygerFrameFormat) {
|
||||
ToygerFrameFormat_NV21,
|
||||
ToygerFrameFormat_BGRA,
|
||||
ToygerFrameFormat_BGR,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, ToygerFrameType) {
|
||||
ToygerFrameType_Light,
|
||||
ToygerFrameType_Unknown,
|
||||
ToygerFrameType_Dark,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, ToygerServiceType) {
|
||||
ToygerServiceType_Face = 0,
|
||||
ToygerServiceType_Card,
|
||||
ToygerServiceType_Face_LocalRegist,
|
||||
ToygerServiceType_Face_LocalMatch,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, ToygerServiceModelType) {
|
||||
ToygerServiceModelTypeFace = 0,
|
||||
ToygerServiceModelTypeMouth,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TSToygerInitFailType) {
|
||||
TSToygerInitFailTypeInvalidAlgorithm,
|
||||
TSToygerInitFailTypeToygerFileError
|
||||
};
|
||||
|
||||
TOYGER_EXPORT ToygerServiceEventKey ToygerServiceEventDarkScreen;
|
||||
TOYGER_EXPORT ToygerServiceEventKey ToygerServiceEventLivenessDone;
|
||||
TOYGER_EXPORT ToygerServiceEventKey ToygerServiceEventLivenessBlinkDone;
|
||||
TOYGER_EXPORT ToygerServiceEventKey ToygerServiceEventReset;
|
||||
TOYGER_EXPORT ToygerServiceEventKey ToygerServiceEventHighQualityImage;
|
||||
TOYGER_EXPORT ToygerServiceEventKey ToygerServiceEventUserInfo;
|
||||
TOYGER_EXPORT ToygerServiceEventKey ToygerServiceEvent;
|
||||
TOYGER_EXPORT ToygerFaceFrameTypeKey ToygerServiceFrameTypeLight;
|
||||
TOYGER_EXPORT ToygerFaceFrameTypeKey ToygerServiceFrameTypeDark;
|
||||
TOYGER_EXPORT ToygerFaceFrameTypeKey ToygerServiceEventPhotinusRGBChanged;
|
||||
|
||||
#endif /* ToygerAlgorithmPublicDefine_h */
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// ToygerSensorData.h
|
||||
// ToygerService
|
||||
//
|
||||
// Created by 晗羽 on 2018/5/17.
|
||||
// Copyright © 2018 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ToygerSensorData : NSObject
|
||||
@property (nonatomic)float pitch;
|
||||
@property (nonatomic)float roll;
|
||||
@property (nonatomic)float yaw;
|
||||
@property (nonatomic)float gyro_x;
|
||||
@property (nonatomic)float gyro_y;
|
||||
@property (nonatomic)float gyro_z;
|
||||
@property (nonatomic)unsigned long timestamp;
|
||||
@end
|
||||
|
||||
#endif
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// ToygerSensorHandler.h
|
||||
// ToygerService
|
||||
//
|
||||
// Created by 晗羽 on 2018/5/17.
|
||||
// Copyright © 2018 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <ToygerService/ToygerSensorData.h>
|
||||
|
||||
struct ToygerSensorResult {
|
||||
bool highRisk = false;
|
||||
bool isStatic = false;
|
||||
float maxRotationAngle = 0.f;
|
||||
};
|
||||
|
||||
|
||||
@interface ToygerSensorConfig: NSObject
|
||||
|
||||
@property (nonatomic)float static_threshold;
|
||||
@property (nonatomic)float rotation_threshold;
|
||||
@property (nonatomic)float offset;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface ToygerSensorHandler : NSObject
|
||||
|
||||
-(instancetype)initWithConfig:(ToygerSensorConfig *) config;
|
||||
|
||||
-(void)processSensorData:(ToygerSensorData *) dataSlice;
|
||||
|
||||
-(NSData *)getSampleData;
|
||||
|
||||
-(ToygerSensorResult)getSensorResult;
|
||||
|
||||
@property (nonatomic)float offset;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Toyger.h
|
||||
// Toyger
|
||||
//
|
||||
// Created by 守逸 on 2018/1/22.
|
||||
// Copyright © 2018年 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ToygerService_h
|
||||
#define ToygerService_h
|
||||
|
||||
#import <ToygerService/ToygerServiceInstance.h>
|
||||
#import <ToygerService/ToygerPublicDefine.h>
|
||||
#import <ToygerService/ToygerConfig.h>
|
||||
#import <ToygerService/ToygerFaceFrame.h>
|
||||
#import <ToygerService/ToygerDocFrame.h>
|
||||
#import <ToygerService/ToygerFrame.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#endif /* ToygerService_h */
|
||||
|
||||
|
||||
|
||||
//! Project version number for ToygerService.
|
||||
FOUNDATION_EXPORT double ToygerServiceVersionNumber;
|
||||
|
||||
//! Project version string for ToygerService.
|
||||
FOUNDATION_EXPORT const unsigned char ToygerServiceVersionString[];
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
//
|
||||
// Toyger.h
|
||||
// ToygerAlgorithm
|
||||
//
|
||||
// Created by 王伟伟 on 2018/1/22.
|
||||
// Copyright © 2018年 DTF. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <ToygerService/ToygerPublicDefine.h>
|
||||
#import <ToygerService/ToygerConfig.h>
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
#import "ToygerSensorData.h"
|
||||
#endif
|
||||
|
||||
@class ToygerServiceInstance;
|
||||
@class ToygerFrame;
|
||||
|
||||
//extern NSString *const kCipherDataKey;
|
||||
//extern NSString *const kDTFPubKey;
|
||||
//extern NSString *const kUserIDKey;
|
||||
|
||||
@protocol ToygerServiceInstanceDelegate<NSObject>
|
||||
|
||||
/**
|
||||
ToygerService处理完一帧后的状态更新的回调
|
||||
|
||||
@param instance 算法实例
|
||||
@param frame 返回的帧
|
||||
*/
|
||||
- (void)toygerService:(ToygerServiceInstance *)instance frameDidUpdate:(ToygerFrame *)frame;
|
||||
|
||||
/**
|
||||
ToygerService事件触发
|
||||
|
||||
@param instance 算法实例
|
||||
@param eventDict 触发的事件Dictionary
|
||||
*/
|
||||
- (void)toygerService:(ToygerServiceInstance *)instance triggerEvent:(NSDictionary *)eventDict;
|
||||
|
||||
/**
|
||||
ToygerService埋点
|
||||
|
||||
@param instance 算法实例
|
||||
@param eventDict
|
||||
*/
|
||||
- (void)toygerService:(ToygerServiceInstance *)instance triggerMonitor:(NSDictionary *)monitorDataDict;
|
||||
|
||||
/**
|
||||
ToygerService采集结束
|
||||
|
||||
@param instance 算法实例
|
||||
@param completionDict 算法结束回调
|
||||
*/
|
||||
- (void)toygerService:(ToygerServiceInstance *)instance captureDidComplete:(NSDictionary *)completionDict;
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
ToygerService采集到一张高清人脸大图(人脸算法才有)
|
||||
|
||||
@param instance 算法实例
|
||||
@param image 采集到的Image
|
||||
*/
|
||||
- (void)toygerService:(ToygerServiceInstance *)instance didGetHighQualityImage:(UIImage *)image;
|
||||
|
||||
@end
|
||||
|
||||
@interface ToygerServiceInstance : NSObject
|
||||
|
||||
/**
|
||||
设置算法的配置
|
||||
*/
|
||||
@property (nonatomic, strong) ToygerConfig *config;
|
||||
|
||||
/**
|
||||
ToygerInstace的代理
|
||||
*/
|
||||
@property (nonatomic, weak) id<ToygerServiceInstanceDelegate> delegate;
|
||||
/**
|
||||
密文秘钥
|
||||
*/
|
||||
@property (nonatomic, strong)NSString *aesCipher;
|
||||
|
||||
/**
|
||||
初始化Toyger算法.
|
||||
提前初始化可以加快算法的启动速度
|
||||
|
||||
@return Toyger算法实例
|
||||
*/
|
||||
|
||||
- (instancetype)initWithType:(ToygerServiceType)type andExtInfo:(NSDictionary *)extInfo modelTypeArray:(NSMutableArray *)modelTypeArray errorPtr:(NSError **)errorPtr NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
#ifdef ZDOC
|
||||
/**
|
||||
设置证件扫描配置
|
||||
@param config
|
||||
*/
|
||||
- (void)setDocConfig:(ToygerDocConfig *)config;
|
||||
#endif
|
||||
|
||||
- (void)updateNativeStatus:(int)actionCode message:(NSString *)message;
|
||||
|
||||
/**
|
||||
Toyger算法处理图片
|
||||
|
||||
@param sampleBuffer 摄像头传入的SampleBuffer
|
||||
*/
|
||||
- (void)processImage:(CMSampleBufferRef)sampleBuffer byOrientation:(UIImageOrientation)orientation extraInfo:(NSDictionary *)extra;
|
||||
|
||||
/**
|
||||
Toyger处理最佳图
|
||||
*/
|
||||
- (void)processBestImage;
|
||||
|
||||
- (void)photinusFinish;
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
|
||||
- (void)processSensorData:(ToygerSensorData *) sensorData withExtraInfo:(NSDictionary *)extra;
|
||||
|
||||
#endif
|
||||
/**
|
||||
对于算法不支持的类型,需要组装数据
|
||||
|
||||
@param image 传入的图片
|
||||
@return 返回要上传的内容
|
||||
*/
|
||||
- (NSData *)dataWithSurveillance:(NSArray<UIImage *> *)surveillance byType:(ToygerServiceType)toygerType extraInfo:(NSDictionary *)extraInfo;
|
||||
|
||||
|
||||
|
||||
- (NSData *)dataWithDocCaptureImage:(UIImage *)image andAeskey:(NSString *)aesKey extraInfo:(NSDictionary *)extraInfo;
|
||||
/**
|
||||
重置算法的状态
|
||||
*/
|
||||
- (void)reset;
|
||||
|
||||
/**
|
||||
返回算法的MetaInfo
|
||||
|
||||
@return metaInfo
|
||||
*/
|
||||
+ (NSArray<NSString *> *)metaInfo;
|
||||
|
||||
|
||||
/**
|
||||
+获取活体检测后的状态
|
||||
*/
|
||||
+(NSInteger)getToygerState;
|
||||
|
||||
//补充加签数据
|
||||
- (NSString *)updateInfoSig:(NSDictionary *)addtionalInfoSig;
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user