ChineseIDCardOCR 0.0.4

ChineseIDCardOCR 0.0.4

测试已测试
语言语言 SwiftSwift
许可证 Apache 2
发布最后发布2016年8月
SPM支持 SPM

Kevin.Gong 维护。



  • Kevin.Gong

ChineseIDCardOCR

ChineseIDCardOCR 是一个用 Swift 编写的框架,用于识别中国二代身份证信息。它基于 Swift-ORC 进行修改。

功能

  • [x] 简洁易用的扫描界面
  • [x] 简洁的 Train 接口
  • [x] 身份证号码识别
  • [ ] 身份证姓名、性别、地址识别
  • [ ] 图片预处理逻辑优化
  • [ ] 单元测试覆盖率

要求

  • iOS 9.0+
  • Xcode 7.3+

使用示例

扫描身份证

import ChineseIDCardOCR

let vc = ScannerViewController()
vc.didRecognizedHandler = { idcard in
    debugPrint(idcard) 
}
presentViewController(vc, animated: true, completion: nil)  

识别图片

import ChineseIDCardOCR

let ocrInstance = IDCardOCR()

let idCardImage = UIImage ... ...

ocrInstance.recognize { recoginzedResult in 
    debugPrint(recoginzedResult)
}

工作原理

ChineseIDCardOCR 会检测传入的 UIImage 的人脸,根据检测到的 frame 和身份证比例,计算身份证号码所在的 Rect,然后截取图片。获取身份证号码图片后,利用 GPUImage 对图片进行一系列预处理,根据 连通分量标记理论,将身份证号码图片剪切成 18 个单独的小图片。然后利用 前馈神经网络 (FFNN) 对每个图片进行识别。

FFNN 训练

在 framework 中提供了 OCR-Training.swift,可以根据自己的特点提供单独的训练数据。

依赖项

许可证

The code in this repository is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

注意:此软件依赖于可能在不同开源许可证下分发的其他包。