[iOS]OCR光学识别信用卡
来源:互联网 发布:源码与公众号 编辑:程序博客网 时间:2024/04/30 04:28
看到一个光学识别信用卡的文章,根据文章测试了下,识别信用卡还算灵敏,但是可惜的是识别不了储蓄卡,这里记录一下:
原文cocoachina微信公共号链接
所用框架github地址:https://github.com/AllLuckly/card.io-iOS-SDK
具体的使用,demo中有介绍,这里只记录一下集成:
将demo里的CardIO文件夹拖进工程,然后在TARGETS---Build Phases---Link Binary With Libraries里边加入系统框架框架:
Accelerate.frameworkMobileCoreServices.frameworkCoreMedia.frameworkAudioToolbox.frameworkAVFoundation.framework
最后,在TARGETS---Build Settings---Other Linker Flags中添加-ObjC和-lc++即可;
接下来就可以使用相关的API了:
首先导入头文件:
#import "CardIO.h"#import "CardIOPaymentViewControllerDelegate.h"
并实现代理CardIOPaymentViewControllerDelegate
实现代理方法:
Objective-C:
(void)viewWillAppear {[super viewWillAppear];[CardIOUtilities preload];}//开始调用扫描- (IBAction)begin:(id)sender {CardIOPaymentViewController *scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:self];[self presentViewController:scanViewController animated:YES completion:nil];}//取消扫描- (void)userDidCancelPaymentViewController:(CardIOPaymentViewController *)scanViewController{[scanViewController dismissViewControllerAnimated:YES completion:nil];}//扫描完成-(void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)info inPaymentViewController:(CardIOPaymentViewController *)scanViewController{//扫描结果NSLog(@"Received card info. Number: %@, expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv);[scanViewController dismissViewControllerAnimated:YES completion:nil];}
Swift:
import UIKitclass ViewController: UIViewController, CardIOPaymentViewControllerDelegate {@IBOutlet weak var resultLabel: UILabel!override func viewDidLoad() {super.viewDidLoad()CardIOUtilities.preload()}//开始调用扫描@IBAction func scanCard(sender: AnyObject) {let cardIOVC = CardIOPaymentViewController(paymentDelegate: self)cardIOVC.modalPresentationStyle = .FormSheetpresentViewController(cardIOVC, animated: true, completion: nil)}//取消扫描func userDidCancelPaymentViewController(paymentViewController: CardIOPaymentViewController!) {resultLabel.text = "user canceled"paymentViewController?.dismissViewControllerAnimated(true, completion: nil)}//扫描完成func userDidProvideCreditCardInfo(cardInfo: CardIOCreditCardInfo!, inPaymentViewController paymentViewController: CardIOPaymentViewController!) {if let info = cardInfo {let str = NSString(format: "Received card info.\\\\n Number: %@\\\\n expiry: %02lu/%lu\\\\n cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv)resultLabel.text = str as String}paymentViewController?.dismissViewControllerAnimated(true, completion: nil)}}
到此,基本就完成了,尝试一下吧!!!
0 0
- [iOS]OCR光学识别信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- 光学字符识别 OCR
- 光学字符识别 OCR
- OCR光学字符识别
- 银行信用卡OCR识别
- OCR:光学字符识别技术
- Office 2010 OCR 光学字符识别技术
- 离线光学字符识别(OCR)技术简介
- Screen OCR(光学字符识别)
- android-ocr 光学字符识别技术
- Tesseract-OCR光学识别引擎 入门
- 光学识别(OCR)之 Tesseract
- Android光学字体识别 -- Android OCR demo
- NOIP2015 跳石头 解题报告(二分答案)
- 最短排序
- css选择器小结
- Python的特色语法
- 2016年年中总结
- [iOS]OCR光学识别信用卡
- Codeforces Round #143 (Div. 2)-B. Magic, Wizardry and Wonders
- 【NOIP 模拟题】刺杀大使(二分答案+并查集)
- JSP学习笔记(第3次):基于配置文件与反射的工厂模式
- MySql commendLine client 常见命令
- listview修改滑动块图标
- python处理csv文件--基础
- JS 点击复制Copy
- opencv源码文件