faceterteam / PayCards_iOS

Credit card scanning for mobile apps
https://pay.cards/
Other
199 stars 54 forks source link

How do I scan custom card? #12

Open matghazaryan opened 6 years ago

matghazaryan commented 6 years ago

I have specific cards in my country it looks like as MasterCard or VisaCard but it not scanning at all. Is there any options that I can scan custom card?

tchernitski commented 6 years ago

What digit(s) are at the beginning of the card number of your cards? Visa/mastercard cards must start with 4 or 55 or 56. So there is validation at: https://github.com/faceterteam/PayCards_iOS_Source/blob/848fa0fc82b5db253e6b335362caef8e3e60da97/PayCardsRecognizer/CrossPlatform/Recognizer/NumberRecognizer.cpp#L307

That can be a reason why your card has not been recognized. You can modify CNumberRecognizer::CheckSum method to allow your cards.

matghazaryan commented 6 years ago

My card starts with 9 digit. How could I modify it? I have to import it manually and change the code there?

tchernitski commented 6 years ago

Modify the code in PayCards_iOS_Source project, build framework by yourself and replace old one by new one in your project.

matghazaryan commented 6 years ago

I just modified the class and added this line

if (number[0] != 5 && number[0] != 4 && number[0] != 2 && number[0] != 9) { return false; }

I checked the result it was okay this method was called func payCardsRecognizer(_ payCardsRecognizer: PayCardsRecognizer, didRecognize result: PayCardsRecognizerResult)

but after 1 second app crashing. And I have this error. What is that?

CNameRecognizer::Process(cv::Mat&, std::1::vector<cv::Mat, std::1::allocator >&, std::1::basic_string<char, std::__1::char_traits, std::1::allocator >&) ()

tchernitski commented 6 years ago

Does crash happen after each recognition? or time to time? Does the crash happen for any card or only for specific one? According to the crash log something went wrong with name recognition. Just for test, could you please init the recognition module in the way:

let mode = PayCardsRecognizerDataMode(rawValue: PayCardsRecognizerDataMode.date.rawValue|PayCardsRecognizerDataMode.number.rawValue)! recognizer = PayCardsRecognizer(delegate: self, recognizerMode: mode, resultMode: PayCardsRecognizerResultMode.sync, container: recognizerContainer, frameColor: .green)

There is only number and date recognition.

Will there be crash?

vitkuzmenko commented 6 years ago

I was update pod to version 1.1.4. Please make pod update

matghazaryan commented 6 years ago

It was crashing any time but when I put your code it stopped crashing.

let mode = PayCardsRecognizerDataMode(rawValue: PayCardsRecognizerDataMode.date.rawValue|PayCardsRecognizerDataMode.number.rawValue)!
        recognizer = PayCardsRecognizer(delegate: self, recognizerMode: mode, resultMode: PayCardsRecognizerResultMode.async, container: self.view, frameColor: .green)

I putted self.view as my container. is it correct?

I don't know why but name never has been scanned. Maybe the reason is that name in custom card not the same position as in Master card or VISA card.

What is the difference between your code and the previous code?

tchernitski commented 6 years ago

The code I attached above initializes Recognizer with number/date recognition mode. So it tries to recognize number and date but not the name. So it appears the crash happens during name recognition. "Maybe the reason is that name in custom card not the same position as in Master card or VISA card." - yes it is the reason. There is hardcoded ROI that used for name localization/recognition https://github.com/faceterteam/PayCards_iOS_Source/blob/a189f87473777e6e8b9a03845f10825a3f4f942d/PayCardsRecognizer/CrossPlatform/Recognizer/NameRecognizer.cpp#L21

You can try to change coordinates to other position that fits you (not sure if there are no other dependencies, try not to change height and width of the ROI, change only x/y coordinates). Take into account that processing card image has 660/416 px size

It would be great if you share image of problem card so we can try to figure out that causes the crash. For security reason you can mask number and date, but not the name (seems it causes the crash). I will understand if it's impossible. We will try to figure out the issue by ourselves. Thanks

matghazaryan commented 6 years ago

I will do it later and share the result with you of course. Thank you

matghazaryan commented 6 years ago

I still couldn't fix the crash. When I am adding name recognition part it still crashing I did some changes there (i.e I changed nameWindowRect(25,325,494,80) to another value) but it still crashing. If the rect size will be changed is it going to scan VISA or MasterCard?

Is it possible increase the rect left margin or something else? Or what should we can do that it will scan any the names as well

tchernitski commented 6 years ago

Unfortunately we can't reproduce the crash. It seems it in some way connected with exact card you use. Could you answer some questions:

matghazaryan commented 6 years ago

Actually now it is not crashing at all. Maybe you changed something. But I can say that I did a lot of test and now it is working. thank you very much

Magantiaruna commented 6 years ago

image

please open that..this type of card is not able to scan using this framework please help.

tchernitski commented 6 years ago

The framework recognizes only embossed cards. We are planning to add plain cards recognition.

Magantiaruna commented 6 years ago

when can we expect the plain cards recognition...

tchernitski commented 6 years ago

I hope by the end of this year

Magantiaruna commented 6 years ago

if you dont mine ,can you please refer any one framework to support all the cards to scan.

MirshodRaupov commented 4 years ago

Hi @tchernitski, bro The framework doesn't recognize non embossed cards, If you have solution, please share!