VNTrackObjectRequest不使用ARSCNView中的VNFaceObservation跟踪人脸

时间:2017-12-11 20:29:53

标签: swift tracking arkit apple-vision arscnview

我正在尝试使用ARSCNView中的VNFaceObservation跟踪脸部

let response = observations.map({ (face) -> (observation: VNFaceObservation, image: CIImage, frame: ARFrame) in

            self.lastObservation = VNDetectedObjectObservation(boundingBox: face.boundingBox)

比我做

func session(_ session: ARSession, didUpdate frame: ARFrame) {


    guard

        let lastObservation = self.lastObservation
        else { return }

    let request = VNTrackObjectRequest(detectedObjectObservation: lastObservation, completionHandler: self.handleVisionRequestUpdate)
    request.trackingLevel = .accurate

    do {

        try self.visionSequenceHandler.perform([request], on: frame.capturedImage)

    } catch {

        print("Throws: \(error)")
    }
}

但请求结果不会跟踪面并返回错误的rect

    guard let newObservation = request.results?.first as? VNDetectedObjectObservation else { return }

0 个答案:

没有答案