Evil
Optical Character Recognition in Swift for iOS&macOS. 银行卡、身份证、门牌号光学识别
Install / Use
/learn @evilgix/EvilREADME

图片来自于网络,侵删
Requirements
- iOS 11.0+ / macOS 10.13+
- Xcode9.2+
- Swift 4.0+
Installation
Basic Usage
Evil 使用 Vision 框架进行文字识别,因此你需要导入特定的MLModel到你的Xcode工程。例如识别身份证导入识别身份证的model,识别银行卡导入识别银行卡的model。
以下是目前已经训练好的模型
- ChineseIDCard ==> 🇨🇳中国二代身份证号码识别
如何导入
首先从上面的地址下载或者自己训练得到模型文件(*.mlmodel),然后作为resource资源加入项目。但是模型文件size一般都比较大因此Evil还支持另外一种方式即:运行时从指定的服务器下载对应的模型。
- 获取对应的模型文件并重名命名为
[name].mlmodel[name]可通过以下方法获取print(Recognizer.chineseIDCard.name) - 将模型文件上传至自己的服务器或者CDN并获取下载链接
- 在
info.plist中配置下载链接如下

初始化
lazy var evil = try? Evil(recognizer: .chineseIDCard)
或者 手动指定下载路径
let downloadURL = URL(string: "https://****/ChineseIDCard.mlmodel")!
let chineseIDCard = Recognizer.custom(name: "ChineseIDCard", model: downloadURL, needComplie: true, processor: Recognizer.cropChineseIDCardNumberArea)
let evil = try? Evil(recognizer: chineseIDCard)
或者直接将模型文件拖入 xcode 项目
let url = Bundle.main.url(forResource: "ChineseIDCard", withExtension: "mlmodelc")!
let evil = try? Evil(contentsOf: url, name: "ChineseIDCard")
注意Extension 为mlmodelc而不是mlmodel因为xcode会自动编译mlmodel文件,并且生成对应的class. 所以请务必注意Model文件不要和现有的class重名。
开始识别
let image: Recognizable = .....
let result = evil?.recognize(image)
print(result)
训练模型
参考Tools 目录下PrepareBot项目
参考博文掘金
交流讨论
1.github issue (推荐)
2.qq 群:641256202
LICENSE
MIT
Copyright 2018 - 2019 Kevin.Gong aoxianglele#icloud.com
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
workshop-rules
Materials used to teach the summer camp <Data Science for Kids>
last30days-skill
19.8kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
000-main-rules
Project Context - Name: Interactive Developer Portfolio - Stack: Next.js (App Router), TypeScript, React, Tailwind CSS, Three.js - Architecture: Component-driven UI with a strict separation of conce
