FaceCropImageView

Crop and show the proper location of face in the photo.


License
MIT
Install
pod try FaceCropImageView

Documentation

Awesome License Platform

Face Crop ImageView

This FaceCropImageView is an extension of UIImageView, which helps properly crop and show the position of the face in the picture. This library is strongly inspired by UIImageView-BetterFace.

Demo screenshot and description are here!

Installation

FaceCropImageView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'FaceCropImageView'

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

Simple instruction is explained as follows.

let myImage = UIImage(named: "some-image")
imageView.setFaceImage(myImage)

You can also crop the image on the web using the URL. (In this case, the Kingfisher library is used)

let imageUrl = URL(string: "https://some-url/image.jpg")
imageView.setFaceImage(with: imageUrl)

If you need to detect faces more specifically, use fast parameter. This parameter can determine the value of CIDectorAccuracy from CIDectorAccuracyLow to CIDectorAccuracyHigh.

imageView.setFaceImage(with: imageUrl, fast: false)

And it supports the completion closure.

imageView.setFaceImage(with: imageUrl, fast: false) { result in
    switch result {
    case .success(let features):
        // `feature` means detected face infomation.
        // `features.count == 0` means no face in the image.
        print(features)
    case .failure(let error):
        print(error)
    }
}

Author

HanSJin, kksd9900@naver.com

License

FaceCropImageView is available under the MIT license. See the LICENSE file for more info.