title: How do I perform Face Detection in Swift
body: <p>Im using the following code to detect a face from an image.</p>
  
  <pre><code>let userDirectory = FileManager.default.homeDirectoryForCurrentUser
  let desktopDirectory = userDirectory.appendingPathComponent("Desktop")
  let pictureUrl = desktopDirectory.appendingPathComponent("test").appendingPathExtension("jpg")
  
  let image = CIImage(contentsOf: pictureUrl)   
  let faceDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh])
  let faces = faceDetector?.features(in: image!) as! [CIFaceFeature]
  print("Number of faces: \(faces.count)")
  </code></pre>
  
  <p>How can I detect a face and save it to an NSImage?</p>