You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The VNFaceObservation returns a normalized bounding box. You have to do the math for translation according to size of your layer. For example, I just use the frame.width and frame.height of my Preview.
func drawFaceWithLandmarks(face: VNFaceObservation) {
let transform = CGAffineTransform(scaleX: 1, y: -1).translatedBy(x: 0, y: -frame.height)
let translate = CGAffineTransform.identity.scaledBy(x: frame.width, y: frame.height)
// The coordinates are normalized to the dimensions of the processed image, with the origin at the image's lower-left corner.
let facebounds = face.boundingBox.applying(translate).applying(transform)
...
Hi, thank you for a great example!
I'm trying to do this in a smaller view but can´t figure out how to calculate the new Face landmark frames.
Say that I have a smaller AVCaptureVideoPreviewLayer say in a CGRect(x: 0, y: 44, width: 320, height: 300). I get face landmarks like this.
Do you have any idé how I can accomplish this?
The text was updated successfully, but these errors were encountered: