Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VNDetectFaceRectanglesRequest always returns 0 for yaw/pitch/roll

Tags:

swift

swift4

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 :)

like image 520
Jonathan Plackett Avatar asked Nov 06 '22 20:11

Jonathan Plackett


1 Answers

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.

like image 71
Paul B Avatar answered Nov 15 '22 07:11

Paul B