MLKitFaceDetection Framework Reference

  • MLKFaceDetectorOptions allows you to configure the behavior of the face detector, such as classification, performance, landmark detection, and contour detection.

  • You can control the accuracy and speed of face detection by setting the performanceMode property to either fast or accurate.

  • The classificationMode enables detection of facial attributes like smiling, while landmarkMode and contourMode control the detection of facial landmarks and contours, respectively.

  • It's possible to specify the minimum detectable face size using the minFaceSize property and enable or disable face tracking with the trackingEnabled property.

MLKFaceDetectorOptions


@interface MLKFaceDetectorOptions : NSObject

Options for specifying a face detector.

  • The face detector classification mode for characterizing attributes such as smiling. The default is .none.

    Declaration

    Objective-C

    @property (nonatomic) MLKFaceDetectorClassificationMode classificationMode;
  • The face detector performance mode that determines the accuracy of the results and the speed of the detection. The default is .fast.

    Declaration

    Objective-C

    @property (nonatomic) MLKFaceDetectorPerformanceMode performanceMode;
  • The face detector landmark mode that determines the type of landmark results returned by detection. The default is .none.

    Declaration

    Objective-C

    @property (nonatomic) MLKFaceDetectorLandmarkMode landmarkMode;
  • The face detector contour mode that determines the type of contour results returned by detection. The default is .none.

    The following detection results are returned when setting this mode to .all:

    performanceMode set to .fast, and both classificationMode and landmarkMode set to .none, then only the prominent face will be returned with detected contours.

    performanceMode set to .accurate, or if classificationMode or landmarkMode is set to .all, then all detected faces will be returned, but only the prominent face will have detecteted contours.

    Declaration

    Objective-C

    @property (nonatomic) MLKFaceDetectorContourMode contourMode;
  • The smallest desired face size. The size is expressed as a proportion of the width of the head to the image width. For example, if a value of 0.1 is specified, then the smallest face to search for is roughly 10% of the width of the image being searched. The default is 0.1. This option does not apply to contour detection.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat minFaceSize;
  • Whether the face tracking feature is enabled for face detection. The default is NO. When performanceMode is set to .fast, and both classificationMode and landmarkMode set to .none, this option will be ignored and tracking will be disabled.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isTrackingEnabled) BOOL trackingEnabled;