Skip to content

Instantly share code, notes, and snippets.

@jacobsapps
Created April 6, 2026 12:38
Show Gist options
  • Select an option

  • Save jacobsapps/d0d14b8ec74d0150ff8a4f92303e3c27 to your computer and use it in GitHub Desktop.

Select an option

Save jacobsapps/d0d14b8ec74d0150ff8a4f92303e3c27 to your computer and use it in GitHub Desktop.
Face Detection with Vision from Apple Photos, Face Tagging, and Embeddings
func detectFaces(in image: CGImage) async throws -> [VNFaceObservation] {
try await withCheckedThrowingContinuation { continuation in
let request = VNDetectFaceRectanglesRequest { request, error in
if let error {
continuation.resume(throwing: error)
return
}
let faces = request.results as? [VNFaceObservation] ?? []
continuation.resume(returning: faces)
}
let handler = VNImageRequestHandler(cgImage: image, options: [:])
try handler.perform([request])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment