Created
April 6, 2026 12:38
-
-
Save jacobsapps/d0d14b8ec74d0150ff8a4f92303e3c27 to your computer and use it in GitHub Desktop.
Face Detection with Vision from Apple Photos, Face Tagging, and Embeddings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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