OCR optical recognition debit card and credit cards developed by iOS

Source: Internet
Author: User

Recently, because the company needs a scan card to obtain the card number of the function of the Internet to find a lot of relevant information, completely scan the bank card to obtain the card number information is very expensive, and just authorization, here we retreat and seek to find a third-party framework can scan credit card, to share the big guy, Can only scan credit card ... o.0.

The frame's name is cardio.

    • Https://github.com/AllLuckly/card.io-iOS-SDK

Here the main show you how to integrate, you crossing can have to pay attention to! My Xcode is version 7.1, first of all pull the framework into its own project, and then in Targets-build Phases-link binary with libraries inside the following several frameworks are added

Accelerate.framework

Mobilecoreservices.framework

Coremedia.framework

Audiotoolbox.framework

Avfoundation.framework

Add-OBJC and-lc++ in the Targets-build settings-other Linker flags and import the header file #import "CardIO.h" and #import in the VC we need to call CardIOPaymentViewControllerDelegate.h "plus agent Cardiopaymentviewcontrollerdelegate

And then the method of implementation

OC version

- (void)viewdidload {

[Super viewdidload];

[cardioutilities preload];

}

Start Call scan

- (ibaction)begin:(ID)sender {

cardiopaymentviewcontroller *scanviewcontroller = [[ Cardiopaymentviewcontroller Alloc] initwithpaymentdelegate: Self];

[self presentviewcontroller: Scanviewcontroller animated: YES Completion: Nil];

}

Cancel Scan

- (void)userdidcancelpaymentviewcontroller:(cardiopaymentviewcontroller *)scanviewcontroller

{

[scanviewcontroller dismissviewcontrolleranimated: YES completion: nil];

}

Scan complete

-(void)userdidprovidecreditcardinfo:(cardiocreditcardinfo *) info inpaymentviewcontroller:(cardiopaymentviewcontroller *) Scanviewcontroller

{

//Scan results

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 version

Import UIKit

Class Viewcontroller: Uiviewcontroller, cardiopaymentviewcontrollerdelegate {

@Iboutlet weak var resultlabel: UILabel!

Override func Viewdidload() {

Super. Viewdidload()

cardioutilities. Preload()

}

Start Call scan

@ibaction func scancard(sender: anyobject) {

let cardiovc = cardiopaymentviewcontroller(paymentdelegate: Self)

CARDIOVC. Modalpresentationstyle = . Formsheet

Presentviewcontroller(cardiovc, animated: True, completion: nil)

}

Cancel Scan

Func userdidcancelpaymentviewcontroller(paymentviewcontroller: Cardiopaymentviewcontroller!) {

ResultLabel. Text = "User canceled"

paymentviewcontroller?. dismissviewcontrolleranimated(true, completion: nil)

}

Scan complete

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)

}  

}

This is done, the foreigner package is still very good, I hope to find a better way to scan the bank card more useful third-party.

The final effect, the recognition is very accurate OH

OCR optical recognition debit card and credit cards developed by iOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.