ToygerServiceInstance.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // Toyger.h
  3. // ToygerAlgorithm
  4. //
  5. // Created by 王伟伟 on 2018/1/22.
  6. // Copyright © 2018年 DTF. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <ToygerService/ToygerPublicDefine.h>
  10. #import <ToygerService/ToygerConfig.h>
  11. #ifdef USE_SENSOR
  12. #import <ToygerService/ToygerSensorHandler.h>
  13. #endif
  14. @class ToygerServiceInstance;
  15. @class ToygerFrame;
  16. //extern NSString *const kCipherDataKey;
  17. //extern NSString *const kDTFPubKey;
  18. //extern NSString *const kUserIDKey;
  19. @protocol ToygerServiceInstanceDelegate<NSObject>
  20. /**
  21. ToygerService处理完一帧后的状态更新的回调
  22. @param instance 算法实例
  23. @param frame 返回的帧
  24. */
  25. - (void)toygerService:(ToygerServiceInstance *)instance frameDidUpdate:(ToygerFrame *)frame;
  26. /**
  27. ToygerService事件触发
  28. @param instance 算法实例
  29. @param eventDict 触发的事件Dictionary
  30. */
  31. - (void)toygerService:(ToygerServiceInstance *)instance triggerEvent:(NSDictionary *)eventDict;
  32. /**
  33. ToygerService埋点
  34. @param instance 算法实例
  35. @param eventDict
  36. */
  37. - (void)toygerService:(ToygerServiceInstance *)instance triggerMonitor:(NSDictionary *)monitorDataDict;
  38. /**
  39. ToygerService采集结束
  40. @param instance 算法实例
  41. @param completionDict 算法结束回调
  42. */
  43. - (void)toygerService:(ToygerServiceInstance *)instance captureDidComplete:(NSDictionary *)completionDict;
  44. @optional
  45. /**
  46. ToygerService采集到一张高清人脸大图(人脸算法才有)
  47. @param instance 算法实例
  48. @param image 采集到的Image
  49. */
  50. - (void)toygerService:(ToygerServiceInstance *)instance didGetHighQualityImage:(UIImage *)image;
  51. @end
  52. @interface ToygerServiceInstance : NSObject
  53. /**
  54. 设置算法的配置
  55. */
  56. @property (nonatomic, strong) ToygerConfig *config;
  57. /**
  58. ToygerInstace的代理
  59. */
  60. @property (nonatomic, weak) id<ToygerServiceInstanceDelegate> delegate;
  61. /**
  62. 密文秘钥
  63. */
  64. @property (nonatomic, strong)NSString *aesCipher;
  65. /**
  66. 初始化Toyger算法.
  67. 提前初始化可以加快算法的启动速度
  68. @return Toyger算法实例
  69. */
  70. - (instancetype)initWithType:(ToygerServiceType)type andExtInfo:(NSDictionary *)extInfo errorPtr:(NSError **)errorPtr NS_DESIGNATED_INITIALIZER;
  71. /**
  72. Toyger算法处理图片
  73. @param sampleBuffer 摄像头传入的SampleBuffer
  74. */
  75. - (void)processImage:(CMSampleBufferRef)sampleBuffer byOrientation:(UIImageOrientation)orientation extraInfo:(NSDictionary *)extra;
  76. /**
  77. Toyger处理最佳图
  78. */
  79. - (void)processBestImage;
  80. #ifdef USE_SENSOR
  81. - (void)processSensorData:(ToygerSensorData *) sensorData withExtraInfo:(NSDictionary *)extra;
  82. #endif
  83. /**
  84. 对于算法不支持的类型,需要组装数据
  85. @param image 传入的图片
  86. @return 返回要上传的内容
  87. */
  88. - (NSData *)dataWithSurveillance:(NSArray<UIImage *> *)surveillance byType:(ToygerServiceType)toygerType extraInfo:(NSDictionary *)extraInfo;
  89. - (NSData *)dataWithDocCaptureImage:(UIImage *)image andAeskey:(NSString *)aesKey extraInfo:(NSDictionary *)extraInfo;
  90. /**
  91. 重置算法的状态
  92. */
  93. - (void)reset;
  94. /**
  95. 返回算法的MetaInfo
  96. @return metaInfo
  97. */
  98. + (NSArray<NSString *> *)metaInfo;
  99. /**
  100. +获取活体检测后的状态
  101. */
  102. +(NSInteger)getToygerState;
  103. @end