Face detection with Vision

Updated
Mar 22, 2021 6:50 PM
Created
Mar 22, 2021 6:50 PM
Tags
SwiftVision
Keywords

private let originalImage: UIImage

func faceDetection() {
    let request = VNDetectFaceRectanglesRequest { (request, error) in
        for observation in request.results as! [VNFaceObservation] {
            print(observation)
        }
    }

    if let cgImage = self.originalImage?.cgImage {
        let handler = VNImageRequestHandler(cgImage: cgImage, options: [:])
        try? handler.perform([request])
    }
}