MLKitFaceDetection Framework Reference

FaceDetector

class FaceDetector : NSObject

A face detector that detects faces in an image.

  • Returns a face detector with the given options.

    Declaration

    Swift

    class func faceDetector(options: MLKFaceDetectorOptions) -> Self

    Parameters

    options

    Options for configuring the face detector.

    Return Value

    A face detector configured with the given options.

  • Returns a face detector with default options.

    Declaration

    Swift

    class func faceDetector() -> Self

    Return Value

    A face detector configured with default options.

  • Unavailable. Use the class methods.

  • Processes the given image for face detection.

    Declaration

    Swift

    func process(_ image: MLKVisionImage, completion: @escaping FaceDetectionCallback)

    Parameters

    image

    The image to process.

    completion

    Handler to call back on the main thread with faces detected or error.

  • Returns face results in the given image or nil if there was an error. The face detection is performed synchronously on the calling thread.

    It is advised to call this method off the main thread to avoid blocking the UI. As a result, an NSException is raised if this method is called on the main thread.

    Declaration

    Swift

    func results(in image: MLKVisionImage) throws -> [MLKFace]

    Parameters

    image

    The image to get results in.

    error

    An optional error parameter populated when there is an error getting results.

    Return Value

    Array of face results in the given image or nil if there was an error.