FaceRecognize.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // FaceRecognize.h
  3. // FaceSDK
  4. //
  5. // Created by Tong,Shasha on 2017/11/13.
  6. // Copyright © 2017年 Baidu. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. typedef NS_ENUM(NSUInteger ,FaceLicenseStatus) {
  11. FaceLicenseStatusSuccess = 0,
  12. FaceLicenseStatusInitError,
  13. FaceLicenseStatusDecryptError,
  14. FaceLicenseStatusInfoFormatError,
  15. FaceLicenseStatusExpired,
  16. FaceLicenseStatusRequiredInfo,
  17. FaceLicenseStatusCheckError,
  18. FaceLicenseStatusLocalFileError,
  19. FaceLicenseStatusRemoteDataError
  20. };
  21. typedef NS_ENUM(NSUInteger ,FaceRecognizeType) {
  22. FaceRecognizeTypeIDPhoto = 0,
  23. FaceRecognizeTypeLive,
  24. FaceRecognizeTypeNIR
  25. };
  26. @interface FaceRecognize : NSObject
  27. /**
  28. * 初始化方法
  29. *
  30. * @return 实例化
  31. */
  32. + (FaceRecognize *_Nonnull)sharedInstance;
  33. /**
  34. * 初始化离线识别模型并使用相对识别模式
  35. *
  36. * @param type 离线识别模型类型
  37. */
  38. - (void)initModelWithRecognizeType:(FaceRecognizeType)type;
  39. /**
  40. * SDK鉴权方法
  41. * SDK鉴权方法 必须在使用其他方法之前设置,否则会导致SDK不可用
  42. *
  43. * @param licenseId 鉴权api key
  44. * @param localLicencePath 本地鉴权文件路径
  45. */
  46. - (void)setLicenseID:(NSString *_Nonnull)licenseId
  47. andLocalLicenceFile:(NSString *_Nonnull)localLicencePath;
  48. /**
  49. * SDK是否可用
  50. * 如果可用返回结果为0
  51. *
  52. * @return SDK可用结果
  53. */
  54. - (FaceLicenseStatus)canWork;
  55. /**
  56. * 开启网络鉴权
  57. * 默认开启
  58. *
  59. * @param remoteAuthorize 是否开启网络鉴权
  60. */
  61. - (void)setRemoteAuthorize:(BOOL)remoteAuthorize;
  62. /**
  63. * 人脸特征提取
  64. *
  65. * @param image 图像
  66. * @param minSize 最小检测人脸大小 推荐值100
  67. * @return 人脸特征数据
  68. */
  69. - (NSData *_Nullable)extractFeatureWithImage:(UIImage *_Nonnull)image
  70. minFaceSize:(int)minSize;
  71. /**
  72. * 人脸特征提取
  73. * 需要传入获取的图像特征点坐标数据
  74. *
  75. * @param image 图像
  76. * @param landmarks 图像特征点坐标数组
  77. * @return 人脸特征数据
  78. */
  79. - (NSData *_Nullable)extractFeatureWithImage:(UIImage *_Nonnull)image
  80. landmarks:(NSArray *_Nullable*_Nullable)landmarks;
  81. /**
  82. * 图像特征比对
  83. * 如果成功返回人脸相似度,结果范围为(-1.0 ~ +1.0)之间
  84. *
  85. * @param firstFeature 第一张图像特征值数据
  86. * @param secondFeature 第二张图像特征值数据
  87. * @return 比对结果
  88. */
  89. - (CGFloat)getFaceFeatureDistance:(NSData *_Nonnull)firstFeature
  90. secondFaceFeature:(NSData *_Nonnull)secondFeature;
  91. /**
  92. * 相似度分数映射
  93. * 如果成功返回人脸相似度分数,结果范围为0 ~ 100
  94. *
  95. * @param firstFeature 第一张图像特征值数据
  96. * @param secondFeature 第二张图像特征值数据
  97. * @return 相似度分数
  98. */
  99. - (int)getFaceSimilarity:(NSData *_Nonnull)firstFeature
  100. secondFaceFeature:(NSData *_Nonnull)secondFeature;
  101. /**
  102. * 开启日志打印
  103. * 默认关闭
  104. *
  105. * @param visible 是否开启日志打印
  106. */
  107. - (void)setLogVisible:(BOOL)visible;
  108. @end