# FaceLandmarker

    class FaceLandmarker: NSObject

Class that performs face landmark detection on images.

The API expects a TFLite model with mandatory TFLite Model Metadata.
- `
  ### [contoursConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)contoursConnections)

  ` Returns the connections between making up the contours of the face.

  #### Declaration

  Swift

      class func contoursConnections() -> [Connection]

  #### Return Value

  An array of connections between all the contours of the face.
- `
  ### [faceConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)faceConnections)

  ` Returns the connections between all the landmarks in the face.

  #### Declaration

  Swift

      class func faceConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the face.
- `
  ### [faceOvalConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)faceOvalConnections)

  ` Returns the connections between all the landmarks of the face oval.

  #### Declaration

  Swift

      class func faceOvalConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks of the face oval.
- `
  ### [leftEyeConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)leftEyeConnections)

  ` Returns the connections between all the landmarks in the left eye.

  #### Declaration

  Swift

      class func leftEyeConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the left eye.
- `
  ### [leftEyebrowConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)leftEyebrowConnections)

  ` Returns the connections between all the landmarks in the left eyebrow.

  #### Declaration

  Swift

      class func leftEyebrowConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the left eyebrow.
- `
  ### [leftIrisConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)leftIrisConnections)

  ` Returns the connections between all the landmarks in the left iris.

  #### Declaration

  Swift

      class func leftIrisConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the left iris.
- `
  ### [lipsConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)lipsConnections)

  ` Returns the connections between all the landmarks in the lips.

  #### Declaration

  Swift

      class func lipsConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the lips.
- `
  ### [rightEyeConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)rightEyeConnections)

  ` Returns the connections between all the landmarks in the right eye.

  #### Declaration

  Swift

      class func rightEyeConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the right eyr.
- `
  ### [rightEyebrowConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)rightEyebrowConnections)

  ` Returns the connections between all the landmarks in the right eyebrow.

  #### Declaration

  Swift

      class func rightEyebrowConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the right eyebrow.
- `
  ### [rightIrisConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)rightIrisConnections)

  ` Returns the connections between all the landmarks in the right iris.

  #### Declaration

  Swift

      class func rightIrisConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks in the right iris.
- `
  ### [tesselationConnections()](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(cm)tesselationConnections)

  ` Returns the connections between all the landmarks making up the tesselation of the face.

  #### Declaration

  Swift

      class func tesselationConnections() -> [Connection]

  #### Return Value

  An array of connections between all the landmarks making up the tesselation of the face.
- `
  ### [init(modelPath:)](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(im)initWithModelPath:error:)

  ` Creates a new instance of `FaceLandmarker` from an absolute path to a TensorFlow Lite model file stored locally on the device and the default `FaceLandmarker`.

  #### Declaration

  Swift

      convenience init(modelPath: String) throws

  #### Parameters

  |---|---|
  | `modelPath` | An absolute path to a TensorFlow Lite model file stored locally on the device. |

  #### Return Value

  A new instance of `FaceLandmarker` with the given model path. `nil` if there is an error in initializing the face landmaker.
- `
  ### [init(options:)](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(im)initWithOptions:error:)

  ` Creates a new instance of `FaceLandmarker` from the given `FaceLandmarkerOptions`.

  #### Declaration

  Swift

      init(options: FaceLandmarkerOptions) throws

  #### Parameters

  |---|---|
  | `options` | The options of type `FaceLandmarkerOptions` to use for configuring the `FaceLandmarker`. |

  #### Return Value

  A new instance of `FaceLandmarker` with the given options. `nil` if there is an error in initializing the face landmaker.
- `
  ### [detect(image:)](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(im)detectImage:error:)

  ` Performs face landmark detection on the provided `MPImage` using the whole image as region of interest. Rotation will be applied according to the `orientation` property of the provided `MPImage`. Only use this method when the `FaceLandmarker` is created with `.image`.

  This method supports performing face landmark detection on RGBA images. If your `MPImage` has a source type of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must use `kCVPixelFormatType_32BGRA` as its pixel format.

  If your `MPImage` has a source type of `.image` ensure that the color space is RGB with an Alpha channel.

  #### Declaration

  Swift

      func detect(image: MPImage) throws -> FaceLandmarkerResult

  #### Parameters

  |---|---|
  | `image` | The `MPImage` on which face landmark detection is to be performed. |

  #### Return Value

  An `FaceLandmarkerResult` that contains a list of landmarks. `nil` if there is an error in initializing the face landmaker.
- `
  ### [detect(videoFrame:timestampInMilliseconds:)](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(im)detectVideoFrame:timestampInMilliseconds:error:)

  ` Performs face landmark detection on the provided video frame of type `MPImage` using the whole image as region of interest. Rotation will be applied according to the `orientation` property of the provided `MPImage`. Only use this method when the `FaceLandmarker` is created with running mode `.video`.

  This method supports performing face landmark detection on RGBA images. If your `MPImage` has a source type of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must use `kCVPixelFormatType_32BGRA` as its pixel format.

  If your `MPImage` has a source type of `.image` ensure that the color space is RGB with an Alpha channel.

  #### Declaration

  Swift

      func detect(videoFrame image: MPImage, timestampInMilliseconds: Int) throws -> FaceLandmarkerResult

  #### Parameters

  |---|---|
  | `image` | The `MPImage` on which face landmark detection is to be performed. |
  | `timestampInMilliseconds` | The video frame's timestamp (in milliseconds). The input timestamps must be monotonically increasing. |

  #### Return Value

  An `FaceLandmarkerResult` that contains a list of landmarks. `nil` if there is an error in initializing the face landmaker.
- `
  ### [detectAsync(image:timestampInMilliseconds:)](https://developers.google.com/edge/api/mediapipe/swift/vision/Classes/FaceLandmarker.md.txt#/c:objc(cs)MPPFaceLandmarker(im)detectAsyncImage:timestampInMilliseconds:error:)

  ` Sends live stream image data of type `MPImage` to perform face landmark detection using the whole image as region of interest. Rotation will be applied according to the `orientation` property of the provided `MPImage`. Only use this method when the `FaceLandmarker` is created with `.liveStream`.

  The object which needs to be continuously notified of the available results of face detection must confirm to `FaceLandmarkerLiveStreamDelegate` protocol and implement the `faceLandmarker(_:didFinishDetectionWithResult:timestampInMilliseconds:error:)` delegate method.

  It's required to provide a timestamp (in milliseconds) to indicate when the input image is sent to the face detector. The input timestamps must be monotonically increasing.

  This method supports performing face landmark detection on RGBA images. If your `MPImage` has a source type of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must use `kCVPixelFormatType_32BGRA` as its pixel format.

  If the input `MPImage` has a source type of `.image` ensure that the color space is RGB with an Alpha channel.

  If this method is used for classifying live camera frames using `AVFoundation`, ensure that you request `AVCaptureVideoDataOutput` to output frames in `kCMPixelFormat_32BGRA` using its `videoSettings` property.

  #### Declaration

  Swift

      func detectAsync(image: MPImage, timestampInMilliseconds: Int) throws

  #### Parameters

  |---|---|
  | `image` | A live stream image data of type `MPImage` on which face landmark detection is to be performed. |
  | `timestampInMilliseconds` | The timestamp (in milliseconds) which indicates when the input image is sent to the face detector. The input timestamps must be monotonically increasing. |

  #### Return Value

  `true` if the image was sent to the task successfully, otherwise `false`.