{"id":15038034,"url":"https://github.com/evilgix/evil","last_synced_at":"2025-04-05T09:07:43.490Z","repository":{"id":56910179,"uuid":"118329733","full_name":"evilgix/Evil","owner":"evilgix","description":"Optical Character Recognition in Swift for iOS\u0026macOS.      银行卡、身份证、门牌号光学识别","archived":false,"fork":false,"pushed_at":"2018-02-14T05:43:56.000Z","size":3283,"stargazers_count":691,"open_issues_count":3,"forks_count":99,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-05T09:07:38.430Z","etag":null,"topics":["cnn-model","keras","machine-learning","ocr","swift4","vision"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evilgix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-21T11:45:42.000Z","updated_at":"2025-03-28T21:16:19.000Z","dependencies_parsed_at":"2022-08-20T20:20:47.685Z","dependency_job_id":null,"html_url":"https://github.com/evilgix/Evil","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilgix%2FEvil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilgix%2FEvil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilgix%2FEvil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilgix%2FEvil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evilgix","download_url":"https://codeload.github.com/evilgix/Evil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312078,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnn-model","keras","machine-learning","ocr","swift4","vision"],"created_at":"2024-09-24T20:36:52.186Z","updated_at":"2025-04-05T09:07:43.462Z","avatar_url":"https://github.com/evilgix.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\".images/logo.png\" height=\"140\" /\u003e\n  \u003ch3 align=\"center\"\u003eEvil\u003c/h3\u003e\n  \u003cp align=\"center\"\u003eOptical Character Recognition in Swift for iOS\u0026macOS.\u003c/p\u003e\n  \u003cp align=\"center\"\u003e\n  \t\u003ca href=\"https://github.com/evilgix/Evil\"\u003e\u003cimg src=\"https://travis-ci.org/evilgix/Evil.svg?branch=master\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/evilgix/Evil\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/Evil.svg\"\u003e\u003c/a\u003e\n    \t\u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n  \t\u003ca href=\"https://github.com/evilgix/Evil\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/p/Evil.svg?style=flat\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/evilgix/Evil\"\u003e\u003cimg src=\"https://img.shields.io/badge/qq群-641256202-ff6964.svg\"\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\n---\n\n![debug image](.images/evil-debug.png)\n\n图片来自于网络，侵删\n\n##  Requirements\n\n - iOS 11.0+ / macOS 10.13+\n - Xcode9.2+\n - Swift 4.0+\n\n## [Installation](installation.md)\n\n## Basic Usage\n\nEvil 使用 [Vision](https://developer.apple.com/documentation/vision) 框架进行文字识别，因此你需要导入特定的[MLModel](https://developer.apple.com/documentation/coreml/mlmodel)到你的Xcode工程。例如识别身份证导入识别身份证的model，识别银行卡导入识别银行卡的model。\n\n以下是目前已经训练好的模型\n\n - ChineseIDCard ==\u003e  [🇨🇳中国二代身份证号码识别](http://ou5pk1mdu.bkt.clouddn.com/ChineseIDCard.mlmodel)\n\n### 如何导入\n\n首先从上面的地址下载或者自己训练得到模型文件(`*.mlmodel`)，然后作为resource资源加入项目。但是模型文件size一般都比较大因此Evil还支持另外一种方式即：运行时从指定的服务器下载对应的模型。\n\n 1.  获取对应的模型文件并重名命名为`[name].mlmodel` \n     `[name]`可通过以下方法获取`print(Recognizer.chineseIDCard.name)`\n2. 将模型文件上传至自己的服务器或者CDN并获取下载链接\n3. 在`info.plist` 中配置下载链接如下\n\n![info.plist](.images/evil-download.png)\n\n### 初始化\n\n``` Swift\nlazy var evil = try? Evil(recognizer: .chineseIDCard)\n```\n\n或者 手动指定下载路径\n\n``` Swift\nlet downloadURL = URL(string: \"https://****/ChineseIDCard.mlmodel\")!\nlet chineseIDCard = Recognizer.custom(name: \"ChineseIDCard\", model: downloadURL, needComplie: true, processor: Recognizer.cropChineseIDCardNumberArea)\nlet evil = try? Evil(recognizer: chineseIDCard)\n```\n\n或者直接将模型文件拖入 xcode 项目\n``` Swift\nlet url = Bundle.main.url(forResource: \"ChineseIDCard\", withExtension: \"mlmodelc\")!\nlet evil = try? Evil(contentsOf: url, name: \"ChineseIDCard\")\n```\n注意Extension 为`mlmodelc`而不是`mlmodel`因为xcode会自动编译`mlmodel`文件，并且生成对应的`class`. 所以请务必注意Model文件不要和现有的`class`重名。\n\n### 开始识别\n\n``` Swift\nlet image: Recognizable = .....\nlet result = evil?.recognize(image)\nprint(result)\n```\n\n## 训练模型\n参考Tools 目录下`PrepareBot`项目  \n参考博文[掘金](https://juejin.im/post/5a76ada6f265da4e9d220727)\n\n## 交流讨论\n\t1.github issue (推荐)\n\t2.qq 群：641256202\n\n## LICENSE\n\t MIT\n\nCopyright 2018 - 2019 Kevin.Gong aoxianglele#icloud.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilgix%2Fevil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilgix%2Fevil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilgix%2Fevil/lists"}