MGLiveDetectionManager.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // MGLiveDetectionManager.h
  3. // MGLivenessDetection
  4. //
  5. // Created by megvii on 16/3/29.
  6. // Copyright © 2016Year megvii. All rights reserved.
  7. //
  8. #import <AVFoundation/AVFoundation.h>
  9. #import <CoreMotion/CoreMotion.h>
  10. #import "MGLiveDetectionDelegate.h"
  11. #import "MGLiveConfig.h"
  12. @class MGLiveErrorManager;
  13. @class MGLiveActionManager;
  14. @protocol MGLiveDetectionDelegate;
  15. /**
  16. * 活体检测管理器,需要配置 动作管理器,错误提示管理器
  17. */
  18. @interface MGLiveDetectionManager : NSObject
  19. @property (nonatomic, assign) id <MGLiveDetectionDelegate> delegate;
  20. /**
  21. * 活体检测线程,外部指定,否则随机生成(目前该方法无效)
  22. */
  23. @property (nonatomic, strong) dispatch_queue_t detectionQueue;
  24. /**
  25. * 在质量检测阶段,根据每一帧错误,显示该提示的信息
  26. */
  27. @property (nonatomic, strong, readonly) MGLiveErrorManager *errorManager;
  28. /**
  29. * 活体检测模式,默认 全部流程。
  30. */
  31. @property (nonatomic, assign) MGLiveDetectionType detectionType;
  32. /**
  33. * 活体检测当前步骤
  34. */
  35. @property (nonatomic, assign, readonly) MGLiveStep currentLiveStep;
  36. /**
  37. * 初始化方法 不推荐使用
  38. *
  39. * @param timeOut 每个活体动作超时时间
  40. * @param actionManager 动作管理器
  41. *
  42. * @return 实例化对象
  43. */
  44. - (instancetype)initWithActionTimeOut:(NSUInteger)timeOut
  45. andActionManager:(MGLiveActionManager *)actionManager DEPRECATED_ATTRIBUTE;
  46. /**
  47. * 初始化方法,请使用该方法初始化
  48. *
  49. * @param timeOut 每个活体动作超时时间
  50. * @param actionManager 动作管理器
  51. * @param errorManager 错误提示管理器
  52. *
  53. * @return 实例化对象
  54. */
  55. - (instancetype)initWithActionTime:(NSUInteger)timeOut
  56. actionManager:(MGLiveActionManager *)actionManager
  57. errorManager:(MGLiveErrorManager *)errorManager;
  58. /**
  59. * 检测每一帧 CMSampleBufferRef
  60. *
  61. * @param buffer CMSampleBufferRef
  62. * @param orientation 图片旋转信息
  63. */
  64. - (void)detectionWithSampleBuffer:(CMSampleBufferRef)buffer
  65. orientation:(UIImageOrientation)orientation;
  66. /**
  67. * 开启检测
  68. */
  69. - (void)starDetection;
  70. /**
  71. * 停止检测,只有在照镜子模式下有用
  72. */
  73. - (void)stopDetectionQuality;
  74. /**
  75. * 停止活体检测
  76. */
  77. - (void)stopDetection;
  78. #pragma mark - 活体结束后获取数据
  79. /**
  80. * 当活体检测结束后获得过程中间采集的高质量图片样本
  81. *
  82. * @return 活体检测过程中,每个动作产生一张人脸。其中如果一个动作过程中有质量合格的人脸,则输出质量合格的。否则就输出质量相对最好的一张。
  83. */
  84. - (NSArray*)getValidFrame;
  85. - (FaceIDData*)getFaceIDDataWithMaxImageSize:(int)maxSize;
  86. - (FaceIDData*)getFaceIDData;
  87. /**
  88. * 获取照镜子阶段最好的图片(目前只在 只有照镜子的模式有用)
  89. *
  90. * @return 人脸frame
  91. */
  92. - (MGLivenessDetectionFrame *)getBestQualityFrame;
  93. /**
  94. * 获取算法日志(如有需要可调用)
  95. *
  96. * @return 活体检测算法日志
  97. */
  98. - (NSString*)getAlgorithmLog;
  99. @end