iOS11:如何在视频中使用Vision框架跟踪面?

时间:2017-07-14 03:21:56

标签: vision ios11

我可以在视频中跟踪对象,但我无法跟踪脸部。 当我使用相机轨道面。代码打印[]

extension FaceTrackingViewController: AVCaptureVideoDataOutputSampleBufferDelegate {

func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {

    let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)

    let request = VNDetectFaceLandmarksRequest { [unowned self] request, error in
        if let error = error {
            self.presentAlertController(withTitle: self.title,
                                        message: error.localizedDescription)
        }
        else {
            print("\(request.results!)")
        }
    }


    do {
        try handler.perform([request], on: pixelBuffer!)
    }
    catch {
        print(error)
    }
}

}

0 个答案:

没有答案