Real time face detection with Camera on swift 3

前端 未结 3 605
野的像风
野的像风 2021-02-11 08:38

How can I do face detection in realtime just as \"Camera\" does? like white round shape around and over the face. I use AVCapturSession . I found that the image I s

3条回答
  •  醉梦人生
    2021-02-11 09:07

    To anyone looking for a working and update example, Apple's website has the best I have found so far: https://developer.apple.com/documentation/vision/tracking_the_user_s_face_in_real_time.

    You have to change two lines: in AppDelegate.swift you need to change line 15 to

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    

    And in ViewController.swiftyou need to change line 462 to

    let cameraIntrinsicData = CMGetAttachment(sampleBuffer, kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix, nil)
    

提交回复
热议问题