我正在尝试在 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 }