MMFaceDetector 接口文档

人脸检测器,检测图片获取人脸区域,关键点信息。可用于美颜,图片人脸检测等。

1. 构造方法

  • 同步构造方法

      MMFaceDetector *facedetector = [[MCCDetectorsCenter sharedInstance] syncMakeFaceDetector:MCCFaceDetectorTypeFace];
    
  • 异步构造方法

      [[MCCDetectorsCenter sharedInstance] asyncMakeFaceDetector:MCCFaceDetectorTypeFace complete:^(NSObject * _Nullable detector) {
          MMFaceDetector *facedetector = detector;
      }];
    
  • 是否开启表情检测,默认是NO

    @property (nonatomic) BOOL advancedExpressionDetectionEnabled;
    

2. 检测方法

  • 共提供三个检测接口,MMFaceDetectOptions 字段为扫脸传参,MMFaceFeature 为单人脸信息(多人时,数组会有多值)。
- (NSArray<MMFaceFeature *> *)featuresInPixelBuffer:(CVPixelBufferRef)pixelBuffer;

- (NSArray<MMFaceFeature *> *)featuresInPixelBuffer:(CVPixelBufferRef)pixelBuffer orientation:(MMCVImageOrientation)orientation;

- (NSArray<MMFaceFeature *> *)featuresInPixelBuffer:(CVPixelBufferRef)pixelBuffer options:(MMFaceDetectOptions *)options;

3. MMFaceDetectOptions 字段介绍

  • 图片帧类型,是否静态图

    @property (nonatomic) MMFaceDetectionInputHint inputHint;
    
  • 图片方向

    @property (nonatomic) MMCVImageOrientation orientation;
    
  • 检测算法 (视频推荐MMFaceDetectionMethodNPD,能耗降低)

    @property (nonatomic) MMFaceDetectionMethod faceDetectionMethod;
    
  • 最大检测脸个数

    @property (nonatomic) NSUInteger maximumFaceCount;
    
  • 人脸点数版本 (fd模型支持96,fd137支持96&137)

    @property (nonatomic) MMFaceAlignmentVersion faceAlignmentVersion;
    

4. MMFaceFeature 字段介绍

  • trackId 人脸追踪标识,视频人脸追踪中不变,人脸丢失后自增

    @property (nonatomic,readonly) NSInteger trackingIdentifier;
    
  • 人脸五官矩形区域(相对于图形帧)

    @property (nonatomic,readonly) CGRect bounds;
    
  • 人脸欧拉角

    @property (nonatomic,readonly) double pitch;
    @property (nonatomic,readonly) double yaw;
    @property (nonatomic,readonly) double roll;
    
  • 图片大小

    @property (nonatomic,readonly) CGSize imageSize;
    

4.1. MMFaceLandmarks2D 介绍

MMFaceLandmarks2D 可以通过 MMFaceFeature 调用如下接口获得

typedef NS_ENUM(NSInteger, MMFaceLandmarks2DType) {
    MMFaceLandmarks2DType68,
    MMFaceLandmarks2DType96,
    MMFaceLandmarks2DType104,
    MMFaceLandmarks2DType137
};
- (MMFaceLandmarks2D *)landmarksOfType:(MMFaceLandmarks2DType)type NS_SWIFT_NAME(landmarks(ofType:));
  • 脸部关键点的个数

    @property (readonly) NSUInteger pointCount;
    
  • 脸部关键点(相对视频帧坐标)

    @property (nonatomic, readonly) const simd_float2 *points NS_RETURNS_INNER_POINTER;
    @property (nonatomic, copy, readonly) NSArray<NSValue *> *pointValues;
    

    +

  • 脸部关键点(归一化后坐标)

    @property (nonatomic, readonly) const simd_float2 *normalizedPoints NS_RETURNS_INNER_POINTER;
    
  • 图片大小

    @property (nonatomic, readonly) CGSize imageSize;
    
@Copyright © cosmos 2019 all right reserved,powered by Gitbook修订时间: 2019-05-31 10:17:01

results matching ""

    No results matching ""