Skip to content

Instantly share code, notes, and snippets.

@ozgurshn
Created December 12, 2019 01:19
Show Gist options
  • Select an option

  • Save ozgurshn/3b54052f8d28eb3bace0ff3aef1585bb to your computer and use it in GitHub Desktop.

Select an option

Save ozgurshn/3b54052f8d28eb3bace0ff3aef1585bb to your computer and use it in GitHub Desktop.
Apple Vision face landmark projection in
func getTransformedPoints(
landmark:VNFaceLandmarkRegion2D,
faceRect:CGRect,
imageSize:CGSize) -> [CGPoint]{
// last point is 0.0
return landmark.normalizedPoints.map({ (np) -> CGPoint in
return CGPoint(
x: faceRect.origin.x + np.x * faceRect.size.width,
y: imageSize.height - (np.y * faceRect.size.height + faceRect.origin.y))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment