接口文档
1. MNFCService
- 类名:MNFCService
- 功能:主要服务功能
1.1. 方法
- 设置AppId
+ (void)configAppId:(NSString *)appId;
- 判断环境是否准备好
+ (BOOL)isPrepared;
- 环境准备
+ (void)prepareEnvironment:(void(^_Nullable)(BOOL prepared))completionHandler;
- 扫脸认证
+ (void)startCertificationWithConfig:(MNFCDetectionConfig *)config;
+ (void)startCertificationWithConfig:(MNFCDetectionConfig *)config themes:(MNFCThemes * _Nullable)themes;
+ (void)startCertificationWithConfig:(MNFCDetectionConfig *)config
themes:(MNFCThemes * _Nullable)themes
presentingViewController:(UIViewController * _Nullable)presentingViewController;
参数说明:
名称 | 类型 | 说明 |
---|---|---|
config | MNFCDetectionConfig | 检测配置 |
themes | MNFCThemes | 界面配置 |
presentingViewController | UIViewController | 用于present扫脸界面的控制器 |
- 人脸对比
识别图片中的人物与指定 personId 的人物的相似度
+ (void)comparePerson:(NSString *)personId
image:(UIImage *)image
completionHandler:(nonnull void(^)(MNCompareResult * _Nullable compareResult, MNFCDetectionError errorCode))completionHandler;
+ (void)comparePerson:(NSString *)personId
imageURL:(NSString *)imageURL
completionHandler:(nonnull void(^)(MNCompareResult * _Nullable compareResult, MNFCDetectionError errorCode))completionHandler;
- 人脸搜索
从指定集合中搜索出与图片中人物相似度高于某值的前N个人物
+ (void)searchPersonsInSet:(NSString *)setId
threshold:(CGFloat)threshold
count:(NSUInteger)count
image:(UIImage *)image
completionHandler:(nonnull void(^)(MNSearchResult * _Nullable searchResult, MNFCDetectionError errorCode))completionHandler;
+ (void)searchPersonsInSet:(NSString *)setId
threshold:(CGFloat)threshold
count:(NSUInteger)count
imageURL:(NSString *)imageURL
completionHandler:(nonnull void(^)(MNSearchResult * _Nullable searchResult, MNFCDetectionError errorCode))completionHandler;
+ (void)searchPersonsInSet:(NSString *)setId
threshold:(CGFloat)threshold
count:(NSUInteger)count
personId:(NSString *)personId
completionHandler:(nonnull void(^)(MNSearchResult * _Nullable searchResult, MNFCDetectionError errorCode))completionHandler;
参数说明:
名称 | 类型 | 说明 |
---|---|---|
setId | NSString | 集合ID |
threshold | CGFloat | 查询相似度阈值 |
count | NSUInteger | 返回结果最大数量 |
2. MNFCDetectionConfig
- 类名:MNFCDetectionConfig
- 功能:扫脸认证相关配置
2.1. 成员
- 检测方式
@property (nonatomic, assign) MNFCDetectionType detectionType;
默认为交互式
MNFCDetectionTypeInteractive = 0, // 交互式
MNFCDetectionTypeSilent // 静默式
- 交互动作数量
指定交互式扫脸模式下交互动作的数量,默认为4,取值范围在 [3, 6]
@property (nonatomic, assign) NSUInteger motionDetectionCount;
- 扫脸结果回调
扫脸注册完成后的结果回调,结果包含注册的personId及错误码
@property (nonatomic, strong) void(^resultCallBack)(NSString * _Nullable personId, MNFCDetectionError errorCode);
3. MNFCThemes
- 类名:MNFCThemes
- 功能:扫脸界面配置
3.1. 成员
- 页面标题
@property (nonatomic, copy, nullable) NSString *detectionTitle;
- 磨皮系数 0~1
@property (nonatomic, assign) CGFloat smoothingAmount;
- 美白系数 0~1
@property (nonatomic, assign) CGFloat whitenAmount;
3.2. 方法
- 默认主题配置
磨皮 0.6
美白 0.8
+ (MNFCThemes *)defultThemes;
4. MNMatchResult
- 类名:MNMatchResult
- 功能:匹配结果
4.1. 成员
- personId
@property (nonatomic, copy) NSString *personId;
- 相似度
@property (nonatomic, assign) CGFloat score;
5. MNCompareResult
- 类名:MNCompareResult
- 功能:比对结果
5.1. 成员
- personId
@property (nonatomic, copy) NSString *personId;
- 相似度
@property (nonatomic, assign) CGFloat score;
- 颜值分
@property (nonatomic, assign) CGFloat beautyScore;
- 人脸质量
@property (nonatomic, assign) MNMatchQualityCode qualityCode;
6. MNSearchResult
- 类名:MNSearchResult
- 功能:搜索结果
6.1. 成员
- 人脸质量
@property (nonatomic, assign) MNMatchQualityCode qualityCode;
- 匹配结果数组
@property (nonatomic, copy) NSArray<MNMatchResult *> *matchResults;
7. MNMatchQualityCode
- 类型名:MNMatchQualityCode
- 功能:图片中人脸质量
MNMatchQualityCode_Normal = 0,
MNMatchQualityCode_NOFACE = 50, // 无脸
MNMatchQualityCode_MULTI = 51, // 多个人脸
MNMatchQualityCode_SMALL = 52, // 面积太小
MNMatchQualityCode_OCC = 53, // 遮挡
MNMatchQualityCode_NOTFRONT = 54, // 大侧脸
MNMatchQualityCode_BLUR = 55, // 模糊
MNMatchQualityCode_DARK = 56, // 太暗
MNMatchQualityCode_LIGHT = 57, // 过曝
MNMatchQualityCode_HICONTRAST = 58, // 对比度过高
MNMatchQualityCode_LIGHTSPOT = 59, // 有光斑
8. MNFCDetectionError
- 类型名:MNFCDetectionError
- 功能:检测服务的错误码
MNFCDetectionError_None = 0,
// 通用错误
MNFCDetectionError_LocalServiceError = 1001, // 本地异常
MNFCDetectionError_NetworkError = 1002, // 网络异常
MNFCDetectionError_InvalidAppId = 1003, // 无效的AppId
MNFCDetectionError_ServerError = 1004, // 服务器异常
MNFCDetectionError_SensitivePeople = 1005, // 命中敏感人物
// 扫脸认证时会返回的错误
MNFCDetectionError_UserCanceled = 2001, // 用户手动取消
MNFCDetectionError_DetectTimeout = 2002, // 检测超时
MNFCDetectionError_NoLivesness = 2003, // 非活体
MNFCDetectionError_FaceChanged = 2004, // 人脸改变
MNFCDetectionError_LostFace = 2005, // 人脸丢失
MNFCDetectionError_TooManyFailedCount = 2006, // 动作检测失败次数过多
MNFCDetectionError_NoCameraPermission = 2007, // 无相机权限
MNFCDetectionError_InvalidBaseFace = 2010, // 收集的base脸异常
// 图片检测时会返回的错误
MNFCDetectionError_LoadImageError = 3001, // 图片拉取失败
MNFCDetectionError_InvalidPersonId = 3002, // 无效的PersonId
MNFCDetectionError_InvalidSetId = 3003, // 无效的SetId