I'm trying to get the pitch / yaw / roll of a face in an image using the Vision framework but always get 0 for all values. Images should be very easy to process (mostly forward looking portraits).
I've successfully got these values by using Amazon Rekognition on them, so the images themselves aren't the issue. (I need to do a batch of about 70,000 so using rekogniton for them all will get expensive and slow.)
This is the request code:
let faceLandmarksRequest = VNDetectFaceRectanglesRequest(completionHandler: handleRectangles)
let requestHandler = VNImageRequestHandler(cgImage: cgImage!, orientation: CGImagePropertyOrientation.right ,options: [:])
do {
try requestHandler.perform([faceLandmarksRequest])
} catch {
print(error)
}
And here's the handler code:
func handleRectangles(request: VNRequest, errror: Error?) {
guard let observations = request.results as? [VNFaceObservation] else {
fatalError("unexpected result type!")
}
for face in observations {
print("\(face.yaw))") // always zero
}
}
Any help appreciated :)
Actually roll and yaw work, but for now they are very rough. You always get zero because roll and yaw (as of 2019) are a discrete set of 6 or 7 values rather than a continuous range of values with exact orientation of the face.
Try a "more rotated" face.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With