Latest 0.1.3
Homepage https://github.com/manuelbulos/SmartImageView
License MIT
Platforms ios 11.0
Frameworks UIKit
Authors

CI Status
Version
License
Platform

Example

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

SmartImageView

Requirements

iOS 11.0 *

Installation

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

pod 'SmartImageView'

Usage

import UIKit

class ViewController: UIViewController {

    // Works programmatically or using the interface builder
    @IBOutlet weak var smartImageView: SmartImageView!

    fileprivate let image = UIImage(named: "Sample1")

    override func viewDidLoad() {
        super.viewDidLoad()
        smartImageView.delegate = self
        smartImageView.searchForFaces(on: image)
    }
}

SmartImageViewDelegate

import UIKit

@available(iOS 11.0, *)
@objc public protocol SmartImageViewDelegate: class {

    /// Asks the delegate for a view object to display in every face found.
    @objc optional func smartImageView(_ smartImageView: SmartImageView, viewForFaceIn frame: CGRect) -> UIView

    /// Sent after SmartImageView finishes searching for faces.
    @objc optional func smartImageView(_ smartImageView: SmartImageView, numberOfFacesFound: Int)

    /// Sent if an error was found at any time during the task.
    @objc optional func smartImageView(_ smartImageView: SmartImageView, encountered error: Error)

}

SmartImageViewDelegate Usage

extension ViewController: SmartImageViewDelegate {

    func smartImageView(_ smartImageView: SmartImageView, numberOfFacesFound: Int) {
        print("Found: (numberOfFacesFound) face(s)")
    }

    func smartImageView(_ smartImageView: SmartImageView, viewForFaceIn frame: CGRect) -> UIView {
        let customView = UIView(frame: frame)
        customView.backgroundColor = .yellow
        customView.alpha = 0.5
        return customView
    }

    func smartImageView(_ smartImageView: SmartImageView, encountered error: Error) {
        print(error.localizedDescription)
    }

}

Author

manuelbulos, [email protected]

License

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

Latest podspec

{
    "name": "SmartImageView",
    "version": "0.1.3",
    "summary": "UIImageView that detects faces and adds custom views over them. Uses Vision API from Apple.",
    "description": "Simple UIImageView component",
    "homepage": "https://github.com/manuelbulos/SmartImageView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "manuelbulos": "[email protected]"
    },
    "source": {
        "git": "https://github.com/manuelbulos/SmartImageView.git",
        "tag": "0.1.3"
    },
    "social_media_url": "https://www.manuelbulos.com",
    "platforms": {
        "ios": "11.0"
    },
    "swift_version": "4.2",
    "source_files": "SmartImageView/Classes/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This