ImageDetect
ImageDetect 是一个基于 Swift 开发的库。使用 ImageDetect,您可以在您的图像中轻松检测和裁剪脸、文本或条形码,并且可以使用 iOS 11 Vision api。它将自动创建包含给定图像中每个找到的对象的新图像。
示例
要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install
命令。
要求
- Xcode 9.0 (beta) 或更高版本。
- iOS 11.0 (beta) 或更高版本。
安装
CocoaPods
ImageDetect 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ImageDetect'
然后,运行以下命令
pod install
手动
-
将其拖放到您的项目中
-
导入
ImageDetect
-
您现在可以开始了!
使用方法
裁剪您的 (UIImage 或 CGImage)
// `type` in this method can be face, barcode or text
image.detector.crop(type: .face) { [weak self] result in
switch result {
case .success(let croppedImages):
// When the `Vision` successfully find type of object you set and successfuly crops it.
print("Found")
case .notFound:
// When the image doesn't contain any type of object you did set, `result` will be `.notFound`.
print("Not Found")
case .failure(let error):
// When the any error occured, `result` will be `failure`.
print(error.localizedDescription)
}
}
作者
Arthur Sahakyan, [email protected]
许可证
ImageDetect 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。