Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/Ancestry/FaceCrop

Utilizing Apple's Vision Framework to center faces in CGImage.
https://github.com/Ancestry/FaceCrop

Last synced: about 2 months ago
JSON representation

Utilizing Apple's Vision Framework to center faces in CGImage.

Lists

README

        

# FaceCrop
CGImage extension that utilizes Apple's Vision Framework to detect and center faces.

![Example](https://user-images.githubusercontent.com/15527890/87205361-20506000-c2bc-11ea-919a-e0a788d5b303.png)

# Usage

```swift
cgImage.faceCrop { [weak self] result in
switch result {
case .success(let cgImage):
DispatchQueue.main.async { self?.imageView.image = UIImage(cgImage: cgImage) }
case .notFound, .failure( _):
print("error")
}
}
```

If you need to crop a `UIImage` - you can always access its `CGImage` by calling [.cgImage](https://developer.apple.com/documentation/uikit/uiimage/1624147-cgimage).

===

For more information consider visiting [this in-depth artictle on Medium](https://medium.com/ancestry-engineering/image-face-centering-using-apples-vision-framework-3ff3954ab5cb).

Huge thanks to Anastasios Grigoriou for his work on this project!