iOS开发之OCR光学识别储蓄卡以及信用卡
2016-09-01 14:04
316 查看
最近由于公司需要一个扫描银行卡获取卡号的功能,网上找了很多相关的资料,完全扫描银行卡
获取卡号信息的都是价格贵的不得了的,而且仅仅只是授权而已,在此咱退而求次,找到一个可
以扫描信用卡的第三方框架,给大家伙分享一下,只能扫描信用卡……o.0。
框架的名字叫
下载地址
在这里主要给大家演示一下怎么集成的,各位看官可得注意咯!
我的xcode是7.1版本的,首先是把框架整个拉进自己的工程,然后在
TARGETS—Build Phases—Link Binary With Libraries
里边分别加入下面这几个框架
再在TARGETS—Build Settings—Other Linker Flags中添加
然后在我们需要调用的
加上代理
然后是实现的方法
- (void)viewDidLoad {
[super viewDidLoad];
[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: %<a href="http://www.jobbole.com/members/uz441800">@,</a> expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv);
[scanViewController dismissViewControllerAnimated:YES completion:nil];
}
import UIKit
class 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 = .FormSheet
presentViewController(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)
}
}
到此就大功告成了,老外封装的东西还是非常给力的,希望可以找到扫描银行卡比较好用的第三方。
最终的效果,识别的非常准确哦
获取卡号信息的都是价格贵的不得了的,而且仅仅只是授权而已,在此咱退而求次,找到一个可
以扫描信用卡的第三方框架,给大家伙分享一下,只能扫描信用卡……o.0。
框架的名字叫
CardIO
下载地址
在这里主要给大家演示一下怎么集成的,各位看官可得注意咯!
我的xcode是7.1版本的,首先是把框架整个拉进自己的工程,然后在
TARGETS—Build Phases—Link Binary With Libraries
里边分别加入下面这几个框架
Accelerate.framework
MobileCoreServices.framework
CoreMedia.framework
AudioToolbox.framework
AVFoundation.framework
再在TARGETS—Build Settings—Other Linker Flags中添加
-ObjC和
-lc++
然后在我们需要调用的
VC中导入头文件
#import "CardIO.h"和
#import "CardIOPaymentViewControllerDelegate.h"
加上代理
CardIOPaymentViewControllerDelegate
然后是实现的方法
OC版
Objective-C- (void)viewDidLoad {
[super viewDidLoad];
[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: %<a href="http://www.jobbole.com/members/uz441800">@,</a> expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv);
[scanViewController dismissViewControllerAnimated:YES completion:nil];
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | - (void)viewDidLoad { [super viewDidLoad]; [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: %<a href="http://www.jobbole.com/members/uz441800">@,</a> expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv); [scanViewController dismissViewControllerAnimated:YES completion:nil]; } |
SWIFT版
Objective-Cimport UIKit
class 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 = .FormSheet
presentViewController(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)
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import UIKit class 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 = .FormSheet presentViewController(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) } } |
最终的效果,识别的非常准确哦
相关文章推荐
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- iOS开发之OCR光学识别储蓄卡以及信用卡
- [iOS]OCR光学识别信用卡
- iOS开发之信用卡 扫描识别卡号信息(card.io)
- Android身份证识别SDK开发包/iOS身份证识别OCR
- 【iOS-Cocos2d游戏开发之二十一 】自定义精灵类并为你的精灵设置攻击帧以及动画创建!【一】
- 【iOS-Cocos2d游戏开发之十六】添加本地通知(UILocalNotification)以及添加系统组件滚动视图(UIScrollView)!【2011年11月15日更新】
- iOS开发之---静态库的编译以及相关问题的处理
- 【iOS-Cocos2d游戏开发之三】CCScene切换的所有特效(27种)以及设置屏幕横竖屏!
- 【iOS-Cocos2d游戏开发之二十一 】自定义精灵类并为你的精灵设置攻击帧(指定开始帧)以及扩展Cocos2d源码的CCAnimation简化动画创建!
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)! .
- 【iOS-Cocos2d游戏开发之十一】使用Box2d物理系统以及在cocos2d框架添加Box2d物理系统lib包的方法
- 开发者畅谈WP iOS以及Android开发经验
- IOS开发之---静态库的编译以及相关问题的处理
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)!
- 【iOS-Cocos2d游戏开发之二十一 】自定义精灵类并为你的精灵设置攻击帧以及动画创建!【二】 推荐
- 【iOS-Cocos2d游戏开发之十八】解决滚屏背景/拼接地图有黑边(缝隙)以及禁止游戏中自动锁屏问题