Real time face detection is not working

后端 未结 2 847
半阙折子戏
半阙折子戏 2021-01-14 22:59

This code does not show the detection of face in camera, even there is no error. I want the face should be detected in realtime in camera with red squire surrounded, but I

2条回答
  •  感动是毒
    2021-01-14 23:22

    You most probably need just to trigger the function the way how it is described in the document

    We will invoke the detect method in viewDidLoad. So insert the following line of code in the method:

    override func viewDidLoad() {
       super.viewDidLoad()
    
       detect()
    

    }

    Compile and run the app.

    EDIT: This is solution while the function "detect" is as a subclass method, but in your case, you use IBAction, which has different syntax like this. You should try to delete name of the function detect() and this bracket

    }
    
    let picker =
    

    and this part have to inside a function

    let picker = UIImagePickerController()
    picker.delegate = self
    picker.allowsEditing = true
    picker.sourceType = .camera
    picker.cameraDevice = .front
    self.present(picker, animated: true, completion: { _ in })
    

    for your case you can probably omit this part as well.

提交回复
热议问题